Compare documents

Changes detection algorithms used by GroupDocs.Comparison allows you to detect changes in different document parts and blocks:

  • Text blocks - paragraphs, words and characters
  • Tables
  • Images
  • Shapes etc.

GroupDocs.Comparison highlights detected changes with different colors:

  • Added – blue 
  • Modified – green
  • Style – green
  • Deleted – red

You can customize the changes styling scheme using different formatting - italic, bold, underlined, strike through, etc.

To compare two documents, follow these steps:

  1. Instantiate the Comparer object with source document path or stream.
  2. Call the Add method and specify target document path or stream.
  3. Call the Compare method.

The following code snippets show how to compare two documents:

Compare local documents

using GroupDocs.Comparison;
// ...

using (Comparer comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");
    comparer.Compare("result.docx");
}

The output file is as follows:

Compare documents from stream

using GroupDocs.Comparison;
using System.IO;
// ...

using (Comparer comparer = new Comparer(File.OpenRead("source.docx")))
{
    comparer.Add(File.OpenRead("target.docx"));
    comparer.Compare(File.Create("result.docx"));
}