pdftops CUPS filter (Poppler mode) does not conserve paper sizes of input file #3689
If I print a PDF document with pages of different sizes (for example A4 pages and one A3-sized fold-out page between them) the pages get all scaled to the default paper size (or the to the page size of the first page).
This scaling of the pages happens in the pdftops filter when the filter is built to use Poppler's pdftops utility for the conversion (I do not build with Ghostscript as the PostScript generated by Ghostscript has a lot of problems). Formerly, Poppler's pdftops utility did not support generating PostScript with varying paper sizes. This problem I have solved by adding the "-origpagesizes" option to the utility and this change got accepted by Poppler upstream (http://bugs.freedesktop.org/show_bug.cgi?id=19777). Then I have applied the attached patch to the CUPS packages of Debian and Ubuntu so that the pdftops filter of CUPS uses the new option and now there PDFs with varying page sizes get printed correctly.
This gets more and more important as applications are switching to send PDF instead of PostScript to CUPS when printing, especially all KDE and many GNOME applications do so, and OpenOffice.org will send PDF from the next release on. Also when switching over to the PDF printing workflow (http://www.cups.org/str.php?L2897) the pdftops filter plays and important role for printing on PostScript printers.
The attached patch fixes pdftops to support documents with varying page sizes. It also adds a build-time check to verify that the installed Poppler is really new enough to contain the "-origpagesizes" option in its pdftops utility.
The text was updated successfully, but these errors were encountered:
CUPS.org User: h.blischke
I just checked the poppler based pdftops 0.12.4 (from peppermint one) and found that using the option "-origpagesizes" does not properly preserve page independence:
The setpagedevice command in the PageSetup section should be emitted for every page of the PDF that has it's own MediaBox or CropBox, and these pages should bracketed by a save and restore statement. Otherwise changing the output order or other page reordering will lead to weird results.
Moreover, it the source PDF really contains pages of different sizes, how then is n-up printing handled?
CUPS.org User: till.kamppeter
Helge, can you give a file example with the correctly set page sizes and "save" and "restore" calls? Can you also tell how to make duplex printing correctly working when each page in the PostScript file requests its paper size? My first patch for Poppler had all pages requesting their paper size and then duplex got reset to the front side of each sheet, making the job coming out one-sided. So I changed it to request the paper size only if it changes (see http://bugs.freedesktop.org/show_bug.cgi?id=19777).
CUPS.org User: h.blischke
First, in any case I'd through the PDF's pae nodes and page object dictionaries to evaluate the prevailing page size and use that as the default page size as defined by the pdfSetup procedure.
Then, if -origpagesizes is specified, I'd only specify a page specific page size if it differs from the overall page size. To preserve page independence (which is mandatory to allow page reordering), my suggestion is to insert save and restore statements as follows
%%Page: 1 1
... page body goes here
In case of duplex printing, the save and restore could bracket a pair of subsequent pages (an odd and an even one), provided that both pages have the same page size (printing different page sizes onto the same sheet seems not quite reaonable, doesn't it?).
Nevertheless, preserving the original page sizes of a multi-sized PDF document and printing on a real printer is sort of a goal conflict - it is not compliant with number-up or printing or booklet making or the like. Moreover, many production printers implement finishing (binding or stapling etc.) sections of a job by bracketing these sections by save and restore and switching the finishing parameters by a setpagedevice statement immediately following the save (for the details see the device control sections of the PLRM).
#! /bin/sh /usr/share/dpatch/dpatch-run
poppler-based-pdftops-fixes.dpatch by firstname.lastname@example.org
All lines beginning with `## DP:' are a description of the patch.
DP: No description.
+if test "x$CUPS_PDFTOPS" != x; then
diff -urNad cups-1.3.11~/filter/pdftops.c cups-1.3.11/filter/pdftops.c