Get list of changes

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison allows you to get list of changes between source and target documents.

To get 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 list of all changes:

Get list of changes from local disk

import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.result.ChangeInfo;
// ...

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:

Get list of changes from stream

import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.result.ChangeInfo;
import java.io.FileInputStream;
import java.io.InputStream;
// ...

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