Skip to main content

Understand a PDF

Compare two PDF files visually

Compare two PDFs locally, review structural findings, and download an HTML gallery containing expected, actual, and highlighted page-difference images.

Practical steps

Compare two PDFs locally

Render both documents under the same bounded policy and inspect exact visual and structural differences.

  1. ChooseSelect the expected PDF first and the actual PDF second.
  2. CompareRender corresponding pages and evaluate structural and pixel-level differences.
  3. ReviewOpen or download the self-contained HTML gallery to compare expected, actual, and highlighted images.

PDF comparison is useful for regression baselines, generated reports, invoices, and publishing pipelines where a successful file write is not enough. The comparison report keeps structural findings beside rendered evidence so a changed page count is not reduced to a pixel score.

Compare from .NET

using OfficeIMO.Pdf;

byte[] expected = File.ReadAllBytes("approved.pdf");
byte[] actual = File.ReadAllBytes("candidate.pdf");

PdfVisualComparisonReport report = PdfVisualComparer.Compare(expected, actual);
File.WriteAllText("comparison.html", report.ToHtmlGallery("Release comparison"));

Console.WriteLine($"Match: {report.IsMatch}");

Application code can configure page selection, channel tolerance, allowed difference ratio, and resource budgets. The browser route deliberately uses exact comparison thresholds and fixed limits so an unexpectedly large document cannot consume unbounded memory.

Read the evidence correctly

A visual match means the compared pages satisfied the selected rendering threshold. It does not prove semantic equality, identical metadata, equivalent signatures, or byte-for-byte identity. Conversely, a visual difference may be a legitimate font, rendering, or pagination change. Review the gallery and structural findings before accepting or rejecting the candidate.