Skip navigation
Currently Being Moderated

Converting PDF to PNG

Jul 27, 2012 6:20 AM

Tags: #illustrator_cs5 #applescrit #current_document

I wrote the following AppleScript to open a PDF file and export is as PNG.

I am using Illustrator CS5.


The export command gets an error: Adobe Illustrator got an error: Can't get current document.

when it encounters the export command.

What is causing this and how do I fix it?


set inputFile to (choose file with prompt "Open PDF file to convert to PNG:") as text

set exportFile to inputFile & ".png"

tell application "Adobe Illustrator"

    if not frontmost then activate

    open inputFile as alias without dialogs

    export current document to exportFile as PNG24 ¬

        with options {class:PNG24 export options ¬

        , resolution:300 ¬

        , matte color:{red:0, green:0, blue:0}}

    close current document saving no

end tell

  • Currently Being Moderated
    Jul 28, 2012 4:27 AM   in reply to DVF2

    I tried your script and while the error kick back say's its a file/document issue… It's NOT you have supplied a bad parameter… resolution NO such thing except for PSD… Remove and you will be fine…

    Mark as:
  • Currently Being Moderated
    Jul 28, 2012 7:06 PM   in reply to DVF2

    You will have to scale the PNG larger and then batch reduce in Photoshop to get the resolution you want. AI thinks all PNGs are 72 ppi.

    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 9:46 AM   in reply to DVF2

    Set the transparency to false and the matte color to 255, 255, 255

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points