5 Replies Latest reply on Jul 30, 2012 9:46 AM by Larry G. Schneider

    Converting PDF to PNG


      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