pdf2png — using Quartz to convert PDF to PNG

I am often taking screenshots on Mac OS X via the shortcuts that Steve describes.

And, like Steve, it bugged me that screenshots were written as PDF with no obvious means of converting them to PNG without going through Preview. At least, none that I’m aware of (which may mean nothing — I have been known to miss the obvious).

It turns out to be rather easy. Panther includes Python bindings for Quartz and Quartz includes all the API necessary to do just about anything desired with PDF, PNG and other bitmap formats.

Here is a tiny python script that takes PDF files as arguments and converts each into one or more PNG images, one page per PNG file (with appropriate numbering scheme).

It works well enough for solving the problem of converting screen shots, but seems to generate rather trashy PNG files if processing anything other than PDF based bitmaps.



One Response to “pdf2png — using Quartz to convert PDF to PNG”

  1. bbum’s weblog-o-mat » Blog Archive » pdfcat — concatenate PDF documents says:

    […] In the end, I decided it would be easier just to write some code to do the concatenation. It was easy. I grabbed the pdf2png hack from a while back and modified it to scan a bunch of PDF documents, looking for maximum dimensions, and then images all pages of all documents into a new document with that maximum dimension. […]

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>