Subject: | |
From: | |
Reply To: | |
Date: | Mon, 8 Mar 2010 10:31:49 +0000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
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
|
|
|