Printing to PDF from within an Applescript

I confess to being a rank newbie when it comes to Applescript, so please bear with me if this question seems a bit simple for the more experienced members here.

I’m trying to write a script that, given a URL, will save a web page to a PDF file. The browser is unimportant (ie Safari, IE, Netscape, etc would be fine).

I’ve been unable to learn how to do this. Can anyone help? It seems so simple, almost like I’m missing something.

Thanks.!

Hi Mike, could you post what code you have, if any, so far. That might help us to see what may be going wrong. Thanks…

This is the complete script (told you it was simple):

tell application “Safari”
set newurl to “http://www.cnn.com
open location newurl
end tell

After the open statement I don’t know what I need to use to get Safari (or any other browser) to print the page to a PDF. My ultimate aim is to be able to batch convert a collection of web pages into PDF, which is why I need to automate this.

Thanks for responding. I hope you might have the answer I need because I’m very confused with the Applescript - the documentation doesn’t appear that good and not everything is, as I’m learning, scriptable.

1- set up a PDF-only printer in Print center
2 - then:
tell application “Print Center” to set current printer to printer “PDF Printer”
3 - then tell safari to print
unfortunately, Safari does not understand the “print” command …

But here’s a fix using GUI Scripting:

http://forums.osxfaq.com/viewtopic.php?t=5227

Now I might sound very stupid, but how to do that? When I want to add a printer, it asks me to show it… Any pointer to a manual? Thanks in advance.

I would very much like to do this too. If any one has any answers or if you have worked it out, please let me know.

Cheers,

Evan

from:
http://docs.info.apple.com/article.html?artnum=34886

Good Luck.
SA
:smiley: