Get list of changes
Leave feedback
On this page
GroupDocs.Comparison allows you to get list of changes between source and target documents.
To get list of changes, follow these steps:
- Instantiate the Comparer object. Specify the source document path or stream.
- Call the Add method. Specify the target document path or stream.
- Call the Compare method.
- Call the GetChanges method.
The following code snippets show how to get list of all changes:
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...
using (Comparer comparer = new Comparer("source.docx"))
{
comparer.Add("target.docx");
comparer.Compare();
ChangeInfo[] changes = comparer.GetChanges();
foreach (ChangeInfo change in changes)
Console.WriteLine("Change Type: {0}, Page: {1}, Change ID: {2}, Text: {3}",
change.Type,
change.PageInfo.PageNumber,
change.Id,
change.Text
);
}
The result is as follows:
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
using System.IO;
// ...
using (Comparer comparer = new Comparer(File.OpenRead("source.docx")))
{
comparer.Add(File.OpenRead("target.docx"));
comparer.Compare();
ChangeInfo[] changes = comparer.GetChanges();
foreach (ChangeInfo change in changes)
Console.WriteLine("Change Type: {0}, Page: {1}, Change ID: {2}, Text: {3}",
change.Type,
change.PageInfo.PageNumber,
change.Id,
change.Text
);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.