[cups.bugs] Re: [LOW] STR #1339: printer hangs after printing files processed with psutils

Peter Englmaier Peter.Englmaier at unibas.ch
Thu Nov 3 01:37:52 PST 2005


I think I found a solution to the problem:

after processing the file with psbook, psnup, pstops, or combinations
of them, one edits the file and moves the section
%%BeginProcSet: PStoPS 1 15
....
%%EndProcSet

down right after the line "%%BeginSetup".

I will try to contact the author of psutils. 
However, as a workaround, I wrote a simple filter program in perl.
I chained it together with the cups filter pstops. Seems to work for
me.

Best, Peter.


File "/usr/lib/cups/filter/badpostscript":
#!/usr/bin/perl -w
# simple perl script to fix buggy postscript produced by psutils
# (c) GNU GPL, Peter Englmaier, 2005.

$mode=0;
$found=0;
my @saved;
while (<STDIN>) {
   if ($mode == 0) {
     if ($_ =~ "%%BeginProcSet: PStoPS.*") {
	$mode=1;
	$found=1;
        @saved = (@saved, $_);
     } else {
	print "$_";
     }
   } elsif ($mode == 1) {
     @saved = (@saved, $_);
     if ($_ =~ "%%EndProcSet.*") {
	$mode=2;
     }
   } else {
     print "$_";
     if ($found && $_ =~ "%%BeginSetup.*") {
       for (@saved) {
	  print "$_";
      }
       $found=0; # do not repeat
     }
   }
}
exit 0

Wrapper script "/usr/lib/cups/badpstops"
#!/bin/sh
FILTERDIR=/usr/lib/cups/filter

# See if we have a filename on the command-line...
if test -z "$6"; then
   ifile="-"
else
	ifile="$6"
fi

cat $ifile | $FILTERDIR/badpostscript | 
$FILTERDIR/pstops "$1" "$2" "$3" "$4" "$5"





More information about the cups mailing list