Get source and target text from files
Leave feedback
On this page
GroupDocs.Comparison for Python via .NET provides access to the source and target text for each detected change.
Compare two files and print the source/target text for each change.
import groupdocs.comparison as gc
with gc.Comparer("source.docx") as comparer:
comparer.add("target.docx")
comparer.compare("result.docx")
changes = comparer.get_changes()
for change in changes:
print()
print("Source text:", change.source_text)
print("Target text:", change.target_text)
🔹 Use case: Extract changed text pairs to power side-by-side diff review tools.
The result is as follows:
Work directly with streams and retrieve the same data programmatically.
import groupdocs.comparison as gc
with open("source.docx", "rb") as src, open("target.docx", "rb") as tgt:
with gc.Comparer(src) as comparer:
comparer.add(tgt)
comparer.compare("result.docx")
changes = comparer.get_changes()
for change in changes:
print()
print("Source text:", change.source_text)
print("Target text:", change.target_text)
🔹 Use case: Feed structured change text into analytics or translation workflows.
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.