Saving a PDF from Safari via Applescript
Hello. I’m an Applescript neophyte and have run into a problem I cannot seem to solve and no amount of Google searches has found an answer for me. It seems a simple thing to do, but I cannot get Safari (5.1, Lion) to save a PDF that is loaded as the result of a script. The relevant portion of the script is this
tell application "Safari"
savedocument 2 infilepdfDLNAME
end tell
In this example pdfDLNAME is a fully specified path, something like this:
Sarkany:Users:fenevad:Dropbox:Personal:Heenan_book:downloads:1776-07-18_New-York -Journal_page-3_4.pdf
Every time I try this it fails, regardless of whether the file exists or not. I get this error (allowing for changes in the variable value) in Safari:
The document “New-York, July 18” could not be saved as “1776-07-18_New-York-Journal_page-3_4.pdf”. The file doesn’t exist.
This result then causes problems for the AppleScript, which cannot procede as it should.
So the question I have is how simply to save a PDF loaded in Safari to a specified path location. I've seen some people suggest scripting the UI, but that is a pain when I have to determine the location for the download based on the script’s results.
Apologies if the answer is obvious to scripters, but it isn't obvious to me or to someone with more experience helping me.
Best regards,
Arle Lommel