Compare, test and inspect PDF and Word documents in .NET

See what changed. Know what matters.

PDiffy detects meaningful changes in content, structure, layout and accessibility, without the noise of binary differences. It says what changed, element by element, and for a PDF, on the page where it happened.

$ dotnet add package PDiffy
TrailGuideTests.cs
[Fact]
public async Task TrailGuide_ShouldMatchApprovedSnapshot_WhenGenerated()
{
    using Stream pdf = await ReportGenerator.CreateTrailGuideAsync();
    await Snapshot.VerifyPdfAsync(pdf);
}
When the guide changes
3 change(s): 1 moved, 1 attribute, 1 text
by section: structure 3
2 can affect accessibility, listed first
↕ moved structure > Document > Figure (p1) [accessibility]
    reading position 3 -> 10
~ attribute structure > Document > Table > TR[1] > TH2 (p2) [accessibility]
    scope: Column -> (missing)
~ text structure > Document > Table > TR[2] > TD[2] (p2)
    "Go with without a guide"

Upgrade without breaking your documents

A new version of the library that writes your PDFs can drop a font's Unicode map, retag a heading as a paragraph or strip the tags, while every page looks the same. A snapshot test catches it the first time the upgrade runs, and pdiffy compare checks a whole folder of documents before and after.

Catch generator upgrades

Terminal
$ dotnet pdiffy before.pdf after.pdf
2 change(s): 1 attribute, 1 changed
by section: structure 1, fonts 1
2 can affect accessibility, listed first
~ changed structure > Document > P[1] (p1) [accessibility]
    type: H1 -> P
~ attribute fonts > Helvetica [accessibility]
    to-unicode: yes -> no

Install

Both packages target .NET 10 and are fully managed, so a snapshot made on Windows matches one made on Linux. They work with any test framework.

PDiffy

The library for your test project.

dotnet add package PDiffy

PDiffy.Cli

The pdiffy command-line tool, installed as a local tool at the same version as the PDiffy package.

dotnet new tool-manifest
dotnet tool install PDiffy.Cli --version <version>