Compare PDF files in C#

Powerful C# library to compare PDF documents and detect even small differences

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

How PDF Compare works

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

To compare two PDF documents, our powerful .NET 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 .NET API to compare documents.

Compare PDF 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 PDF 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 PDF documents

To compare PDF s and verify how our .NET 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 PDF 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 Aspose.Words;

var docA = new Document("Input1.pdf");
var docB = new Document("Input2.pdf");

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

docA.Compare(docB, "Author Name", DateTime.Now);
docA.Save("Output.pdf");
Run code

How to compare two PDF in C#

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

C# library to compare PDF documents

There are three alternative options to install "Aspose.Words for .NET" onto your system. Please choose one that resembles your needs and follow the step-by-step instructions:

System Requirements

Our product is fully cross-platform and supports all major .NET implementations following '.NET Standard 2.0' specification:

  • Microsoft .NET Framework, starting from the earliest 2.0 version, and ending with the latest '.NET Framework 4.8'
  • .NET Core, starting from the earliest 2.0, and ending with the latest '.NET 6'
  • Mono >= 2.6.7

As far as .NET code doesn't depend on the underlying hardware or operating system, but only on a Virtual Machine, you are free to develop any kind of software for Windows, macOS, Android, iOS and Linux. Just make sure you have installed the corresponding version of .NET Framework, .NET Core, Windows Azure, Mono or Xamarin.

We recommend using Microsoft Visual Studio, Xamarin, and MonoDevelop integrated development environments to create C#, F#, VB.NET applications.

Fore more details please refer to 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-2022. All Rights Reserved.