Jens Nöckel provides Keynote/Preview fix

Friday, April 11, 2008

For some time now, Keynote (and indeed all of iWork) under Leopard has been suffering from a problem. Namely, if you attempt to Crop a .PDF in Preview then copy that cropped PDF into Keynote, you would get an image of the ENTIRE page, not just the cropped area. With the upgrade from Tiger’s version of Preview, to Leopard’s version, a very useful and efficient workflow had been halted. Now, to perform the same action required several steps and a separate application. While it was an effective workaround, we’ve still been waiting for a fix.

I had some idea of the PasteBoard interactions that were behind the problem, but I wasn’t aware of the specifics until I read this post by Martin Costabel. My initial suspicions were verified when I read that Preview had introduced some additional dimensions into the cropped image that weren’t there with Tiger’s Preview. Specifically, there’s now an /ArtBox parameter being set in the PDF that gets copied to the System PasteBoard. What I didn’t know (and why it works for other apps) is that while there is a properly dimensioned /CropBox parameter, Keynote is instead using the /ArtBox definitions… and those are set to the size of the entire page. This is why the cropped PDF copied into Keynote appears to have a box that’s the right size, but shows the entire PDF extending to the right and below outside the bounds of the box.

The fix for this is to alter /ArtBox so that it’s either removed OR equals /CropBox, and Jens’ initial script does this, using ghostscript to properly re-create the altered PDF (many advanced Keynote users may already have ghostscript installed by way of a TeX distribution). Once I was aware of the specifics of the fix, I used iClip lite as a kind of PasteBoard peeker in order to see if I could apply the same fix in such a way that it would not require ghostscript to be installed. I discovered that, for the purposes of someone just wanting a properly cropped image in Keynote, massaging the data that gets placed on the PasteBoard was indeed good enough for that purpose. However, lacking the skills of Jens, I contacted him with my findings inquiring if he thought it would be possible as well. Not only did he reply that it was possible, he then prepared and made available a separate script which does NOT require ghostscript!

You can find the ghostscript enabled version, the no ghostscript version AND the instructions for their installation and use on this page.