Get Comparison Result as a Document Object

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 for Python via .NET returns a Document object from Comparer.compare() that exposes the result file name, detected changes, and the result stream. The object model is compatible with Aspose libraries, so you can pass it into downstream processing pipelines.

Example: Obtain the result Document object

from groupdocs.comparison import Comparer

def get_result_document_object():
    with Comparer("./source.docx") as comparer:
        comparer.add("./target.docx")
        result_document = comparer.compare("./result.docx")
        for change in result_document.changes:
            print(f"Source text: {change.source_text}")
            print(f"Target text: {change.target_text}\n")

if __name__ == "__main__":
    get_result_document_object()

source.docx is the source file used in this example. Click here to download it.

target.docx is the target file used in this example. Click here to download it.

Binary file (DOCX, 25 KB)

Download full output

The result will list source and target text segments for each detected change.