Bug 56503 - psnup produces incorrect output
psnup produces incorrect output
Product: Fedora
Classification: Fedora
Component: psutils (Show other bugs)
All Linux
medium Severity low
: ---
: ---
Assigned To: Martin Bacovsky
Depends On:
  Show dependency treegraph
Reported: 2001-11-19 22:13 EST by Kevin Range
Modified: 2007-11-30 17:10 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-12-13 13:17:08 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
gnumeric print output (51.72 KB, application/postscript)
2001-11-19 22:16 EST, Kevin Range
no flags Details
psnup -2 -pletter -d foo.ps output (54.10 KB, application/postscript)
2001-11-19 22:17 EST, Kevin Range
no flags Details
mpage -2 foo.ps output (56.28 KB, application/postscript)
2001-11-19 22:18 EST, Kevin Range
no flags Details

  None (edit)
Description Kevin Range 2001-11-19 22:13:53 EST
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:

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-19 22:16:22 EST
Created attachment 37988 [details]
gnumeric print output
Comment 2 Kevin Range 2001-11-19 22:17:47 EST
Created attachment 37989 [details]
psnup -2 -pletter -d foo.ps output
Comment 3 Kevin Range 2001-11-19 22:18:51 EST
Created attachment 37990 [details]
mpage -2 foo.ps output
Comment 4 Alex Cherepanov 2005-03-06 20:08:11 EST
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-06 21:27:59 EST
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-06 21:44:15 EST
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 05:44:31 EST
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

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.

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

Wrapper script "/usr/lib/cups/badpstops"

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

cat $ifile | $FILTERDIR/badpostscript |
$FILTERDIR/pstops "$1" "$2" "$3" "$4" "$5"
Comment 8 Matthew Miller 2006-07-10 15:43:18 EDT
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 11:33:33 EDT
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 05:59:59 EDT
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-15 19:39:01 EST
Closing this as NOTABUG seems just plain wrong.  What is the motivation behind
this change?

Note You need to log in before you can comment on or make changes to this bug.