Skip to main content
Question

Applescript: Printing current Safari Tab

  • April 3, 2023
  • 3 replies
  • 12 views

Forum|alt.badge.img+3

Good day all,

I am working on a project currently to automate the creation of a build sheet that will print when the Mac has been enrolled and all software installed. I am able to successfully create the buildsheet as an HTML file and open it in Safari successfully. The issue I have run into is automatically printing the page to the default printer. Does anyone know how to have Safari print the current open tab automatically in Apple Script? I tried finding resources for this online but I could not find much that was helpful in my situation. Any help would be greatly appreciated.

3 replies

jamf-42
Forum|alt.badge.img+17
  • Esteemed Contributor
  • 744 replies
  • April 3, 2023

not exactly what you asked for.. but this may work.. make a PDF of the HTML and push that via:

lpr -P printername filename.pdf

 


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 3 replies
  • April 3, 2023

not exactly what you asked for.. but this may work.. make a PDF of the HTML and push that via:

lpr -P printername filename.pdf

 


Thanks for this idea. I looked into it briefly and found a script online for exporting the tab as PDF. The issue I find is that in PDF form the margins of my table are all wonky. I'll keep this as a last resort, maybe I can adjust my html to display properly.


jamf-42
Forum|alt.badge.img+17
  • Esteemed Contributor
  • 744 replies
  • April 3, 2023

Thanks for this idea. I looked into it briefly and found a script online for exporting the tab as PDF. The issue I find is that in PDF form the margins of my table are all wonky. I'll keep this as a last resort, maybe I can adjust my html to display properly.


suggested PDF so its more formatted, but try sending the raw HTML.. see what comes out..