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:
Mon, 8 Mar 2010 10:31:49 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (41 lines)
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

ATOM RSS1 RSS2