Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom usercode with lpoptions isn't shown in Libreoffice #405

Closed
TxOfficial opened this issue May 30, 2022 · 8 comments
Closed

custom usercode with lpoptions isn't shown in Libreoffice #405

TxOfficial opened this issue May 30, 2022 · 8 comments
Labels
bug Something isn't working third-party The bug/fix is in a different project

Comments

@TxOfficial
Copy link

Today i check the behaviour on the new Ubuntu 22.04 with CUPS 2.4.1 and the following PPD:

https://www.openprinting.org/download/PPD/Ricoh/PS/Ricoh-IM_C3000_PS.ppd

When I use the print dialog from libre office and setup the usercode manually within the appplication printdialog, I got the attached PS-file "01_Print_via_libre_print_dialog_usercode_0850.ps.txt" within the UserCode 0850. Then I closed libre office, used lpoptions on the command line (refer screenshot 05_lpoptions_command.png), started libre again and print without any changes in the printdialog of libre I got "02_Print_via_libre_lpoption.ps.txt" with an empty UserCode. At this time lpoption -l and cat ~/.cups/lpoption has the values from the attached Screenshot "03_Values of lpoption.png". See the asterisk (*) in the usercode line at "Custom.STRING". When I open the printdialog in libre and check the usercode option the option was also set to custom but with an empty value (not "0850") and the printresult is wrong as "02_...ps.txt". I've checked the cups error_log, but can't find any entry for UserCode "0850" at this time and also the processing of the lpoptions command after I setup "cupsctl --debug-logging" takes a really long time, approx. 20sec after the cursor/promt comes back. Interesting is, when i use the lp-command "lp -d print2welp -o UserCode=Custom.0850 test.pdf" it works and I get a correct file similar to "01_....ps.txt". So i think there is a bug within the lpoptions command

Hope you can find anything that can help us in the attached cups error_log. Until approx. 1,1MB you find the first bad printout (lpoption) without success and after that the second one with the successful lp command.

01_Print_via_libre_print_dialog_usercode_0850.ps.txt
02_Print_via_libre_lpoption.ps.txt
03_Values of lpoption
04_libre print dialog after set of lpoption - empty value but switched to custom
error_log.txt
05_lpoptions_command

@zdohnal
Copy link
Member

zdohnal commented May 31, 2022

Hi @TxOfficial ,

thank you for reporting the issue!

Unfortunately it looks you've forgot to attach the .txt file with debug logs - I see only the links to PPD, postscript outputs and screenshots - it would be great if you attached the debug log file as well.

Ad the issue - since you change a default value via lpoptions, AFAIU it should be used during normal lp invocation (without -o). Do you get the correct output that way?

@zdohnal zdohnal added investigating Investigating the issue waiting for reporter There are data requested from the reporter labels May 31, 2022
@TxOfficial
Copy link
Author

Hi @zdohnal,

the "error_log.txt" is still there, between the last two screenshots. I think that the lp commands works but we want to use lpoptions to change the default when we print with the application and not via lp. If we choose one of the predefind values 1001,1002, or 1003 it works also with the application but not with UserCode=Custom.xxxx. Hope you can find and fix the problem?

Many thanks and best regards..
Tx

@zdohnal
Copy link
Member

zdohnal commented May 31, 2022

the "error_log.txt" is still there, between the last two screenshots.

Aha, completely missed it - I was looking among the other .txt files, but didn't look between the screenshots...

I think that the lp commands works but we want to use lpoptions to change the default when we print with the application and not via lp.

I've asked about lp command to narrow the issue - whether there is something completely wrong with lpoptions, or is there a problem with how LibreOffice uses CUPS API to do this.

So it would be great if you tried to print via lp without -o option - if lp correctly loads Custom.0850 then there will a difference how LibreOffice loads those characters, thus it will need a change in their application/or in our API which it uses.

@TxOfficial
Copy link
Author

Hi @zdohnal,

yes it works when i use lp without the -o option.

Any idea how to fix this with the CUPS API that libre use?

@zdohnal
Copy link
Member

zdohnal commented Jun 1, 2022

Ok, I've checked the code which LibreOffice uses and compared with lp command and CUPS API documentation. LibreOffice uses cupsGetDests() function, which is useful for listing printers, but once user selects a specific printer, cupsGetNamedDest() function has to be used for getting the full option set, altogether with local option overrides such as your UserCode defined by lpoptions.

From cups.dest.c:

1727  * 'cupsGetNamedDest()' - Get options for the named destination.
1728  *
1729  * This function is optimized for retrieving a single destination and should
1730  * be used instead of @link cupsGetDests2@ and @link cupsGetDest@ when you
1731  * either know the name of the destination or want to print to the default
1732  * destination.  If @code NULL@ is returned, the destination does not exist or
1733  * there is no default destination.

So I cannot fix this in CUPS - the proper fix has to happen in LibreOffice, so the app can use the correct function and get users the correct options.

It would be great if you reported this issue to Libreoffice project.

Thank you in advance!

Zdenek

@zdohnal zdohnal closed this as completed Jun 1, 2022
@zdohnal zdohnal added bug Something isn't working third-party The bug/fix is in a different project wontfix This will not be worked on and removed investigating Investigating the issue waiting for reporter There are data requested from the reporter labels Jun 1, 2022
@zdohnal zdohnal changed the title custom usercode with lpoptions command doesn't work custom usercode with lpoptions isn't shown in Libreoffice Jun 1, 2022
@michaelrsweet
Copy link
Member

@zdohnal cupsGetDests absolutely should be returning the full set of options. If not, that is a bug.

@zdohnal
Copy link
Member

zdohnal commented Jun 2, 2022

@michaelrsweet ok, then I will reinvestigate - thanks for checking!

@zdohnal zdohnal reopened this Jun 2, 2022
@zdohnal zdohnal added investigating Investigating the issue and removed wontfix This will not be worked on third-party The bug/fix is in a different project labels Jun 2, 2022
@zdohnal
Copy link
Member

zdohnal commented Jun 2, 2022

Ok, I was able to reproduce this with CUPS 2.4.2 and Libreoffice 7.3.3.2. I set Custom.0850 via lpoptions and lp command is able to apply the option into job, but Libreoffice doesn't.

Then I wrote a simple program with cupsGetDests2(), looked for ricoh printer and went through its options in gdb. Among the options was:

(gdb) p dests[6].options[22]
$31 = {name = 0x41b144 "UserCode", value = 0x405fc4 "Custom.0850"}

CUPS correctly passes the user defined value for UserCode via cupsGetDests2(), so the issue is in Libreoffice about not applying/filtering out this option.

@zdohnal zdohnal closed this as completed Jun 2, 2022
@zdohnal zdohnal closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2022
@zdohnal zdohnal added third-party The bug/fix is in a different project and removed investigating Investigating the issue labels Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working third-party The bug/fix is in a different project
Projects
None yet
Development

No branches or pull requests

3 participants