Accept or reject PDF comparison changes in C#
You might be looking for an API that provides ability to apply or discard specific changes between source and target documents and save resultant document with (or without) selected changes.
About the API
GroupDocs.Comparison for .NET is a back-end API that can be integrated in any .NET (existing or new) application without any third party tool/software dependency. Currently API supports all these file formats.
Steps to apply/reject changes
- Instantiate Comparer object with source document path or stream
- Call Add method and specify path target document path or stream
- Call Compare method
- Call GetChanges method and obtain detected changes list
- Set ComparisonActionof needed change object to ComparisonAction.Accept or ComparisonAction.Reject value
- Call ApplyChanges method and pass collection of changes to it
using (Comparer comparer = new Comparer("source.pdf"))
{
comparer.Add("target.pdf");
comparer.Compare();
ChangeInfo[] changes = comparer.GetChanges();
changes[0].ComparisonAction = ComparisonAction.Reject;
comparer.ApplyChanges(File.Create("result.pdf"),
new SaveOptions(), new ApplyChangeOptions()
{ Changes = changes });
}
ApplyChangeOptions Class
Changes — List of changes that must be applied (or not) to the resulting document.
You can see that in “without change.pdf” file the text “Powerful document comparison APIs” is not highlighted that means its the rejected one. A complete list of changes is available in ChangeInfo.
Please access API from download section. Get release or features related updates on blog. Feel free to share your concerns on forum.