Working some PDF magic: CutePDF and pdftk

Over the past several years Benjamin has developed several documents for use with his business, Memento & Co. These documents are designed in Word and originally had the letterhead on them as well. This proved problematic when we moved because in order to update the contact information he had to open and change each and every document. Word doesn’t provide a way to single-source documents and we decided we needed to do this differently.

B had been using CutePDF to create PDFs of his Word documents for a while so I started poking around to see if there was a way to “merge” two PDFs together: we’d create one PDF with the letterhead that he could use to merge on the first page of Word document printed to a PDF. I discovered pdftk would do the trick. Using this technique B was able to design his letterhead in Inkscape and save it as a PDF document. Using Inkscape allowed for a crisp logo (also designed in Inkscape) and no longer required rasterizing the vector logo into a high-resolution image just to place it into a Word document! He could then run a VB script I write which would prompt for the PDF onto which the letterhead should be applied and the script called pdftk to do the actual work.

Now enter the move to Sebastian and Mac OS X. Initially the process seemed much simpler. OpenOffice can export to a PDF out-of-the-box removing the need for CutePDF. Automator can apply a watermark to a PDF but only if the watermark is a raster image, not another PDF. Moreover it doesn’t tell you that anywhere but simply doesn’t do anything to the desired file making it a frustrating task to figure out what was going wrong. Drat, we’d have to go back to pdftk.

Getting pdftk on the system was a bit more challenging as the program doesn’t come in a DMG. Luckily it is included as a port so the process was a simple ‘port install pdftk’. I then used the Automator to provide a Finder menu option that B can use to apply the letterhead to one or more files. The Automator calls a shell script that calls pdftk to do the actual work.

Published by

cpeel

I'm a gay geek techie space nerd living in Seattle, WA.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s