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