Solved

AppleScript Save Page As with Safari

Posted on 2008-10-16
3
3,575 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Syslogd is a utility that traps and logs messages sent by running processes. It is configured with the syslog.conf file, which consists of lines containing a pair of fields: "the selector field which specifies the types of messages and priorities to…
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
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 …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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