I often save web pages for future use, and am looking to try and streamline this process.
Say I have safari and finder open. Finder contains my current project. I browse the web researching and find something of interest, I then drag the web pages address from safari to finder - this will create a .webloc link.
This is not ideal for a couple of reasons ;
.webloc file does not work with windows clients
If website is removed or changed for whatever reason, my link essentially becomes invalid
What I ideally want to do is capture the website as a PDF. I am aware I can choose the appropriate menu options to export as PDF, or print / save as PDF etc... but it interrupts my workflow by having more steps involved, and also having to specify the folder to export to every time.
I was thinking an Automator / Apple Script may be able to help, something along the following pseudo code:
If finder has item dropped on it
If the item is a URL or .Webloc
Use Safari’s built in functionality to generate a PDF from the URL in the folder the item was dropped on
end if
end if
However, I do find I struggle with AppleScript, so would anyone be able to tell me if this would even be possible before I dived in?
Thanks in advance.
The best way to do what you want it so mix an Automator service with an AppleScript.
Automator service will contain only 1 action "run applescript", and it is set to receive text as a selection from Safari. AppleScript action is the following:
This script runs simulate the use of Safari menu export as PDF. If you're using different version of Safari, the menu item may be different than mine. please adjust.
I assume that the PDF file should be based on URL value (+ PDF at the end !). To do so, I also add a subroutine to clean up the URL to convert it a something OK as a file name. I replace all special characters like / : , with char _.
Variable myPath contains the path to your default saving location: you must change 'your_user' with your user name and make sure the folder TEST_URL exists on your desktop. The script contains many comment to help you to adjust to your specific needs.