Today I needed to convert a PDF file to a series of images. Initially I was a little stumped on how to do this easily on my Mac.
My first port of call was Preview. Preview is one of Mac OS X’s most useful tools, but for this task it let me down.
You can use Preview to save a PDF file to a variety of other image formats just by choosing “Save As…” from the File menu. Preview will then ask you to specify a format and other image options. Unfortunately when you choose to save in the PNG image file format, this saves just the current page you are viewing. What I wanted was each page of the entire PDF to be saved to a separate file.
My next thought was perhaps I could use AppleScript to automate Preview. Unfortunately Preview is one of the few Apple tools that doesn’t support AppleScript very well (if at all).
This lead me to think about Apple’s Automator tool, and I discovered that Automator has an action called “Render PDF Pages as Images”. Hurrah! Problem solved! Well, not quite. I’m not an Automator expert so I had a little trouble figuring out how to use it. In the end I constructed the following workflow.
- Render PDF Pages as Images
- Rename Finder Items (set to Make Sequential mode)
- Move Finder Items
- Reveal Finder Items
When I was creating this workflow I was concerned about there not being any way to specify which folder to save the images into and other options on each workflow step. However I then discovered the “Show this action when the workflow runs” check box in the options section of each action. When this checkbox is enabled the action will pop up a dialog and ask the user to specify certain options. In the case of the Render Pages as Images action you can specify the image format and DPI settings. For the Move Finder Items action you can specify the destination directory.
I saved this workflow as an “Application” and now I have an icon I can drag a PDF onto to create a series of images.