FormatterHQ

PDF

How to Compare Two PDF Files and Find Every Text Change

How to compare two PDF files by their text, why re-flowed lines show up as false changes, what a text diff cannot see, and a review workflow for contracts, policies and theses.

FormatterHQ Team Published 7 min read

You receive a revised contract, policy or thesis chapter as a PDF, and the sender says "only minor edits." Checking that claim by flicking between two windows is slow and unreliable, especially when the layout has shifted. The faster way to compare two PDF files is to extract their text and let a diff do the work. This guide explains how text comparison works, why line breaks cause false alarms and how to avoid them, how to read the output, what a text comparison cannot see, and a review workflow you can repeat with the Compare PDF tool.

Why comparing PDF versions by eye fails

Human proofreading is good at spotting typos and poor at spotting what is missing. A deleted "not" in a liability clause, a notice period changed from 30 to 60 days, or a sentence quietly dropped from a methodology section all read naturally, so your eye slides past them.

PDFs make it harder. A single inserted word can push every following line, and sometimes whole paragraphs, onto a different page. Once page 4 of the old version no longer matches page 4 of the new one, side-by-side reading turns into hunting for where each paragraph went.

Typical cases where this matters:

  • Contracts and leases, where a counterparty sends a "clean" version instead of a redline.
  • Policies and terms, where you need to know exactly what changed between this year's and last year's edition.
  • Theses and papers, where a supervisor or co-author returns an exported PDF rather than the source file.
  • Specifications and tenders, where a changed tolerance, quantity or deadline has real cost.

How text comparison works

A PDF does not store paragraphs. It stores pieces of text placed at positions on each page. A comparison tool first reads those pieces in reading order and rebuilds lines of text for each page, adding line breaks where the layout breaks and spaces where there are gaps between words.

Next comes a line diff, the same technique the diff checker uses for code and plain text. It finds the largest set of lines the two versions share in the same order and reports everything else as removed lines, added lines, or changed lines (a removal paired with an addition at the same spot).

Finally, inside each changed line, a word-level pass highlights only the words that differ. That is the part your eye actually needs: instead of two nearly identical 20-word lines, you see the one word that was swapped.

The re-flow problem: compare two PDF files by sentences, not lines

Line diffs assume a line means something. In a PDF it only means "the text ran out of width here." Add one word near the start of a paragraph and every line break after it moves, so a pure line comparison reports the entire paragraph as changed.

Here is a lease clause where only one word, "business", was added. Compared line by line, as on the page:

- The tenant shall pay rent on the first day of each
- month by bank transfer to the account named in
- Schedule 2.
+ The tenant shall pay rent on the first business day of
+ each month by bank transfer to the account named
+ in Schedule 2.

Three lines removed and three added, for a one-word change. Now the same text compared by sentences:

- The tenant shall pay rent on the first day of each month by bank transfer to the account named in Schedule 2.
+ The tenant shall pay rent on the first business day of each month by bank transfer to the account named in Schedule 2.

One changed sentence, and the word highlight lands on "business" alone. This is what the Compare by: Sentences (ignores line breaks) option in Compare PDF does. It joins the lines of each page, rejoins words that were hyphenated across a line end (such as "agree-" followed by "ment"), and then puts one sentence per line before diffing. Changed column widths, margins, fonts or paper sizes stop producing noise.

Use Lines as on the page when the line structure itself carries meaning: tables, lists of figures, addresses, or code samples in a manual. Sentences are rebuilt within each page, so a sentence that now begins on a different page shows up as a small change at the page boundary. That is expected and easy to recognize.

Reading the output: side by side, unified and context

The Side by side view puts the original on the left and the changed version on the right, with removed text and added text marked on their own sides. It is the easiest view for long sentences and for showing a colleague.

The Unified view shows one column, with removed lines followed by added lines, like the examples above. It is more compact and closer to what you would paste into an email or ticket.

The Show setting controls context. Changes with context shows each change with three unchanged lines around it, so a 60-page document with five edits becomes five short blocks. Whole text shows everything, which helps when changes are dense or when you want to read the new version with the edits marked.

Ignore spacing and ignore case

Ignore spacing (on by default) ignores differences in spacing, which matters because the gaps between words in a PDF are reconstructed from positions and can differ between two exports of the same text. Ignore case is off by default; turn it on when a revision changed headings to title case or small caps and you only care about wording. Leave it off for legal text, where "Tenant" as a defined term and "tenant" can mean different things.

What text comparison cannot see

A text diff compares words. Everything else on the page is invisible to it:

ChangeDetected?How to check it instead
Added, removed or reworded textYesThe diff itself
Numbers in body text and simple tablesYes, as textThe diff, then confirm the table layout in the PDF
Bold, italic, font, color, sizeNoVisual review of the changed pages
Images, charts, logos, signaturesNoRender the pages to images and compare them by eye
Scanned pages without a text layerNoRun OCR first, then compare the recognized text
Document properties (author, dates)NoA PDF metadata viewer

Scanned documents deserve a warning. A page that is a photo of paper has no text to extract, so Compare PDF tells you which file has no text layer instead of reporting a false "identical." The tool does not perform OCR, so you need to run the scans through OCR software before comparing.

Also remember that text order comes from the PDF's structure. Multi-column layouts, sidebars and footnotes are usually extracted in a sensible order, but a moved text box can appear as a removal in one place and an addition in another. When that happens, check the two spots in the PDF before concluding that anything was deleted.

A practical review workflow

  1. Load both versions. Drop the original PDF on the left and the changed one on the right. Both files are read in your browser and are not uploaded, which matters for unsigned contracts and unpublished research.
  2. Start with Sentences, side by side, changes with context. This shows the smallest set of real wording changes.
  3. Use the page markers. With Page markers on, each page's text starts with a line like --- Page 7 ---. Note the page for every change and open that page in your PDF viewer to see it in its real formatting, including anything a text diff misses nearby, such as a changed table cell border or a struck-out figure.
  4. Re-check surprising changes in Lines mode. If a change looks odd, such as text in a table or a list, switch to Lines as on the page to see it the way it is laid out.
  5. Save a record. Use Download .diff to keep a standard unified diff of the comparison next to both PDFs. It is plain text, so you can attach it to an approval email, a ticket or a thesis log, and anyone can open it later.

If a section seems to be missing entirely, extract both versions with PDF to Text and search the plain text for a phrase from it. For long documents, a quick look at the per-page counts in the PDF word counter also shows where text was added or removed before you read a single change.

Summary

To compare two PDF files reliably, compare their text rather than their pages, and compare by sentences so re-flowed lines do not hide the real edits. Read the changes with context, confirm each one on its page in the PDF, check images and formatting separately, run OCR on scans first, and keep the .diff file as your record of what changed between versions.

  • pdf
  • compare pdf
  • diff
  • document review
  • contracts

Frequently asked questions

Can I compare a PDF with a Word document?
Not directly with a PDF comparison tool, which expects two PDFs. Export the Word file to PDF first, or extract the text of both and paste it into a general text diff. Comparing by sentences keeps differences in line breaks between the two exports from showing up as changes.
Why do headers, footers and page numbers show up as changes?
They are ordinary text on each page, so they are extracted and compared along with the body. If the new version has more pages, a footer such as Page 4 of 60 becomes Page 4 of 61 on every page. These lines are easy to recognize and skip, so focus your review on changes in the body text.
Does comparing PDFs detect changes to the signature page?
Only if the change affects text, such as a different name or date typed on the page. A handwritten or image signature is a picture, so a text comparison does not see it. Check signature pages visually, and verify digital signatures in your PDF reader.
Is it safe to compare confidential PDFs online?
It depends on where the files are processed. Compare PDF on FormatterHQ reads both files in your browser and does not upload them. For any other service, check whether files are sent to a server and how long they are kept before using it for contracts or unpublished work.
Can I compare more than two versions at once?
A diff always compares two texts. To track a document through several versions, compare each version with the next one, such as v1 with v2 and v2 with v3, and keep the downloaded .diff file from each step as a change log.

Tools used in this guide