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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to