Controlling Safari Printing via A.S.

So basically I want to print a webpage - more critically I ONLY want to print the first page of this (what happens to be a) 2-page document.

So I’ve tried this script as the main working script for printing the page:


set theURL to "http://www.crh.noaa.gov/forecasts/CAZ072.php?%20warncounty=CAC017&city=South+Lake+Tahoe"

tell application "Safari"
	open location theURL
	delay 10
	print window 1
end tell

But I need to get in there: “…with properties {starting page:1, ending page:1}…” and I can’t get the diction down.

Tried it a slightly different way. This doesn’t really effect the printing aspects, just how I access the page. In this latter example I save it as a webarchive file and then try printing that one like this:

set theFile to (path to desktop as Unicode text) & "Print Test.webarchive"

tell application "Safari"
	open theFile
	delay 2
	print theFile with properties {starting page:1, ending page:1}
end tell

I’ve also tried using the above technique of saving the webarchive and then trying to print the item via the Finder by setting up an Automator workflow consisting of:
¢ Get Specified Finder Items
¢ Print Finder Items
This likewise doesn’t work - because I don’t get to specify that I only want to print 1 page.

Any ideas on printing a SINGLE web page??
Thanks in advance! KB

Well I’m on a train and don’t have a real printer to work with, but I do have Acrobat 7 installed which does create a Adobe PDF Printer and I can get it to work through that…

The URL I was printing is http://bbs.applescript.net/viewtopic.php?id=20984 and is 14 pages long when printed without any options. Doing this though gives me only the first page.

tell application "Safari"
	print window 1 with properties {starting page:1, ending page:1, target printer:"Adobe PDF 7.0"}
end tell

So why that works for me and not you is beyond me… perhaps its a issue with printing to a real printer? Not sure.

Thanks for the input. I’ve been able to do much testing lately. But as for now, slight tweaks to your script got it working on my machine. But that’s not the “real” target machine. So I’ll post back when I know more. Thanks again for the input thus far.