Get a list of changes

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:

  1. Instantiate the Comparer object. Specify the source document path or stream.
  2. Call the add() method. Specify the target document path or stream.
  3. Call the compare() method.
  4. Call the getChanges method.

The following code snippets show how to get a list of all changes:

Get a list of changes from a local disk

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:

Get a list of changes from a stream

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());
}
Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.