#1071595 cups: contortions needed to use duplex printing on HP Laserjet M402dn

Package:
cups
Source:
cups
Description:
Common UNIX Printing System(tm) - PPD/driver support, web interface
Submitter:
Sanjoy Mahajan
Date:
2025-12-15 01:55:02 UTC
Severity:
normal
#1071595#5
Date:
2024-05-21 20:24:24 UTC
From:
To:
When using CUPS (lp), I couldn't get duplex printing to work on the
newly arrived (used) HP Laserjet M402dn.  The documents come out single
sided even though I had (1) set the print queue's default options to
include two-sided-long-edge (via the web interface on port 631), (2) had
specified sides=two-sided-long-edge on the command line, and (3) had set
the printer's default (via the EWS) to duplex (long edge).

Meanwhile, the printer hardware works fine: My wife's Mac, also running
CUPS, prints duplex with no problem, and sending a PDF directly to the
printer using netcat gives duplex output too.

The problem seems to be the following, from the cups error_log (see
attached 1.log for the full output for that job):

D [21/May/2024:20:53:32 +0200] [Job 12731] ---- unsupported-attributes-tag ----
D [21/May/2024:20:53:32 +0200] [Job 12731] sides keyword two-sided-long-edge
D [21/May/2024:20:53:32 +0200] [Job 12731] ---- end-of-attributes-tag ----
D [21/May/2024:20:53:32 +0200] [Job 12731] Unable to do two-sided printing, setting sides to \'one-sided\'.

However, the printer itself knows it can do two-sided printing.  Also
from the error_log:

D [21/May/2024:20:53:32 +0200] [Job 12731] media-col-supported 1setOf keyword media-size,media-top-margin,media-left-margin,media-right-margin,media-bottom-margin,media-type,media-source,media-source-properties,duplex-supported

And I've attached the result of running ipptool to get the printer attributes:

$ ipptool -tv ipp://NPI4CFED8.lan:631/ipp/print get-printer-attributes.test > attributes.txt

It contains

        media-col-supported (1setOf keyword) = media-size,media-top-margin,media-left-margin,media-right-margin,media-bottom-margin,media-type,media-source,media-source-properties,duplex-supported

I've worked around the problem by setting the following default options
(from /etc/cups/lpoptions):

Default lj402 sides=DuplexNoTumble

This new setting of the "sides" keyword seems to confuse cups enough
that it doesn't bother to forcibly revert to one-sided output.  And the
printer hardware's configuration of printing duplex now takes over.

For reference ,here are the printer's lpoptions:

$ lpoptions -l
PageSize/Media Size: 100x150mm 184x260mm 195x270mm 4x6 5x8 *A4 A5 A6 B5 B6 DoublePostcardRotated Env10 EnvC5 EnvDL EnvMonarch Executive FanFoldGermanLegal ISOB5 Legal Letter Oficio Postcard Statement roc16k Custom.WIDTHxHEIGHT
InputSlot/Media Source: *Auto Manual Tray1 Tray2
MediaType/Media Type: *Stationery StationeryLightweight ExtraLight Intermediate Midweight StationeryHeavyweight ExtraHeavy Transparency Labels StationeryLetterhead Envelope StationeryPreprinted StationeryPrepunched StationeryColored StationeryBond Recycled Rough
cupsPrintQuality/cupsPrintQuality: Draft *Normal
ColorModel/Output Mode: *Gray
Duplex/Duplex: None *DuplexNoTumble DuplexTumble
OutputBin/OutputBin: *FaceDown

#1071595#10
Date:
2024-05-22 13:05:52 UTC
From:
To:
I have just updated the printer's firmware (from a 2015 to a 2020 one).
Now it prints in duplex mode with no complaints.  So, it was almost
certainly a printer bug rather than a CUPS bug.

#1071595#15
Date:
2024-05-25 15:39:13 UTC
From:
To:
Great, thanks a lot for telling us. So I close this bug.

   Thorsten

#1071595#16
Date:
2024-06-05 11:04:16 UTC
From:
To:
I'm sorry to reopen this bug, but it seems that I spoke too soon.  The
duplex-printing problem reappeared a couple days ago, despite the newer
firmware.  So, I don't know whether it's a new problem, or whether my
earlier idea (that the newer firmware fixed it) was just noise.

I've tried powering cycling the printer and restarting cups, but it
doesn't make a difference.

Are there further tests that I can try?  (I've re-grabbed the
attributes.txt, but there's no difference between it and the one that I
attached earlier, except for trivial differences like uptime.)

#1071595#23
Date:
2025-12-15 01:21:39 UTC
From:
To:
#1071595#28
Date:
2025-12-15 01:08:01 UTC
From:
To:
I am now seeing this issue with my HP m479fdw printer.

Two computers, computer A with the printer added through the settings
app back in July, computer B with the printer added today. In both cases
the printer was added exactly the same way. On A, duplex printing is
available. On B, it's not.

I can get duplex functionality on B as follows:

1) Shut down cups.

2) Delete /var/cache/cups/*.*

3) Replace the PPD file for the printer in /etc/cups/ppd with the PPD
file from A.

2) Start cups back up.

Now duplex printing works.

Note: if I remove the printer on A (after backing up the PPD file) and
re-add it, duplex printing goes away. I can then restore duplex printing
as described above.

So the problem is clearly that when the printer is initially added CUPS
is failing to detect the fact that it supports duplex printing. Not only
that, but this is a regression, otherwise I wouldn't have access to the
PPD that was generated on A back in July that has duplex options in it.