Comparing documents

Word API Comparing Documents is a feature that compares two documents created in Microsoft Word to see the differences between them.
The following three methods are available for checking the differences:

Comparing documents

Compares two documents and creates a document with underlines and other decorations for inserted and deleted parts.
The differences can be checked from the created document.

Example of Microsoft Word "Compare" feature

This is an example of using the document comparison feature of Microsoft Word.
Documents can be compared by selecting files to be compared in the [Compare Documents] dialog that appears under [Review]-[Compare].
The following figure shows an example of the result (center) of comparing the original (left) and the revised version (right) in Microsoft Word.
The red framed area in the original document represents the parts that have been deleted in the revised version.
The blue framed area in the revised version shows the parts added in the revised version.

Compare documents by Microsoft Word Results1 Image

Compare documents by Microsoft Word Results2 Image

Example of Word API "Comparing documents" feature

Similarly, the Word API can compare documents and output documents with decorations such as underlining in inserted or deleted parts.
The following figure shows an example of the result (center) of comparing the original document (left) and the revised document (right) using the Word API.
The red framed area in the original document represents the part that was deleted in the revised version.
The blue framed area in the revised version shows the parts added in the revised version.

Compare documents by WordAPI Results1 Image

Compare documents by WordAPI Results2 Image

Getting the changed ratio

The Word API compares two documents and obtains the following ratio as percentages.
The changed ratio is obtained only for differences in the body text area.

  • Same Ratio
  • Deleted Ratio
  • Inserted Ratio

Example of changed ratio

If you get the changed ratio in the following images using Word API, you will get the following percentage of Same, Deleted and Inserted Ratio:

  • Same Ratio is 60%
  • Deleted Ratio is 31%
  • Inserted Ratio is 9%

Compare documents by WordAPI Results1 Image

Compare documents by WordAPI Results2 Image

Creatinge a comparison table

The Word API compares two documents and creates a comparison table of the differences.
The created table consists of the left column as the "Revised" column and the right column as the "Original" column.
The contents displayed in each row will be decorated with the following characters depending on the contents of the differences.
The comparison table will be created from the differences in the body text area only.

Changes Revised Document Original Document
Deleted paragraph [Delete] String with double lines.
Added paragraph String with double lines. [Add]
Changed paragraph The changed character string with the difference underlined. Character string before change with the difference underlined.

Example of comparison table

The following figure shows an example of a comparison table (center) created by comparing the original (left) with the revised version (right) using the Word API.

Comparison Table result

Sample files

[Install directory]/samples/templates/Document_comparison.zip contains sample files for document comparison.