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:
try (Comparer comparer = new Comparer("source.docx")) {
comparer.add("target.docx");
comparer.compare();
ChangeInfo[] changes = comparer.getChanges();
for (ChangeInfo change : changes) {
System.out.println("Change Type: " + change.getType() +
", Page: " + change.getPageInfo().getPageNumber() +
", Change ID: " + change.getId() +
", Text: " + change.getText());
}
}
The result is as follows:
try (final FileInputStream sourceInputStream = new FileInputStream("source.docx");
final Comparer comparer = new Comparer(sourceInputStream);
final FileInputStream targetInputStream = new FileInputStream("target.docx")) {
comparer.add(targetInputStream);
comparer.compare();
ChangeInfo[] changes = comparer.getChanges();
for (ChangeInfo change : changes) {
System.out.println("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.