Archive for OS X

How to view a color diff of text from two PDFs

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.

Comments (1)

Mac Software I Use

I just got a sweet new MacBook Pro Retina – way faster than my old MBP. I wanted to do a clean install rather than restoring from a TimeMachine backup, which meant reinstalling software and manually transferring stuff over that I really needed. I kept a list…

Read the rest of this entry »

How to upgrade MacPorts to OS X 10.8 Mountain Lion

This weekend I upgraded OS X from Lion to Mountain Lion. Documenting steps I had to do to get all my development environments working with MacPorts.


  • First installed the latest XCode via the Mac App Store
  • Downloaded/Installed Mountain Lion
  • Launched XCode one to so I could agree to license, etc.
  • MacPorts also requires the XCode Command Line tools which are a separate install. Inside XCode preferences: “Instead, they can be installed optionally using the Components tab of the Downloads preferences panel as shown in” (source)
  • Had to run “sudo xcodebuild -license” after getting “Error: for port libunwind-headers returned: command execution failed”. Run this, scroll down, type agree.
  • sudo port selfupdate
  • sudo port upgrade outdated
  • Everything finished and worked properly except MongoDB. Currently there’s a bug and the easiest/best work around seems to be just manually installing the latest stable OS X version from and manually copying the binaries into /opt/local

Comments (4)