Applescript: Easily convert PDF documents to JPG or PNG

Applescript: Easily convert PDF documents to JPG or PNG

There are, of course, a million ways to convert PDF documents to JPG or PNG files. However, sometimes you just want something quick and easy.

A while ago, reader AS pointed me out an Applescript droplet written by Martin Michel over at MacScripter.

AS mentioned that it would be nice to have a version that converts to PNG as well. Being nothing if not nice, I used my almost non-existant Applescript/Python skills to convert Martin’s script to output PNG. All credit for this goes to Martin.. I just did some modifications.

Here’s how to do it:

PDF To JPG

PDF to PNG

  • Download PDF2PNG from here
  • Drag a PDF or multiple PDFs onto the icon
  • Select the resolution (or accept the default)
  • A PNG file will be created for each page in the PDF

Hope this helps some of you. I know they will come in handy for me. Thanks AS and thanks Martin Michel! Let me know how it works out for you.

About the Author

Brooks Duncan helps individuals and small businesses go paperless. He's been an accountant, a software developer, a manager in a very large corporation, and has run DocumentSnap since 2008. You can find Brooks on Twitter at @documentsnap or @brooksduncan. Thanks for stopping by.

Leave a Reply 35 comments

Maro - April 17, 2014 Reply

can it be modified to convert PDFs to .eps?

John - September 5, 2012 Reply

Never mind about the image size. I had the canvas size set to 8.5 x 11.

John - September 5, 2012 Reply

Is there a way to retain the size of the pdf. It seems to make everything 8 1/2" x 11"
And .tiff can it be made to be .tif

this may be asking a lot. : (

John - September 5, 2012 Reply

thank you.

John - September 5, 2012 Reply

Sorry for the late return. I be out of the office. If you could have it name with the same name that is given.
With a .png or .tif eg: 12345.pdf 12345.png or 12345.tif

Otherwise is seems solid.
Thanks, J.

    Brooks Duncan - September 5, 2012 Reply

    I was afraid you'd say that! Just kidding, I'll see what I can do.

John - August 30, 2012 Reply

I think that the Automator you used to build using Lion or Mountain Lion is conflicting with Snow Leopard old version not recognizing correctly. Just a thought.

    Brooks Duncan - August 30, 2012 Reply

    Yep I am almost sure that is what the issue is. I will try to re-build it on my Snow Leopard machine. It's always something!

    Brooks Duncan - August 30, 2012 Reply

    OK, can you please try this one and see if it works better on SL? For now, it will kick out a filename output-1, output-2, blah blah. Let me know if that is not acceptable. http://cl.ly/16391Z380y0R

John - August 30, 2012 Reply

Downloaded app again. No error messages , however the file name after processing is ex: 356cdf2.pdf is named 000cdf2.png
?

    Brooks Duncan - August 30, 2012 Reply

    Hmm, let me try it on my Snow Leopard machine in a bit.

John - August 30, 2012 Reply

I did try on A Mac with 10.7 and is fine.

John - August 30, 2012 Reply

10.6.8 – not lion

John - August 30, 2012 Reply

Hello-

When I used the app you sent yesterday, it worked perfect. Today , for some unknown reason,
the file name is incorrect and it errors with the following:
Here what the errors say: The workflow was saved with a newer version of the action "Get Selected Finder Items." Some behavior may have changed.
The workflow was saved with a newer version of the action Render PDF pages as Images Some behavior may have changed.

I have not updated anything on my computer???

    Brooks Duncan - August 30, 2012 Reply

    Hmm weird. What version of Mac OS are you running? Can you try re-downloading and see if it happens again?

John - August 29, 2012 Reply

This is a really nice app. Let me give it the road test. Thanks so much. I will be in touch.

I have been working as well and came up with features in Adobe CS 6 to automate Acrobat Reader now.
And Photoshop has droplets.

John - August 27, 2012 Reply

Thank you. so much.
I really like this app.

    Brooks Duncan - August 28, 2012 Reply

    Hi John, testing out a different way of doing things. Can you download this and give it a try? http://cl.ly/3O3R1E1V0b0Y

John - August 27, 2012 Reply

Is there anyone out there who can correct the dpi so that it can do other resolutions besides 72dpi.
Flatten the image and not add a -0 to the saved file name and make a working app to send me?

Thanks.
I will contact you upon your commenting here.

    Brooks Duncan - August 27, 2012 Reply

    Hey John, sorry for the delay. I started on this last night, but it was a bit more complex than I had thought. I'll try to get something done this week.

John - August 26, 2012 Reply

Thank you. I changed the source code, but now the script does not run at all. Sorry I'm
not versed in Applescript. If you would make it save as 150 dpi and make it available for me to download, I can send you compensation for your efforts.
Much appreciated.
John

john - August 26, 2012 Reply

How can I change the resolution so that is saves as 150 dpi?
It always reverts to 72 dpi.

Thanks.

    Brooks Duncan - August 26, 2012 Reply

    Hi John, you'll need to change the source code. You can download it from here: http://cl.ly/1W1I0J0d3B3Q. Open that file in AppleScript editor and near the top you will see that batchresolution is hardcoded. Change the number and go from there.

      John - August 27, 2012 Reply

      Thank you. I changed the source code, but now the script does not run at all. Sorry I'm
      not versed in Applescript. If you would make it save as 150 dpi and make it available for me to download, I can send you compensation for your efforts.
      Much appreciated.
      John

MD - September 17, 2010 Reply

I like the way your script processes multiple pages. Would it be possible for you to share the code so that I could convert it in to a bash script where parameters could be passed to convert files and used as an automation too for many who need it.

    MacD - September 17, 2010 Reply

    Ignore my previous post. I do see that you have the code in there. One thing. Even when passing a resolution in the case of PDF2PNG it converts to 72 dpi. The .py file has a hardcode value. You may want to change that.

      Brooks Duncan - September 17, 2010 Reply

      Thanks MacD, I'll check it out!

Phil - May 20, 2010 Reply

Hi BrooksD,

Just wondering if you have any idea how to easily change the droplet into a folder action.
Obviously the dpi would have to be manually set within the script but I can't figure out how to turn the droplet into a folder action, any ideas?

Thanks in advance,

Phil

    Brooks Duncan - May 20, 2010 Reply

    Hi Phil, I think that should be doable. Let me play and get back to you.

    Brooks Duncan - May 21, 2010 Reply

    Hi Phil, OK give this a try:http://www.documentsnap.com/files/pdf2png-action….

    Since you're asking for a folder action I'm guessing you know what to do with it, but let me know if you're not sure. This should give you something to go on if you want to convert the macscripter one too.

Sofia - May 10, 2010 Reply

It asks me to select a resolution, but no matter what I choose (e.g. 150 dpi) it converts to 72 dpi.

    Brooks Duncan - May 10, 2010 Reply

    Hi Sofia, which one? PDF -> JPG or PDF -> PNG?

Nick - May 6, 2010 Reply

Thanks, you just saved an hour of my time!

    Brooks Duncan - May 6, 2010 Reply

    No worries Nick glad it helped!

Leave a Reply: