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:
Laine Lee <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Tue, 9 Mar 2010 11:47:06 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
On 3/8/10 4:31 AM, "John Delacour" <[log in to unmask]> wrote:

> At the moment I'm frequently converting SVG vector files to vector
> pdf files.  I can do it using svg2pdf, which requires Cairo etc and
> is very fussy and rather deficient.
> 
> This thread has got me thinking of another way to do it and the
> result is below.  It requires no administrator privileges.  The Perl
> script reads cups/ and gets the last file spooled (at least here it
> does).  It then  opens a copy of the file created, complete with name
> suffix, in user's TemporaryItems.
> 
> The AppleScript script is saved as an application and put in the
> dock.  I print from Safari (sadly the only browser that creates a
> vector pdf file) and then click on openprintfile.app in the dock.
> 
> 
> 
> -- ~/scripts/openprintfile.app (in dock):
> 
> do shell script "cd; cd scripts; perl openpprintfile.pl"
> 
> ---
> 
> # ~/scripts/openprintfile.pl
> 
> #!/usr/bin/perl
> use strict;
> my ($dir, @list, $printfile);
> $dir = "/var/spool/cups";
> opendir DIR, $dir or die $!;
> while ($_=readdir DIR) {/^d/ or next; push @list, $_ }
> $printfile = pop @list;
> my $pdf = "$ENV{HOME}/Library/Caches/TemporaryItems/$printfile.pdf";
> $printfile = "$dir/$printfile";
> open F, $printfile or die $!;
> open PDF, ">$pdf" or die $!;
> while (<F>){print PDF}
> close F; close PDF;
> `open -a preview '$pdf'`;
> 
> JD

That probably won't work on a system running something later than Tiger,
maybe because you need to pass the dynamic temporary item location to perl,
which should be possible, although I'm not good enough to know how to plug
that into your method offhand. When I print to my virtual printer in Snow
Leopard, I delete the queue file with admin privileges because I can't find
any other way to get rid of it. There doesn't seem to be a print to file
option (as specified in the virtual printer instructions you linked at
http://www.caddpower.com/cms/osxmakevirtualprinterpscript.htm) for the
virtual printer in Snow Leopard's print dialog , all of that is handled by
printing plug-ins, I guess. I'm also guessing this is related to changes in
Snow Leopard that killed applications such as CocoaBooklet. Thanks.

Laine Lee

ATOM RSS1 RSS2