[cups.general] Better way to add a filter to a printer ?
Tom Schutzer-Weissmann
trmsw at yahoo.co.uk
Thu Nov 4 08:11:06 PST 2004
I'm trying to add a filter to a printer so that it becomes a
pseudo-printer visible to Windows clients, but I'm not sure my approach
is a very good one - can anyone comment or suggest a better way?
All it needs to do is pipe the first page to one printer, and the rest
to a different printer.
I replaced foomatic-rip in the PPD file with foo-foomatic-rip:
*cupsFilter: "application/vnd.cups-postscript 0 foo-foomatic-rip"
and created a perl script called foo-foomatic-rip:
#!/usr/bin/perl
# pipe input to a temporary file
my $tmpfile = $ENV{'TMPDIR'} . '/' . time ;
open( TMP , ">$tmpfile") || die "$!" ;
print TMP <STDIN> ;
close TMP ;
print STDERR "$tmpfile" ;
$firstpage = $tmpfile . 'f' ;
$rest = $tmpfile . 'r' ;
`psselect -p1 $tmpfile $firstpage && cupsdoprint -P Headed
$firstpage` ;
`psselect -p2- $tmpfile $rest && cupsdoprint -P Unheaded $rest`
;
unlink $tmpfile ;
unlink $firstpage ;
unlink $rest ;
Of course, if the damn printer honoured commands to change input tray,
none of this would be necessary :)
Thanks for your help,
Tom SW
More information about the cups
mailing list