Related blog post: Compare PDF Documents using C#
Last active
April 18, 2023 08:00
-
-
Save GroupDocsGists/bf49902dda69a05f94f88a324f67dd4e to your computer and use it in GitHub Desktop.
Compare PDF Documents, Find Differences, and Accept or Reject Changes using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Accept and reject identified changes by comparing PDF documents using C# | |
*/ | |
using (Comparer comparer = new Comparer(@"path/document-1.pdf")) | |
{ | |
comparer.Add(@"path/document-2.pdf"); | |
comparer.Compare(); | |
ChangeInfo[] changes = comparer.GetChanges(); | |
// Rejecting the first identified change and it will not be added to result document | |
changes[0].ComparisonAction = ComparisonAction.Reject; | |
comparer.ApplyChanges(@"path/rejected-change-result.pdf", new ApplyChangeOptions { Changes = changes, SaveOriginalState = true }); | |
changes = comparer.GetChanges(); | |
changes[0].ComparisonAction = ComparisonAction.Accept; | |
comparer.ApplyChanges(@"path/accepted-change-result.pdf", new ApplyChangeOptions { Changes = changes }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compare Multiple PDF Documents using C# | |
*/ | |
using (Comparer comparer = new Comparer(@"path/document-1.pdf")) | |
{ | |
comparer.Add(@"path/document-2.pdf"); | |
comparer.Add(@"path/document-3.pdf"); | |
comparer.Add(@"path/document-4.pdf"); | |
comparer.Compare(@"path/compare-result.pdf"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compare Two PDF Documents and Highlight Changes using C# | |
*/ | |
using (Comparer comparer = new Comparer(@"path/document-ver1.pdf")) | |
{ | |
comparer.Add(@"path/document-ver2.pdf"); | |
comparer.Compare(@"path/compared-result.pdf"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compare Password Protected PDF Documents using C# | |
*/ | |
using (Comparer comparer = new Comparer(@"path/protected-document-1.pdf", new LoadOptions(){ Password = "SourceFilePassword" })) | |
{ | |
comparer.Add(@"path/protected-document-2.pdf", new LoadOptions() { Password = "TargetFilePassword" }); | |
comparer.Compare(@"path/compared-protected-docs-result.pdf"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment