Compare Documents
Wordize supports comparison of documents in any format:
- to compare documents, use the Wordize Comparison for .NET module
- to work with documents in the required formats, select the appropriate document conversion module
Wordize provides an easy and efficient way to compare two documents and highlight their differences. This feature helps track changes between document versions, whether for collaboration, version control, or content auditing.
With the Wordize Comparison for .NET, you can programmatically compare two documents and generate a document with the detected changes. The comparison results include insertions, deletions, and modifications, making it easy to review document differences.
How to Compare Documents
When comparing documents, differences between the second and first documents are displayed as revisions in the first document – each detected change will have its revision.
The comparison functionality in Wordize is accessible through the Comparer class, which provides the Compare methods for comparing documents.
The following code example shows how to compare DOCX and DOC documents:
var doc1 = "Document1.docx";
var doc2 = "Document2.doc";
Comparer.Compare(doc1, doc2, "CompareDocuments.1.docx", "Author", new DateTime());
To compare documents, you will need the following Wordize modules with the corresponding licenses:
- The Wordize Comparison for .NET module, which provides functionality for comparing documents.
- The mandatory Wordize Core for .NET module, which allows users to load and save documents in Microsoft Word format. Without purchasing this module, none of the other modules will work.
- Optional: other document conversion module to work with the required formats. For example, to compare two HTML documents, you will also need the additional Wordize Web for .NET module.
Compare Documents and Save the Result as an Image
You can also compare two documents and save the result as an image using the CompareToImages method. In this case, each element of the returned array represents a single page of the output, rendered as an image.
The following code example shows how to compare two DOCX documents and save the result as a PNG:
Stream[] pages = Comparer.CompareToImages("Document1.docx", "Document2.docx", new ImageSaveOptions(SaveFormat.Png), "Wordize", Datetime.Now);
Compare Documents Using Comparison Options
For a more precise comparison, you can use CompareOptions:
- CompareMoves – specifies whether to compare the differences between two documents and present the differences as a move revision, defaults to “false”
- IgnoreCaseChanges – specifies no case sensitivity, defaults to “true”
- IgnoreTables – specifies whether to ignore data in tables when comparing, defaults to “false”
- IgnoreFields – specifies whether to ignore data in fields when comparing, defaults to “false”.
- IgnoreFootnotes – specifies whether to ignore data in footnotes and endnotes when comparing, defaults to “false”.
- IgnoreComments – specifies whether to ignore data in comments when comparing, defaults to “false”.
- IgnoreTextboxes – specifies whether to ignore data in text boxes when comparing, defaults to “false”.
- IgnoreFormatting – specifies whether to ignore formatting when comparing, defaults to “false”.
- IgnoreHeadersAndFooters – specifies whether to ignore data in headers and footers when comparing, defaults to “false”.
- Granularity – specifies whether changes are tracked by characters or by words, defaults to “WordLevel”
The following code example shows how to compare DOCX and DOC documents, using IgnoreCaseChanges option:
var doc1 = "Document1.docx";
var doc2 = "Document2.doc";
CompareOptions compareOptions = new CompareOptions();
compareOptions.IgnoreCaseChanges =true;
Comparer.Compare(doc1, doc2, "CompareDocuments.3.docx", "Author", new DateTime(), compareOptions);