To get the result document object, follow these steps:
Instantiate the Comparer object. Provide the source document path
or stream.\
Call the add() method and provide the target document path or
stream.\
Call the compare() method and assign its return value to a
Document object.
With the Document object, you can access the file name, detected changes, stream, and other information. The object model is fully compatible with Aspose libraries, so you can also use it for advanced
processing.
Example: Obtain the result document object and get changes
importgroupdocs.comparisonasgcsource_path="source.docx"target_path="target.docx"result_path="result.docx"# Initialize comparer with the source documentwithgc.Comparer(source_path)ascomparer:# Add target documentcomparer.add(target_path)# Perform comparison and get the result Document objectresult_document=comparer.compare(result_path)# Iterate through detected changesforchangeinresult_document.changes:print("\033[92mSource text:\033[0m",change.source_text)# greenprint("\033[94mTarget text:\033[0m",change.target_text,"\n")# blue
The result will list source and target text segments for each detected
change.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.