Compare PDF Files
Operator: Abdulla Al Fahad. How tools are built and checked
When a counterparty sends back "the same contract with a couple of small fixes", the useful question is which words moved. This tool answers it for the text of two PDFs: it reads the words stored on every page of the original and of the revision, lines them up, and marks each removed word in red with a strike-through and each added word in green with an underline, next to the page it sits on.
It compares text only. A swapped logo, a recoloured table or a changed signature image will not show up, and a scanned document with no text layer is refused with a message rather than reported as identical. Within those limits it is a quick way to check a revision before you sign it, forward it or file it.
Key features
- Reads the text of every page of two PDFs in the browser with pdf.js.
- Line-level comparison followed by word-level marking inside changed lines.
- Counts of added words, removed words, changed, added, removed and unchanged lines.
- A per-page list of where the changes are, for both documents.
- Unchanged stretches folded to keep long contracts readable, with a switch to show everything.
- A downloadable, self-contained HTML report with page numbers beside every line.
- A clear refusal for scanned PDFs, plus a warning naming any individual pages that have no text.
A PDF does not store paragraphs. It stores positioned runs of glyphs, and the reader (here the pdf.js library that runs in the page) reports which runs end a visual line. The tool rebuilds each page as a list of lines, collapses runs of spaces into one, drops blank lines, and then joins all pages into one long document while remembering which page each line came from.
The two documents are compared in two passes by the same engine as the site's Text Compare tool. The first pass finds the shortest set of whole-line insertions and deletions (Myers' algorithm). Removed and added lines that sit next to each other and share most of their characters are then paired, and each pair is compared word by word, so a line where one word changed is shown once with that one word marked instead of as a deleted line plus a new line.
Each PDF may be up to 50 MB and 300 pages. Password-protected files must be unlocked first; files that only restrict printing or copying open normally.
How it works
The original is read before the revision, one page at a time, with a progress counter for each side. A document with more than 300 pages is refused before any of its text is read, and each document is closed as soon as its lines are in memory, so only the extracted text is kept for the comparison.
The extracted lines are compared as described above. Every row of the result keeps the page number of its line on each side, which is how the on-screen table, the per-page counts and the report can all point at pages rather than at line numbers in an invisible joined document.
Common use cases
- Checking a returned lease or supplier agreement against the version you sent before anyone signs it.
- Confirming that a re-issued policy document changed only the clauses the cover email lists.
- Reviewing an updated price schedule or terms sheet where one digit in a long table could matter.
- Seeing what an editor touched between two exported drafts of a report when the tracked-changes file was not shared.
- Making sure a regenerated invoice or statement PDF says the same thing as the one it replaces.
How to use this tool
- Drop the original PDF on the left panel and the revised PDF on the right panel.
- Optionally tick Ignore letter case.
- Press Compare PDFs and wait for both page counters to finish.
- Read the counts and the list of changed pages, then scan the highlighted table.
- Press Download HTML report if you need a copy to share or archive.
Example
Two 2-page PDFs; page 2 of the original says "Notice period is thirty days.", the revision says "Notice period is sixty days."
Original, page 1: The tenant pays rent monthly. / Deposit is two months.
Original, page 2: Notice period is thirty days.
Revision, page 1: identical
Revision, page 2: Notice period is sixty days.Result
Added words 1, removed words 1, changed lines 1, unchanged lines 2.
Changes on p. 2 (1) in both files.
Page 2 row: Notice period is [thirty] days. | Notice period is [sixty] days.
("thirty" struck through in red on the left, "sixty" underlined in green on the right)Tips for best results
- Put the older file on the left (Original PDF) and the newer one on the right; removed means present only in the original.
- Leave unchanged lines folded on first look: only changes and the two lines around each are shown, with a count of the hidden lines between them.
- Use the page list under the counts to jump straight to the pages that changed, then tick Show unchanged lines if you need the surrounding clause.
- Tick Ignore letter case when one version was retyped with different capitalisation of headings and you only care about wording.
- Download the HTML report to attach to an email or a file note; it opens in any browser and its number columns are page numbers.
Common pitfalls
Re-wrapped paragraphs inflate the line counts. If a word is inserted early in a paragraph, the following lines of that paragraph each start one word later, so several lines appear as changed even though only one word was added. The word counts stay accurate in that case; read them rather than the changed-line count.
Running headers and footers are text too. If the revision gained a page, every footer reading Page 7 of 12 becomes Page 7 of 13 and each one is reported as a change.
Values typed into form fields are not part of the page text that pdf.js reads, so two forms that differ only in their filled answers compare as equal. Flatten both forms first so the answers become page text.
Common errors and how to fix them
- The message says a file has no text to compare.
- The PDF is an image of pages, usually a scan or a phone photo. Run it through OCR software to add a text layer, then compare again.
- A warning names a few pages with no text.
- Those pages are probably scanned inserts or full-page images inside an otherwise digital document. Changes on them cannot be seen; check those pages by eye.
- The file is refused as password-protected.
- Open it with Unlock PDF using the password you were given, then compare the unlocked copy.
- A file is refused for having more than 300 pages.
- Split both versions at the same chapter or section boundary and compare the matching parts.
- Words appear jumbled or run together in the result.
- Multi-column layouts and text drawn as separate letters can be extracted in an unusual order. The comparison is only as good as the extracted text; for such files, compare a section at a time and confirm suspicious changes against the page.
Best practices
- Compare the exact files that will be signed or sent, not earlier exports of them.
- Treat a result of no differences as covering wording only; glance at tables, images and signatures separately.
- When a long document shows dozens of changed lines but only a few changed words, suspect re-wrapping and focus on the word marks.
- Keep the downloaded report with the signed copy as a record of what you checked.
Why the counts use pages, not line numbers
Line numbers in an extracted PDF are not something a reader can find: the PDF has no visible line numbering, and the extraction drops blank lines. Page numbers are what people quote in an email, so the table, the per-page summary and the report all label each row with its page in each file. When text moves across a page break between versions, the same sentence can show page 4 on the left and page 5 on the right; that is expected and is not itself counted as a change.
What the report file contains
The HTML report is a single file with its own styles and no scripts or external links. It lists both file names, the comparison option, the time it was made and the six counts, followed by every row of the comparison, including unchanged lines. All text from the PDFs and both file names are escaped before being written, so a document containing markup cannot inject anything into the report.
Frequently asked questions
Does it compare images, fonts or layout?
No. Only the stored text is compared. A bolded word, a moved paragraph that keeps its words in the same order, or a replaced image will not be reported.
Can I compare a Word file with a PDF?
Not directly. Export the Word file to PDF first, or copy both texts into Text Compare. Expect some line-break differences, since each program wraps text differently.
Where does the comparison happen?
In this browser tab. pdf.js extracts the text of both PDFs inside the page, the diff runs on that text in the same tab, and the HTML report is assembled as a Blob in memory and saved through a temporary download link that is revoked a second later, so neither the PDFs nor their text are sent anywhere.
Why does a one-word edit show several changed lines?
The added or removed word pushed the rest of the paragraph along, so later lines start and end differently. The added and removed word counts show the true size of the edit.