MACSCRPT Archives

March 2010

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
John Delacour <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Tue, 2 Mar 2010 23:51:30 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (43 lines)
At 10:42 -0600 2/3/10, Steve Alex wrote:

>...probably the first script I've written in years - even using ui 
>scripting which came out about the time I stopped using AppleScript.

Wasn't that about the time all the people who could write an AETE for 
an application suddenly disappeared into thin air?

>click menu item "PrintÉ" of menu "File" of menu bar item "File" of menu bar 1

That's one thing you can actually do without UI scripting:

    tell app "Safari" to print window 1 with print dialog

But you can also set up a virtual printer...

<http://www.caddpower.com/cms/osxmakevirtualprinterpscript.htm>

and tell Safari to

      print window 1 with properties {target printer:"my virtual printer"}

The print files are spooled to /var/spool/cups/, which requires root access.

Then convert the resulting PostScript file to pdf using ps2pdf

   (do shell script "man ps2pdf")

for which you need ghostscript, which is not a troublesome installation.

Otherwise Preview will automatically convert ps to pdf on opening.


There are other ways of doing it, of course, without involving any 
browser but the installations required (eg. ImageMagick and probably 
a dozen or so prerequisites) are far beyond the powers of this humble 
Mac user.

svg2pdf is much more fun.


JD

ATOM RSS1 RSS2