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 no-argument Compare() call performs the comparison in-memory without writing a result file — use it when you only need the change list and do not need to save the marked-up document.

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

Get list of changes from local disk

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

using (Comparer comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");
    comparer.Compare();
    ChangeInfo[] changes = comparer.GetChanges();
    foreach (ChangeInfo change in changes)
        Console.WriteLine("Change Type: {0}, Page: {1}, Change ID: {2}, Text: {3}", 
            change.Type, 
            change.PageInfo.PageNumber, 
            change.Id, 
            change.Text
        );
}

The result is as follows:

Get list of changes 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("target.docx"));
    comparer.Compare();
    ChangeInfo[] changes = comparer.GetChanges();
    foreach (ChangeInfo change in changes)
        Console.WriteLine("Change Type: {0}, Page: {1}, Change ID: {2}, Text: {3}", 
            change.Type, 
            change.PageInfo.PageNumber, 
            change.Id, 
            change.Text
        );
}

See also