using AppleScript to print an HTML document
using AppleScript to print an HTML document
- Subject: using AppleScript to print an HTML document
- From: Alan Snyder <email@hidden>
- Date: Sun, 24 Sep 2017 13:22:29 -0700
I’m trying to use AppleScript to get Safari to print an HTML document (showing
the print dialog) and am having no luck with the direct approach.
This script times out without opening a print dialog or printing the document:
tell application "Safari"
print POSIX file "/Users/alan/a5.val/index.html" with print dialog
end tell
These scripts open the document, but do not open a print dialog and do not
print the document. The first one times out.
tell application "Safari"
open POSIX file "/Users/alan/a5.val/index.html"
print document 1 with print dialog
end tell
tell application "Finder"
print POSIX file "/Users/alan/a5.val/index.html"
end tell
This workaround is the closest I have come, although I don’t really want to
display the document in Safari:
tell application "Safari"
open POSIX file "/Users/alan/a5.val/index.html"
end tell
tell application "System Events"
set frontmost of process "Safari" to true
tell process "Safari"
keystroke "p" using command down
end tell
end tell
Also, there is a long delay before the print dialog is displayed.
Any suggestions?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden