Get a list of changes
On this page
GroupDocs.Comparison allows you to get a list of changes between the source and target documents.
To get a list of changes, follow these steps:
- Instantiate the Comparerobject. Specify the source document path or stream.
- Call the add()method. Specify the target document path or stream.
- Call the compare()method.
- Call the getChangesmethod.
The following code snippets show how to get a list of all changes:
const comparer = new groupdocs.comparison.Comparer(source);
comparer.add(target);
comparer.compare();
let changes = comparer.getChanges();
for (ChangeInfo change : changes) {
    Console.log("Change Type: " + change.getType() +
                        ", Page: " + change.getPageInfo().getPageNumber() +
                        ", Change ID: " + change.getId() +
                        ", Text: " + change.getText());
}
The result is as follows:

const comparer = new groupdocs.comparison.Comparer(new FileInputStream(source));
comparer.add(new FileInputStream(target));
comparer.compare();
let changes = comparer.getChanges();
for (ChangeInfo change : changes) {
    Console.log("Change Type: " + change.getType() +
                        ", Page: " + change.getPageInfo().getPageNumber() +
                        ", Change ID: " + change.getId() +
                        ", Text: " + change.getText());
}
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.