Get Changes Coordinates

GroupDocs.Comparison for Python via .NET can compute pixel coordinates for each detected change, letting you overlay highlights on preview images of the source and target documents.

Example: Get coordinates for detected changes

Enable coordinate calculation, run the comparison, and inspect the box on each change:

from groupdocs.comparison import Comparer
from groupdocs.comparison.options import CompareOptions

def get_changes_coordinates():
    with Comparer("./source.docx") as comparer:
        comparer.add("./target.docx")
        options = CompareOptions()
        options.calculate_coordinates = True
        comparer.compare(options)
        for change in comparer.get_changes():
            print(f"Type: {change.type}, X: {change.box.x}, Y: {change.box.y}, Text: {change.text}")

if __name__ == "__main__":
    get_changes_coordinates()

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.

Type: 2, X: 488.96243, Y: 223.86372, Text: Cool
Type: 2, X: 560.054, Y: 223.86372, Text:  
Type: 3, X: 389.23828, Y: 285.49686, Text: test 
Type: 2, X: 206.4055, Y: 375.95325, Text:  signatures
Type: 2, X: 119.997, Y: 595.8851, Text: Our 
Type: 2, X: 435.85577, Y: 657.51825, Text: char[
Type: 2, X: 435.85577, Y: 657.51825, Text: 255]
Type: 2, X: 498.0422, Y: 657.51825, Text:  
Type: 3, X: 119.997, Y: 922.6783, Text:

Download full output

Use case: draw bounding boxes over page previews to visualise change locations.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.