Compare multiple documents with specific compare settings

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 available for Microsoft Word documents, Microsoft PowerPoint, and Open Document presentations only.

GroupDocs.Comparison allows you to compare more than two documents and specify specific comparison options like styling for detected changes, comparison detalization level, etc.

To compare multiple documents using the specific options, follow these steps:

  1. Instantiate the Comparer object. Specify the source document path or stream.
  2. Call the Add method and specify the target document path or stream. Repeat this step for every target document.
  3. Instantiate the CompareOptions object and specify the appropriate options.
  4. Call the Compare method. Specify the pass CompareOptions object from the previous step.

The following code snippets show how to compare multiple documents with the appropriate options:

Compare multiple documents with specific compare settings from local disk

using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...

using (Comparer comparer = new Comparer("source.docx"))
{
    comparer.Add("target1.docx");
    comparer.Add("target2.docx");
    comparer.Add("target3.docx");
    CompareOptions compareOptions = new CompareOptions()
    {
        InsertedItemStyle = new StyleSettings()
        {
            FontColor = System.Drawing.Color.Yellow
        }
    };
    comparer.Compare("result.docx", compareOptions);
}

The result is as follows:

Compare multiple documents with specific compare settings from stream

using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
using System.IO;
// ...

using (Comparer comparer = new Comparer(File.OpenRead("source.docx")))
{
    comparer.Add(File.OpenRead("target1.docx"));
    comparer.Add(File.OpenRead("target2.docx"));
    comparer.Add(File.OpenRead("target3.docx"));
    CompareOptions compareOptions = new CompareOptions()
    {
        InsertedItemStyle = new StyleSettings()
        {
            FontColor = System.Drawing.Color.Yellow
        }
    };
    comparer.Compare(File.Create("result.docx"), compareOptions);
}