How to Compare PDF files

When working with similar documents, it becomes increasingly difficult to find the difference between what was changed in one of the versions, especially when working with large-volume documents.Such functionality as PDF document comparison can significantly improve your work efficiency and, most importantly, speed it up.GroupDocs.Comparison gives you many options for comparing a wide range of supported file formats, including PDF format.

After the comparison, there are three colors on the resulting file that highlight the differences. You can also specify the colors yourself to identify the next difference:

  • Elements that were inserted in the first file. – blue, by default
  • Elements wich were deleted from the first file – red, by default
  • Elements that have changed their styles (font, color, etc.) – green, by default
Source / Target / Result PDF files
Source
Target
Result

The code sample to compare two PDF files:

string sourcePath = @"source.pdf"; // NOTE: Path to the source pdf document
string targetPath = @"target.pdf"; // NOTE: Path to the target pdf document
string resultPath = @"result.pdf"; // NOTE: Path to the result pdf document

using (Comparer comparer = new Comparer(sourcePath))
{
    comparer.Add(targetPath);
    CompareOptions compareOptions = new CompareOptions
   {
        DetectStyleChanges = true,
        DetalisationLevel = DetalisationLevel.High
   };
    comparer.Compare(resultPath, compareOptions);
}

As a result, we get a PDF file with highlighted changes, in which the deleted elements are marked with a font red, the added – in blue, and the modified – in green.

More resources

Advanced Usage Topics

To learn more about document comparison features, please refer to the advanced usage section.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to compare your DOC or DOCX, XLS or XLSX, PPT or PPTX, PDF, EML, EMLX, MSG and other documents with free to use online GroupDocs Comparison App.