Solved

AppleScript Save Page As with Safari

Posted on 2008-10-16
3
3,466 Views
Last Modified: 2013-11-12
Goal:  Save pdf to local directory with scripting on OS 10.5.

Scenario:
When I visit:
http://www.domainname.com/directory/generatereportpdf.aspx?VIUEoYx7fvmJJgtoX2bOw2+bHMUSd9JTe39xjuWnj+lCqxiwPX6JWbEYIq%2fIKvi1etUQkfRAaMBKmokWcUfYRWYxL93jpHV%2fd+YgP+%2f20Br6RFQmqJ5Bb1

It generates a PDF report for me on which I can right click in Safari and save it to my Desktop.  I used to have a process in FileMaker Pro using SuperContainer where I would pass the URL to supercontainer and it would upload it to your servers for document storage.  The provider of the pdf changed their site and now encrypt it as seen above and this process no longer works. The solution to my problem as I see it to have applescript save page as in Safari and save the PDF to a local directory and then have supercontainer retrieve the file from that location.

Current sticking point:
I have not found an applescript example of how to do this.
Thank you for your help
0
Comment
Question by:ppeiris
3 Comments
 
LVL 39

Expert Comment

by:Eoin OSullivan
ID: 22738216
Why don't you use the Print to PDF option inside the print dialog in OSX?

You have some access to scripting this with Automator

See this article on how to create a PDF printer .. which you can send the current web page to.
http://www.macgeekery.com/gspot/2005-12/how_to_mass-print_to_pdf

This article contains an applescript that automates the process
http://www.ehmac.ca/mac-ipod-help-troubleshooting/48924-applescript-code-request-print-pdf-function-2.html


0
 
LVL 28

Expert Comment

by:lesouef
ID: 22738298
depends what you want to save, but if a screen capture is enough, using the web viewer, you can display this page in a filemaker layout and save it as pdf using the pdf export from fm. You would be left with the former solution (supercontainer) to upload it.
0
 
LVL 1

Accepted Solution

by:
ppeiris earned 0 total points
ID: 22766899
Thanks for the help.  Here is the solution I came up with.
-- Remove the current copy of the file example.pdf  The try prevents the error when the file does not exist.
try
	do shell script "rm ~/Desktop/example.pdf"
end try
 
activate application "Safari"
 
-- Get the current URL and set it into a variable.
tell application "Safari"
	set urlpdf to URL of document 1
end tell
 
-- The next is UI scripting that goes to the Safari menu and performs a Save As with and then clicks the save button.
tell application "System Events"
	tell process "Safari"
		click menu item "Save As&" of menu 1 of menu bar item "File" of menu bar 1
		click button "Save" of sheet 1 of window urlpdf
	end tell
end tell

Open in new window

0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
The error "There was an error performing the update" occurred on a Mac OS X client workstation running  Symantec AntiVirus for Mac (http://www.symantec.com/business/products/purchasing.jsp?pcid=pcat_security&pvid=825_1) - the Enterprise product vers…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question