0
votes

I'm trying to create a script to use as a droplet where I drop a file onto it, automator opens it in Adobe Acrobat, then applescript runs an action inside of Acrobat to save it as an optimized PDF into a specific folder, then opens that new file in preview and uses a quartz filter to reduce the size of the PDF.

If I have a file already open in Acrobat and just run the script, it executes the action within Acrobat, saves the file, then opens preview (haven't gotten any further). But if I drop the file onto the droplet it just gives me an error message.

Here's the code:

on run {input, parameters}
    tell application "System Events"
        tell application process "Acrobat"
            tell application "Adobe Acrobat Pro" to activate
            -- runs the custom action in Acrobat
            click the menu item "SAVE in 0-SEND" of menu 1 of menu item "Action Wizard" of the menu "File" of menu bar 1
        end tell
    end tell

    tell application "System Events"
        keystroke return
        -- clears the action finished message
    end tell

    tell application "Adobe Acrobat Pro"
        activate
        close documents saving no
        quit
    end tell

    -- this doesn't work yet
    tell application "Finder"
        tell application "Preview"
            open input
        end tell
    end tell
end run
1
Droplets must implement the on open handler. The direct parameter passes a list of alias specifiers representing the dropped items.vadian
Template for properly handling a Droplet: macosxautomation.com/applescript/sbrt/sbrt-10.htmljweaks

1 Answers

0
votes

I would recommend something along these lines...

on run
    set aFile to choose file with prompt "Please select the file to process"
    processPDF(aFile)

    -- cleanup, quit the application
    tell application "Adobe Acrobat Pro" to quit
end run


on open (theFiles)
    repeat with aFile in theFiles
        processPDF(aFile)
    end repeat

    -- cleanup, quit the application
    tell application "Adobe Acrobat Pro" to quit
end open


on processPDF(theFile)

    -- open your file
    -- do something with theFile here.
    -- close the file

end processPDF