Get changes coordinates

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 →

On this page

GroupDocs.Comparison allows you to detect changes between source and target documents and get changes coordinates at document preview images. These coordinates can be useful to highlight changes at the document preview images.

To get the changes coordinates, 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. Instantiate the CompareOptions object. Set the CalculateCoordinates property to true.
  4. Set the CalculateCoordinatesMode to CalculateCoordinatesModeEnumeration.Source or CalculateCoordinatesModeEnumeration.Target if you want to get coordinates from source or target document.
  5. Call the Comparer method. Specify the CompareOptions object from the previous step.
  6. Call the GetChanges method.

The following code snippet shows how to compare multiple documents with specific options:

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

using (Comparer comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");
    CompareOptions compareOptions = new CompareOptions(){ CalculateCoordinates = true };
    comparer.Compare(compareOptions);
    ChangeInfo[] changes = comparer.GetChanges();
    foreach (ChangeInfo change in changes)
        Console.WriteLine("Change Type: {0}, X: {1}, Y: {2}, Text: {3}", 
            change.Type, 
            change.Box.X, 
            change.Box.Y, 
            change.Text);
}

The result is as follows:

On this page