Bug 161152 - LibreOffice doesn't set printer option "sides" leading to duplex not working on printers relying on this option
Summary: LibreOffice doesn't set printer option "sides" leading to duplex not working ...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
7.4.7.2 release
Hardware: All Linux (All)
: medium normal
Assignee: Michael Weghorn
URL:
Whiteboard: target:25.2.0 target:24.8.4
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-17 13:47 UTC by qez33165
Modified: 2024-10-31 08:32 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
My Brother's DCP9020CDW ppd as requested (26.28 KB, text/plain)
2024-10-26 10:07 UTC, Pierre
Details

Note You need to log in before you can comment on or make changes to this bug.
Description qez33165 2024-05-17 13:47:17 UTC
Description:
There are two printer options for duplex printing on Linux/CUPS.

One is called "Duplex" and can be set to one of None/DuplexNoTumble/DuplexTumble.
It's described here: https://oip.manual.canon/USRMA-0595-zz-DR-deDE/contents/dlu-cmd-basic-2side.html

The other is called "sides" and can bet set to one of one-sided/two-sided-long-edge/two-sided-short-edge.
It's described here: https://www.cups.org/doc/options.html

It depends on the printer which one is actually used.

I have a Brother MFC-L3730CDN which uses the "sides" option.
I also have a Brother MFC-J480DW which uses the "Duplex" option.

LibreOffice doesn't set the "sides" option which means that the duplex setting in LibreOffice has no effect for printers which rely on this option.
That means the "sides" option is always set to the default value of the CUPS printer for every print job.

To debug this I paused the printer and run the "strings" command on the PPD file of the print job in /var/spool/cups.
It turned out that the "Duplex" setting is set to the value selected in the LibreOffice print dialogue.
But the "sides" option is always the default and never what I selected in the LibreOffice print dialogue.

I want to add that other programs work fine. Only LibreOffice is causing problems.

Steps to Reproduce:
1. Set the duplex default of your CUPS printer to off (one-sided)
2. Reboot your system (necessary; don't know why)
3. Pause your CUPS printer (perhaps not necessary)
4. Print an (empty) two-sided document in LibreOffice Writer with duplex on
5. Run the "strings" command on the PPD file of the print job in /var/spool/cups
6. You will see that it says sides<new line>one-sided

Actual Results:
sides
one-sided

Expected Results:
sides
two-sided-long-edge


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 7.4.7.2 / LibreOffice Community
Build ID: 40(Build:2)
CPU threads: 4; OS: Linux 6.1; UI render: default; VCL: kf5 (cairo+wayland)
Locale: de-DE (de_DE.UTF-8); UI: de-DE
Debian package version: 4:7.4.7-1+deb12u2
Calc: threaded
Comment 1 qez33165 2024-06-01 13:02:13 UTC
In order for the PPD file to appear under /var/spool/cups you have to wait 1-2 min. The file starts with a "c".
Comment 2 Stéphane Guillou (stragu) 2024-06-06 12:51:59 UTC
Thanks for the report.

Possibly related, other duplex issues with Brother printers:
- bug 45630
- bug 61337

Caolán, thought you might have insights?
Comment 3 Michael Weghorn 2024-06-11 14:01:13 UTC
(In reply to qez33165 from comment #0)
> It depends on the printer which one is actually used.
> 
> I have a Brother MFC-L3730CDN which uses the "sides" option.
> I also have a Brother MFC-J480DW which uses the "Duplex" option.

Can you please attach the PPD files of both printers?
Comment 4 qez33165 2024-08-16 11:20:22 UTC
I guess the problem is in the core repository in these two files:

https://github.com/LibreOffice/core/blob/e3d7473a5611f414bfcf1a3e812248c82f9e9b83/vcl/unx/generic/printer/configuration/ppds/SGENPRT.PS#L332
https://github.com/LibreOffice/core/blob/e3d7473a5611f414bfcf1a3e812248c82f9e9b83/vcl/unx/generic/print/genprnpsp.cxx#L531

It sets the "Duplex" property there but there needs to be added code which sets the "sides" property too...
Comment 5 QA Administrators 2024-08-17 03:16:08 UTC Comment hidden (obsolete)
Comment 6 Michael Weghorn 2024-08-24 21:51:39 UTC
(In reply to qez33165 from comment #4)
> I guess the problem is in the core repository in these two files:
> 
> https://github.com/LibreOffice/core/blob/
> e3d7473a5611f414bfcf1a3e812248c82f9e9b83/vcl/unx/generic/printer/
> configuration/ppds/SGENPRT.PS#L332
> https://github.com/LibreOffice/core/blob/
> e3d7473a5611f414bfcf1a3e812248c82f9e9b83/vcl/unx/generic/print/genprnpsp.
> cxx#L531
> 
> It sets the "Duplex" property there but there needs to be added code which
> sets the "sides" property too...

At first glance, that code deals with PPD options, and the "sides" option might not be present in the PPD.

(It's been a while that I had to do with this, but I thought that CUPS was mapping between the Duplex PPD option and the "sides" IPP option.)

In any case, it's hard to say something really specific without the actual PPDs at hand (s. comment 3).
Comment 7 Pierre 2024-10-26 10:07:03 UTC
Created attachment 197246 [details]
My Brother's DCP9020CDW ppd as requested

Same problem on LO Writer
Version: 24.2.6.2 (X86_64) / LibreOffice Community
Build ID: ef66aa7e36a1bb8e65bfbc63aba53045a14d0871
CPU threads: 2; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: fr-CH (fr_CH.UTF-8); UI: fr-FR
Calc: threaded

pierre@iMacPB:~$ cat /etc/debian_version
12.7

pierre@iMacPB:~$ sudo strings /var/spool/cups/c00082
...
printer-uri
,ipp://localhost/printers/Brother_DCP_9020CDWB
...
Duplex
DuplexNoTumbleB
	InputSlot
...
sides
	one-sidedB

Thanks for help and regards, Pierre
Comment 8 Michael Weghorn 2024-10-29 10:19:00 UTC
(In reply to Pierre from comment #7)
> Created attachment 197246 [details]
> My Brother's DCP9020CDW ppd as requested

Thanks.

With a dummy printer set up using that PPD, I can reproduce:

Printing from Kate (i.e. using the Qt print dialog), I see this in /var/log/cups/error.log when selecting duplex in the print dialog (i.e. this contains both, "sides=two-sided-long-edge" and "Duplex=DuplexNoTumble"):

> D [29/Oct/2024:11:09:12 +0100] [Job 183] argv[5]="media=Letter sides=two-sided-long-edge number-up=1 number-up-layout=lrtb job-billing= job-uuid=urn:uuid:f8e1b492-96db-3d74-76a8-002e1a448a8f job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1730196552 time-at-processing=1730196552 document-name-supplied=476676726f6fe Duplex=DuplexNoTumble PageSize=Letter"

When printing from LO, I see this (i.e. only contains "Duplex=DuplexNoTumble", but no "sides" option):

> D [29/Oct/2024:11:12:10 +0100] [Job 184] argv[5]="Duplex=DuplexNoTumble PageSize=A4 job-uuid=urn:uuid:9338f443-35f2-38ff-7994-b45cda66f977 job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1730196730 time-at-processing=1730196730 document-name-supplied=4QQijP"

Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: cd2e3087642bb2849a089fb121f7b2c581fe0f00
CPU threads: 32; OS: Linux 6.11; UI render: default; VCL: qt6 (cairo+wayland)
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: CL threaded
Comment 9 Michael Weghorn 2024-10-29 11:13:04 UTC
Pending change:
https://gerrit.libreoffice.org/c/core/+/175782

With that in place, I now get e.g.

> D [29/Oct/2024:12:09:55 +0100] [Job 200] argv[5]="Duplex=DuplexNoTumble PageSize=A4 sides=two-sided-long-edge job-uuid=urn:uuid:79725d8e-758d-388f-608f-96493364854f job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1730200195 time-at-processing=1730200195 document-name-supplied=68lekk"

in the CUPS log, i.e. both, the "sides" and the "Duplex" option are set when selecting a non-default one in the print dialog.

I don't have a Brother (or any duplex) printer at hand myself to test the actual print result, though.
Comment 10 Commit Notification 2024-10-29 12:35:32 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/152896274aca291a5d2181db6dd639c3e36c2a02

tdf#161152 vcl: Set CUPS "sides" option for duplex mode

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Michael Weghorn 2024-10-29 12:38:25 UTC
(In reply to Michael Weghorn from comment #9)
> I don't have a Brother (or any duplex) printer at hand myself to test the
> actual print result, though.

That change is merged to the current development version now. I'm closing as fixed as I see the "sides" option being set now, but as I mentioned, I don't have an actual printer for testing the specific scenario.

Could one of the affected users please test with a daily build as described at https://wiki.documentfoundation.org/QA/Testing_Daily_Builds and report back here? (Reopen the bug and give more details if it still doesn't work, say all is fine otherwise.)
Comment 12 Michael Weghorn 2024-10-29 12:39:37 UTC
(In reply to Michael Weghorn from comment #11)
> Could one of the affected users please test with a daily build as described
> at https://wiki.documentfoundation.org/QA/Testing_Daily_Builds and report
> back here? (Reopen the bug and give more details if it still doesn't work,
> say all is fine otherwise.)

Please note you'll need a daily build from tomorrow or later on for the change to actually be included, so please wait until that's available before testing.
Comment 13 Pierre 2024-10-30 16:34:29 UTC
All is fine.
Thanks and regards Pierre
Comment 14 Michael Weghorn 2024-10-30 21:08:06 UTC
(In reply to Pierre from comment #13)
> All is fine.
> Thanks and regards Pierre

Great, thanks for testing.
Pending backport for 24.8:
https://gerrit.libreoffice.org/c/core/+/175836
Comment 15 Commit Notification 2024-10-31 08:32:50 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/06da42353c53193685da3d2aa0b313bd5c1b1026

tdf#161152 vcl: Set CUPS "sides" option for duplex mode

It will be available in 24.8.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.