Skip to content

ppd-generator: let "stackingorder" decide the output order - #120

Open
xangelix wants to merge 1 commit into
OpenPrinting:masterfrom
xangelix:generator-output-order-stackingorder
Open

xangelix wants to merge 1 commit into
OpenPrinting:masterfrom
xangelix:generator-output-order-stackingorder

Conversation

@xangelix

Copy link
Copy Markdown

Assisted by Claude, this PR fixes an issue I was having with my Epson ET-4950. I have manually confirmed the findings, the fix (on my limited hardware), and that the code is reasonable to merge given my own limited understanding of how this fits into the drivers here.

Happy to make changes or take a different approach if requested.


The PPD generator writes *DefaultOutputOrder / *PageStackOrder as Reverse only if exactly one of pagedelivery=faceUp and stackingorder=lastToFirst is in printer-output-tray, as if they were two independent inversions. stackingorder is prtOutputStackingOrder from the Printer MIB (RFC 3805): lastToFirst means "the back of the next page is placed against the front of the previous page", which is simply what a face-up bin does. So a face-up bin reporting both gets Normal, and the last page ends up on top.

Seen with an Epson ET-4950 (output-bin-default = face-up, printer-output-tray = ...;stackingorder=lastToFirst;pagedelivery=faceUp;): driverless cat gives *PageStackOrder FaceUp: Normal, while a CUPS IPP Everywhere queue for the same printer gets Reverse.

This PR decides by stackingorder and falls back to pagedelivery or the bin name only without it, the same rule as cfIPPReverseOutput() in libcupsfilters; CUPS's own generator also uses stackingorder alone. It also matches libppd's own conversion in the other direction: ppdLoadAttributes() turns *PageStackOrder ...: Reverse into stackingorder=lastToFirst (without output bins, into stackingorder=lastToFirst;pagedelivery=faceUp), which the generator previously turned back into Normal. Both places in the generator now share one helper.

Testing:

  • New cases in test_ppd_generator (face-up/lastToFirst, face-down/firstToLast, stackingorder contradicting the bin name, pagedelivery alone). Without this change the first and third fail. make check: 14/14 pass.
  • driverless cat ipp://<ET-4950>/ipp/print with this build: only *DefaultOutputOrder and *PageStackOrder FaceUp change, both to Reverse.
  • With pdftopdf: take output order and duplex from the printer defaults again libcupsfilters#366 (pdftopdf reads *PageStackOrder again), the generated PPD now gives pages in reverse order (3,2,1); the old PPD gave 1,2,3.

Related: #119, OpenPrinting/libcupsfilters#366

Comment thread ppd/ppd-generator.c Fixed
The generator wrote *DefaultOutputOrder and *PageStackOrder as Reverse
only if exactly one of "pagedelivery=faceUp" and
"stackingorder=lastToFirst" was in "printer-output-tray", treating them
as two independent inversions.  They are not: "stackingorder" is
prtOutputStackingOrder of the Printer MIB (RFC 3805), where
"lastToFirst" means that the back of each page is placed against the
front of the previous page, which is what a face-up bin does.  So a
face-up bin reporting both, like the one of an Epson ET-4950, got
Normal and printed the last page on top.

Decide by "stackingorder" and use "pagedelivery" or the bin name only
without it, as cfIPPReverseOutput() in libcupsfilters does.  The PPD
generator of CUPS also uses "stackingorder" alone.  Both places now use
the same helper.

Add tests for face-up/lastToFirst, face-down/firstToLast, a
"stackingorder" contradicting the bin name, and "pagedelivery" alone.
The first and third fail without this change.
@xangelix
xangelix force-pushed the generator-output-order-stackingorder branch from 6217d79 to 1040f1b Compare November 21, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants