In this post, we will see how to Compare two Word Documents by using Aspose.Words for C++ 19.6 API.
You can use Document.Compare method to compare two Word documents to see the difference between them. This method mimics Microsoft Word’s Compare feature and produces document difference as a number of edit and format revisions. The main idea is that if we reject all revisions then we get a document which is equal to the original document. On the contrary, if we accept all revisions then we get the final (comparison target) document.
There are a few general limitations:
- The document being compared must not have revisions before this method is called.
- Markup – is limited to SmartTag only. Other markups are ignored completely.
- DML- Fallback shapes are compared instead of actual DML comparison.
There is an important note regarding “equal”. Actually “equality” means here that the comparison method is not able to represent changes as revisions. In general, it means that both document text and text formatting are the same. But there can be other difference between documents. For example, Word supports only format revisions for styles and we can’t represent style insertion/deletion. So documents can have a different set of styles and the Compare method still produces no revisions.
Following example shows normal comparison case.
Below example shows how to test that Word Documents are “Equal”.
See Also Useful Links
The resources, you may need to accomplish your tasks:
- Aspose.Words for C++ Online Documentation – up-to-date documentation containing Programmer’s Guide, Knowledge Base and much more.
- Aspose.Words for C++ Product Page
- Install Aspose.Words for C++ NuGet Package
- Aspose.Words for C++ API Reference Guide – detailing the publicly exposed classes, methods, properties, constants & interfaces.
- Download Examples at GitHub Repository – we have published our code examples on the social coding website GitHub.com. Anyone could explore the code examples for learning purposes.
Keeping the Aspose tradition, you are welcome to shape the upcoming releases of Aspose.Words for C++ API by posting your suggestions and concerns in the Aspose.Words for C++ support forum.