`number-up=2` applied twice on PostScript PPD queue (pdftopdf + pstops), giving 4-up output
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by tracing the filter chain described in the report: universal → pdftopdf → ppdFilterPDFToPS (gs and pstops) → hpps. Reproduce the page counts with the supplied cupsfilter commands and inspect how number-up=2 is passed between stages. Done means the chain produces four sheets from the eight-page PDF, with two pages on each sheet.
Written by the indexing model from the issue text.
Description
Summary
On a queue using a PostScript PPD (HP Color LaserJet Pro M252dw, hpps filter), printing a PDF with -o number-up=2 produces 4-up output instead of 2-up. The filter chain runs both pdftopdf and pstops, and both appear to apply the N-up layout, so the effect is 2 × 2 = 4.
System Information
- Distribution: Manjaro Linux
- cups 2:2.4.19-1
- cups-filters 2.0.1-2
- libcupsfilters 2.2.1-2
- libppd 2.1.1-2
- Printer: HP Color LaserJet Pro M252dw
- PPD:
/etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw.ppd(shipped by the distribution)*cupsFilter: "application/vnd.cups-postscript 0 hpps"- Model: "HP Color LaserJet Pro M252 Postscript (recommended)"
Steps to reproduce
- Generate a simple 8-page A4 portrait test PDF (no external dependencies beyond Ghostscript):
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=a4 -sOutputFile=/tmp/test8.pdf \
-c "/Helvetica findfont 72 scalefont setfont 1 1 8 { /n exch def 200 400 moveto (Page ) show n 3 string cvs show showpage } for"
- Print it with N-up 2:
lp -d HP_Color_LaserJet_Pro_M252dw -o number-up=2 /tmp/test8.pdf
I first saw this with a real document (an 8-page page range extracted with pdftk), and it reproduces identically with the generated file, so it does not depend on the document's content.
Expected result
4 sheets, each with 2 pages.
Actual result
2 sheets, each with 4 pages.
Additional context
-o number-up=1prints 1-up, so the source is not already N-up.- No
number-updefault is set in lpoptions, the PPD or the printer. - Adding
sides=two-sided-short-edgemakes no difference; the job is 4-up with or without it. - Pre-building the 2-up PDF (
pdfjam --nup 2x1 --landscape) and printing withoutnumber-upworks correctly.
Debug log excerpt (real job)
The options reach the chain intact, and the chain is universal → pdftopdf → ppdFilterPDFToPS (gs + pstops) → hpps:
argv[5]="finishings=3 number-up=2 print-color-mode=color ..."
cfFilterUniversal: Adding pdftopdf to chain
cfFilterChain: pdftopdf completed with status 0.
ppdFilterPDFToPS: Started filter gs
ppdFilterPDFToPS: Started filter pstops
Offline reproduction, no printer needed
cupsfilter and pdftopdf have to run as root here because the PPD is not readable by normal users.
sudo PPD=/etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw.ppd /usr/lib/cups/filter/pdftopdf 1 me title 1 "number-up=2" /tmp/test8.pdf > /tmp/stage1.pdf
pdfinfo /tmp/stage1.pdf | grep -E 'Pages|Page size'
sudo cupsfilter -p /etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw.ppd -m application/postscript -o number-up=2 /tmp/test8.pdf > /tmp/full.ps
ps2pdf /tmp/full.ps /tmp/full.pdf && pdfinfo /tmp/full.pdf | grep Pages
Results:
| Stage | Input pages | Output pages |
|---|---|---|
pdftopdf alone |
8 | 4 (A4 portrait, correct 2-up) |
ppdFilterPSToPS (inside ppdFilterPDFToPS) |
%%Pages: 4 |
"Wrote 2 pages" |
Whole chain (ps2pdf of full.ps) |
8 | 2 |
Relevant cupsfilter debug lines:
cfFilterUniversal: Adding pdftopdf to chain
ppdFilterPDFToPS: Running command line for gs: gs -q -dNOPAUSE -dBATCH -dSAFER -dNOMEDIAATTRS -sstdout=%stderr -sDEVICE=ps2write ... -r600 ... -f /tmp/...
ppdFilterPSToPS: %%Pages: 4
ppdFilterPSToPS: Wrote 2 pages...
Analysis
pdftopdf correctly produces 4 sheets from 8 pages. pstops then receives that 4-page PostScript and combines it again into 2 sheets. The pstops debug output does not log number-up explicitly, so this conclusion rests on the page counts (4 in, 2 out) and on the fact that number-up=1 does not trigger it.
It looks like N-up should be handled by only one of the two stages when universal inserts pdftopdf ahead of ppdFilterPDFToPS. For example, pdftopdf could consume the option and strip it from the options passed on, or pstops could skip its layout when an earlier stage already did it.
I am not sure which component is at fault (libppd, libcupsfilters, or the way the filter chain is assembled). Please move the issue if it belongs elsewhere.
Workarounds
- Pre-generate the 2-up PDF and print without
number-up:
cat /tmp/test8.pdf | pdfjam --nup 2x1 --landscape --outfile /dev/stdout /dev/stdin | lp -o sides=two-sided-short-edge - Use a driverless IPP queue (
lpadmin -m everywhere), which has nopstopsstage.
- Dominant language
- C
- Stars
- 6
- Forks
- 38
- Avg merge
- 23h 9m
- Merged PRs (30d)
- 16
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenPrinting/libppd
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
OpenPrinting/libppd#95 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
OpenPrinting/libppd#90 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
OpenPrinting/libppd#65 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
OpenPrinting/libppd#60 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
OpenPrinting/libppd#52 · 7 comments ·
Maintainers usually reply within 1 day
All issues in OpenPrinting/libppd
Similar issues
-
`sha256()` returns a wrong hash when libsql-ffi is built with gcc 11 or laterPossibly taken @colinhacks claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tursodatabase/libsql#2333 ·
Maintainers usually reply within 11 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenPrinting/cups#1826 ·
Maintainers usually reply within 1 day
-
Backport to 3.0 advertises a suffix that does not existPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
389ds/389-ds-base#8152 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RetroAchievements/rcheevos#580 · 1 comment ·
Maintainers usually reply within 5 days