From 8f17dceb6bcadc0fc7cee5e0143bee84d2982230 Mon Sep 17 00:00:00 2001 From: Cody Wyatt Neiman Date: Sun, 22 Nov 2026 16:40:36 -0500 Subject: [PATCH] pdftops: do not let pstops reverse pages again after pdftopdf When the input comes from pdftopdf, ppdFilterPDFToPS() removes "OutputOrder" from the options for pstops, as pdftopdf has already put the pages into the right order. But without "OutputOrder", pstops falls back to the PPD's default output order (*PageStackOrder of the default output bin, *DefaultOutputOrder) and reverses the pages a second time if that is "Reverse". So on PostScript PPD queues with a face-up output bin, every job that pdftopdf reverses comes out in the wrong order: jobs with an explicit "outputorder", and, with the QPDF-based pdftopdf of libcupsfilters 2.0.x/2.1.x, also jobs without one, as it reverses them from the printer's default output bin. Pass "OutputOrder=Normal" to pstops in this case, as is already done for "Collate", so that the output order is only applied by pdftopdf. Queues whose PPD defaults to normal order are not affected. The PDFio-based pdftopdf of libcupsfilters 2.2.x lost that printer default, so there jobs without "outputorder" currently get their reversal from pstops only. This needs OpenPrinting/libcupsfilters#366, which restores it in pdftopdf. Fixes #119. --- ppd/pdftops.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ppd/pdftops.c b/ppd/pdftops.c index 0bb31c53..2780142c 100644 --- a/ppd/pdftops.c +++ b/ppd/pdftops.c @@ -618,6 +618,19 @@ ppdFilterPDFToPS(int inputfd, // I - File descriptor input stream num_pstops_options, &pstops_options); } + if (pdftopdfapplied) + { + // + // pdftopdf has already put the pages into the requested or the printer's + // default output order, so tell pstops not to reverse them again from + // the PPD's default output order. + // + + num_pstops_options = cupsAddOption("OutputOrder", + "Normal", + num_pstops_options, &pstops_options); + } + // // Create data record to call the pstops filter function //