Compare Word files in C++

Powerful C++ library to compare Word documents and detect even small differences

Compare two Word files in C++ using our difference checker. With our high-fidelity C++ API, you can find the difference between compared Word documents and export the results to a convenient file format.

How Word Compare works

Comparing documents is a rather difficult function to implement. But our C++ solution is designed so that you can get the most accurate result.

To compare two Word documents, our powerful C++ library compares content at both the character level and word level. If only a character has been changed, the word will be marked as the whole changed.

This way you can no longer look for differences in documents manually, but instead use our C++ API to compare documents.

Compare Word files using C++

Sometimes you are not sure if a document has not been modified, and comparing two document versions manually can be tricky. Or vice versa, you know for sure that the document has been changed, but manually searching for updated places is too hard.

In all these situations and more, you can diff two Word files using our product API. To compare two documents, simply load them, call the comparison method, and get the result in a convenient file format. This allows you to find even small changes that would be invisible to the human eye.

Compare two Word documents

To compare Word s and verify how our C++ library works, simply load the files you want to diff and select the export file format. After comparing two files, the document containing the difference of this comparison will be automatically loaded.

An important point: the compared documents should not have any revisions before calling the comparison method. And it is necessary to accept all revisions, which we have already taken care of in our example:

Compare two DOCX files using C++
Input files
Upload the compared file
Run code
Upload the second file to compare
Output format
Select the target format from the list
using namespace Aspose::Words;

auto docA = MakeObject<Document>(u"Input1.docx");
auto docB = MakeObject<Document>(u"Input2.docx");

// There should be no revisions before comparison.
docA->AcceptAllRevisions();
docB->AcceptAllRevisions();

docA->Compare(docB, u"Author Name", time(0));
docA->Save(u"Output.docx");
Run code

How to compare two Word in C++

  1. Install 'Aspose.Words for C++'
  2. Add a library reference (import the library) to your C++ project
  3. Load two Word to compare
  4. Accept all revisions before calling the 'Compare()' method
  5. Call the 'Compare()' method to compare two Word
  6. Call the 'Save()' method, passing an output filename with required extension
  7. Get the result of compression Word as a separate file

C++ library to compare Word documents

There are three options to install Aspose.Words for C++ to your developer environment. Please choose one that resembles your needs and follow the step-by-step instructions:

System Requirements

You can use this C++ library to develop software on Microsoft Windows, Linux and macOS operating systems:

  • GCC >= 6.3.0 and Clang >= 3.9.1 are required for Linux
  • Xcode >= 12.5.1, Clang and libc++ are required for macOS

If you develop software for Linux or macOS, please check information on additional library dependencies (fontconfig and mesa-glu open-source packages) in Product Documentation.

Other supported file formats

You can perform compare operation for other file formats:

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2023. All Rights Reserved.