Recursive AI

PDF redline annotations vs. a reflowed comparison report

One .NET comparison produces both PDF redlines: see what changes when you export it each way.

Use annotations to locate edits on the original pages. Render a report to read insertions and deletions together without opening pop-ups.

OneDiff is a free, open-source .NET library from Recursive AI, licensed under MIT or Apache-2.0. NuGet · GitHub · Getting started

InstallShell
dotnet new console
dotnet add package RecursiveAI.OneDiff.Pdf --version 1.0.1

This program creates two sample PDFs with the included OneRender.Pdf dependency, then exports the same comparison twice.

Program.cs.NET 10
using OneDiff.Documents;
using OneDiff.Documents.Model;
using OneDiff.Pdf;
using OneRender.Pdf;
 
var before = MakePdf(30);
var after = MakePdf(45);
var source = new PdfDocumentSource();
var diff = Comparison.Of(
    source.Read(DocumentInput.FromBytes(before, "old.pdf")),
    source.Read(DocumentInput.FromBytes(after, "new.pdf")));
 
using var marked = File.Create("annotated.pdf");
var markup = PdfRedline.OnPages.MarkNewDocument(diff, after, marked);
using var report = File.Create("report.pdf");
var rendered = PdfRedline.Rendered.Render(diff, report);
Console.WriteLine($"annotated.pdf: incremental save = {markup.SavedIncrementally}");
Console.WriteLine($"report.pdf: {rendered.PageCount} page(s)");
 
static byte[] MakePdf(int days) => HtmlPdf.ToPdf(
    "<style>@page { size: 5in 3in; margin: 0.4in; }</style>" +
    "<h2>Supply terms</h2>" +
    $"<p>Payment is due within {days} days.</p>");
Observed outputConsole
annotated.pdf: incremental save = True
report.pdf: 2 page(s)

The annotated copy kept the revised PDF’s single 5 × 3 inch page. It highlights “45 days,” with “30 days” in the pop-up. The report used two A4 pages: a summary and the comparison body, with “30” struck out and “45” inserted inline. “Reflowed” here means the report is laid out anew, not that its PDF pages adjust to the viewer’s window.

Choose the redline by what the reviewer needs

UseWhat the reader gets
Locate an edit on a cited page
Original-page annotationsText markup at the source position, on the unchanged page layout.
Read removed and added language on paper
Rendered reportBoth versions’ changes drawn on the page, with a key. Page breaks and page numbers come from the report, not the source.
Align old and new paragraphs for review
Rendered side by sideOld text on the left and new on the right in a landscape report. The columns are laid out from the comparison, not screenshots of the PDFs.

Keep the source page geometry with annotations

PdfRedline.OnPages adds real markup annotations, leaving page content alone. It highlights insertions and replacements on the revised pages. A deletion has no text left to strike out there, so OneDiff adds a caret with the removed text in a pop-up. To strike out removed text where it originally appeared, also mark the old PDF with MarkOldDocument. Check what the recipient’s viewer shows or prints before relying on annotation pop-ups as the only record of deletions.

Pass the exact bytes used in the comparison to MarkNewDocument; a re-export of a visually identical page can fail the source-hash check. If you reload a comparison from JSON, the original bytes are not carried along, so provide those bytes yourself or export a report. See the output selection and source-byte rules.

Create a standalone report when page references aren’t needed

PdfRedline.Rendered lays out the comparison as an inline report. PdfRedline.RenderedSideBySide gives the same comparison two columns. Both work from the comparison itself; neither needs the source PDF bytes. Send the marked PDF and the report together when reviewers need both page references and deleted text visible on the page. Name them clearly so a report page number isn’t mistaken for one in the source.

Neither export mode turns a text comparison into a visual comparison. A moved logo, a changed drawing, or a scan with no usable text calls for a different check. If extracted text is missing or out of order, start with why PDF comparisons highlight whole pages before choosing the output.