In this post, we will see how to compare two Word Documents by using C++ with Aspose.Words for C++ 19.6 API.

C++ MS Word Document Comparison

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 that is equal to the original document. On the contrary, if we accept all revisions then we get the final (comparison target) document.

Compare Word Documents using C++

The following example shows a normal comparison case.

C++ MS Word Comparison - Check If Documents are Same

The below example shows how to test that Word Documents are “Equal”.


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.

The resources, you may need to accomplish your tasks:

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.