apple / cups

Apple CUPS Sources
https://www.cups.org
Apache License 2.0
1.9k stars 461 forks source link

pstops filter produces incorrect output with number-up=2 on some documents #2663

Closed michaelrsweet closed 16 years ago

michaelrsweet commented 16 years ago

Version: 1.3.5 CUPS.org User: mardur

On some documents (ps-files created with LaTeX-beamer package, or with cups pdftops-filter, see attachment for an example input file (gzipped)) with an odd number of pages, the pstops filter produces incorrect output with option 'number-up=2'. The ps-viewer gv is hanging on displaying the last page. The last page is not printed on an HP LaserJet 4350.

filter/pstops.c (7067 2007-11-09 19:54:09Z mike) contains the code:

if (number && !is_first_page(number) && cupsArrayLast(doc->pages)) { pageinfo = (pstops_page_t *)cupsArrayLast(doc->pages);

start_nup(doc, doc->number_up, 0, doc->bounding_box);
doc_puts(doc, "showpage\n");
end_nup(doc, doc->number_up);

pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset;

}

which is not executed on the last output page with an odd-page input document, due to the "!is_first_page(number)". Instead of testing for a single page on the last output page, the filter should check for activated number-up printing.

if (number && (doc->number_up > 1) && cupsArrayLast(doc->pages)) { ... nup-stuff }

I am not familiar with postscript, so I don't know what start/end_nup are doing together with 'showpage', but the change above resolved the problem. This code is working fine on all tested documents with and without number-up printing.

I am using cups 1.3.5 from subversion repository r7167. Compiled with Sun Studio 11 on a sparcv8, Solaris 9/10.

michaelrsweet commented 16 years ago

CUPS.org User: mike

Please re-test with the current version from the repo - r7174 should have the necessary fix.

michaelrsweet commented 16 years ago

CUPS.org User: mardur

Yes, this fixed the problem. I should svn-update more regularly.