Latest blog post
I recently had to look at two different legal documents (PDFs) that were mostly the same, but I wanted to spot any differences.
My first attempt was to install the cross-platform GUI tool DiffPDF. This mostly worked but was annoying because it seemed to basically only diff within a page – so if your paragraph bumped to another page in the new version of the document, you couldn’t really spot changes.
Then I installed pdftotext with macports: “sudo port install poppler”. From there you can diff the two text files, like normal.
However the format was still not ideal in the standard FileMerge, “diff” or “vimdiff” programs (even with ignoring whitespace) because it would show an entire paragraph changing even if just one word did. And it would also show issues in all the places where text wrapping happened on. different words
So finally I found a couple other useful tools, wdiff (for word-by-word rather than line-by-line comparisons) and colordiff to colorize the output. Installed with: sudo port install wdiff colordiff. And threw in a trick to avoid needing the .txt temp files.
$ wdiff <(pdftotext old.pdf -) <(pdftotext new.pdf -) | colordiff
Beautiful! Now I can easily spot the specific words, nicely colored, that have changed.
Only thing I would improve is for it to print only the lines with changes (plus 3 context lines above/below), rather than all lines.