BHOZ4 TOOLS

Compare two PDF versions for text changes

You fixed some typos for a reprint or an ebook edition. Now you need to know that nothing else changed by accident. Here is how to check.

Why it is hard

A PDF stores text placed on pages, not one running document. Two things get in the way of a clean comparison.

Fix 1, free: compare the pages as pictures

diff-pdf is "a tool for visually comparing two PDFs", released under the GPL.

  1. Download it from its page.
  2. Run diff-pdf --view old.pdf new.pdf. Its page says this "opens a window that lets you view the files' pages, identify their differences and zoom in on the details".
  3. Or run diff-pdf --output-diff=diff.pdf old.pdf new.pdf to get a PDF that highlights the differences.

This works well when the pages line up. Once text reflows, every page after the change is marked as different.

Fix 2, free: extract the text and compare it

pdftotext, from the poppler-utils package, "converts Portable Document Format (PDF) files to plain text" (manual page).

  1. Run pdftotext old.pdf old.txt and pdftotext new.pdf new.txt.
  2. Add -nopgbrk if you do not want page breaks in the output. The manual says this option stops it inserting "page breaks (form feed characters) between pages".
  3. Open both text files in a text comparison tool. On Windows, WinMerge is "an Open Source differencing and merging tool for Windows".

This ignores reflow, so it finds real wording changes. The cost is that you lose the page numbers, and line breaks and hyphens can show up as changes.

Fix 3, paid: compare text and keep page numbers

I make Edition Compare ($12). It compares the extracted text of a reference and a revised edition across pagination changes. You review replacements, additions and removals with their PDF page numbers. It also checks page counts and page sizes, and it exports a CSV report. You unzip it and open index.html in desktop Chrome. The download includes a worked sample and a quick-start guide.

It needs PDFs with text layers, so scanned pages will not work. Headers, footers, hyphenation and changes in reading order can affect the text it extracts. It compares text, page counts and page sizes, not images or the look of the page. There is no free demo.

Which one to use