• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
using AppleScript to print an HTML document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: using AppleScript to print an HTML document
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Looking for a Pasteboard Peeker sample code
  • Next by Date: Re: using AppleScript to print an HTML document
  • Previous by thread: Re: Looking for a Pasteboard Peeker sample code
  • Next by thread: Re: using AppleScript to print an HTML document
  • Index(es):
    • Date
    • Thread