Compare multiple documents

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 →
Note
This feature is available only for Word documents, PowerPoint and Open Document presentations.

GroupDocs.Comparison allows you to compare more than two documents.

To compare several documents, follow these steps:

  1. Instantiate the Comparer object. Specify the source document path or stream.
  2. Call the add() method and specify target document path or stream. Repeat this step for every target document.
  3. Call the compare() method.

The following code snippets show how to several documents:

Compare several documents from a local disk

import com.groupdocs.comparison.Comparer;
import java.nio.file.Path;
// ...

try (Comparer comparer = new Comparer("source.docx")) {
    comparer.add("target.docx");
    comparer.add("target2.docx");
    comparer.add("target3.docx");
    final Path resultPath = comparer.compare("result.docx");
}

The result is as follows:

Compare several documents from a stream

import com.groupdocs.comparison.Comparer;
import java.nio.file.Path;
import java.io.FileInputStream;
import java.io.InputStream;
// ...

try (Comparer comparer = new Comparer(sourceInputStream)) {
    comparer.add(targetInputStream1);
    comparer.add(targetInputStream2);
    comparer.add(targetInputStream3);
    final Path resultPath = comparer.compare(resultInputStream);
}