Bug 56503

Summary: psnup produces incorrect output
Product: [Fedora] Fedora Reporter: Kevin Range <range006>
Component: psutilsAssignee: Martin Bacovsky <mbacovsk>
Status: CLOSED NOTABUG QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: rawhideCC: alexcher, gleblanc, mattdm, peter.englmaier
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-12-13 18:17:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
gnumeric print output
none
psnup -2 -pletter -d foo.ps output
none
mpage -2 foo.ps output none

Description Kevin Range 2001-11-20 03:13:53 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010808

Description of problem:
While normally quite superior to mpage, I have found a postscript file
which psnup fails to properly process.  Instead of taking my two page ps
file and making it into  one "2 per page" ps file, I get a one page ps file
that looks half right, but produces two pages when printed, one of garbage
and one half right.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. run psnup -pletter -2 -d foo.ps > foo2.ps
2. gv foo2.ps and see it looks okay
3. lpr -h foo2.ps and get two pages.
	

Actual Results:  Two pages, one half right and one of garbage

Expected Results:  one page, "2 per paged"

Additional info:

The postscript file was made by gnumeric 0.61.  maybe it is abug there?

Comment 1 Kevin Range 2001-11-20 03:16:22 UTC
Created attachment 37988 [details]
gnumeric print output

Comment 2 Kevin Range 2001-11-20 03:17:47 UTC
Created attachment 37989 [details]
psnup -2 -pletter -d foo.ps output

Comment 3 Kevin Range 2001-11-20 03:18:51 UTC
Created attachment 37990 [details]
mpage -2 foo.ps output

Comment 4 Alex Cherepanov 2005-03-07 01:08:11 UTC
I confirm that foo2.ps is broken. I can look into this problem
closer if Red Hat agrees to support the project.


Comment 5 Kevin Range 2005-03-07 02:27:59 UTC
Reconfirmed that this is still broken on FC3 with psutils-1.17-19.

[rangek@asimov psnup]$ psnup -2 -pletter -d foo.ps foo_new.ps
[1] Wrote 1 pages, 55400 bytes
[rangek@asimov psnup]$ diff -u foo2bad.ps foo_new.ps


Comment 6 Kevin Range 2005-03-07 02:44:15 UTC
That should be psutils-1.17-23 in FC3.  (I had a window on a FC9 box up.)

Comment 7 Peter Englmaier 2005-11-03 10:44:31 UTC
I have a fix for this problem. It is submitted to both psnup and cups
maintainers, however, it is not clear to me if the patch is accepted. The
problem is in cups, not in psnup, because the postscript files print when
submitted directly to the printer. However, the cups maintainer is saying that
psnup is not creating complient files. The fix is to install an additional
filter in cups (two files, see below) and change the filter in the
/etc/cups/mime.conv file:
#application/postscript  application/vnd.cups-postscript 66      pstops
application/postscript  application/vnd.cups-postscript 66      badpstops

This will make postscript files filter through the attached scripts, which
just move the psutils stuff down in the %%BeginSetup section. I do not
know if that makes the file perfect postscript, but at least cusp can print
it.

Since everyone thinks redhat should support people submitting patches, I
like to comment that it took me 2 days to fix this problem. 
Send the money to New Orleans.


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"

Comment 8 Matthew Miller 2006-07-10 19:43:18 UTC
Fedora Core 3 is now maintained by the Fedora Legacy project for security
updates only. If this problem is a security issue, please reopen and
reassign to the Fedora Legacy product. If it is not a security issue and
hasn't been resolved in the current FC5 updates or in the FC6 test
release, reopen and change the version to match.


Comment 9 Adam Tkac 2006-10-11 15:33:33 UTC
Please try to reproduce this bug with latest version of psutils in FC5.
Otherwise I'm going to close this bug

Comment 10 Tim Waugh 2006-10-17 09:59:59 UTC
FWW, here is what cupstestdsc (the CUPS utility for checking PostScript DSC
validity) says about the original gnumeric output:

foo.ps: FAIL
    Bad %%Page: on line 23!
        REF: Page 53, %%Page:
    Bad %%Page: on line 2289!
        REF: Page 53, %%Page:
    Missing or bad %%BoundingBox: comment!
        REF: Page 39, %%BoundingBox:
    Missing or bad %%Pages: comment!
        REF: Page 43, %%Pages:
    Missing or bad %%Page: comments!
        REF: Page 53, %%Page:
    Warning: obsolete DSC version 2.0 in file!
    Warning: no %%EndComments comment in file!


Comment 11 Gregory Leblanc 2006-12-16 00:39:01 UTC
Closing this as NOTABUG seems just plain wrong.  What is the motivation behind
this change?