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

Wrong media limits for A4 paper using HP OfficeJet 7740 Pro due ignoring duplicated sizes in ppdCacheCreateWithPPD() #29

Closed
piratenpanda opened this issue Oct 24, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@piratenpanda
Copy link

Describe the bug
When printing A4 pages with the printer a wrong media size is used. See https://bugs.launchpad.net/ubuntu/+source/cups/+bug/2040270 for more details. I have the same issue on arch

To Reproduce
Steps to reproduce the behavior:
Print A4 pages with the HP OfficeJet 7740 Pro.
Media has wrong offset as the printer thinks the paper has media limits of: 0.42 x 0.42 to 27.52 x 35.14 cm

Expected behavior
Print normal A4 pages

System Information:

  • OS and its version: latest Arch Linux, above linked bug is on Ubuntu 23.04
  • Application: Evince 45 and Firefox tested
  • CUPS version 2.4.7
@zdohnal
Copy link
Member

zdohnal commented Nov 24, 2023

Hi,

please follow https://github.com/OpenPrinting/cups/blob/master/REPORTING_ISSUES.md and provide the necessary information - like CUPS debug2 logs when you print and try to reproduce via CUPS CLI. Especially it would be interesting to see how the printer behaves with everywhere driver without hplip PPD.

You can install it (if you have IPP enabled on your printer - the Ubuntu reporter has it, but Idk about you - please enable it if you don't):

$ lpadmin -p <arbitrary name for the printer> -v ipp://<printer-ip>/ipp/print -m everywhere -E && sleep 3 && ls -lah /etc/cups/ppd/<chosen printer name>.ppd

If the ppd file exists, IPP Everywhere installation went ok and you can try print A4 via it.

EDIT:
Of course I forgot to escape < > again...
EDIT2:
@zdohnal Line with 3 backticks before and after a block of code lines and no escaping needed, or 1 backtick before and after a piece of code in the middle of a line

@piratenpanda
Copy link
Author

piratenpanda commented Nov 25, 2023

error_log.txt
log.txt
lpstat-e.txt
lpstat-t.txt
lpstat-v.txt

PPD: HP_OfficeJet_Pro_7740_series_F712A4.zip

d0031-001.txt

I tried to run lpadmin -p -v ipp://192.168.178.21/print -m everywhere -E && sleep 3 && ls -lah /etc/cups/ppd/.ppd but this does not work. What do I need to change?

@zdohnal
Copy link
Member

zdohnal commented Nov 27, 2023

I'm sorry, I didn't realize markdown removed some parts of the command... and from the other files I see you either don't have mDNS working on your machine, or you have disabled IPP on the printer (because I don't see a temporary queue for your printer in lpstat -e - Ubuntu reporter had implicitclass printer there, which indicates the printer works via IPP), thus the command lpadmin might not work if you disabled IPP - you can check if everything is ok for IPP Everywhere by:

$ ipptool -tv ipp://192.168.178.21/ipp/print get-printer-attributes.test

if it fails with the error "Host is down", check IPP support in your printer, enable it and try again. If the result is [FAIL], your printer does not support properly IPP Everywhere and you can ignore the lpadmin command.

The command should like like this, if your printer's IP is 192.168.178.21 and you choose to name your destination 'test'

$ lpadmin -p test -v ipp://192.168.178.21/ipp/print -m everywhere -E && sleep 3 && ls -lah /etc/cups/ppd/test.ppd

and then try to reproduce the issue with this printer.

==================================================================================

From the error_log I see you printed a test page and there are no settings regarding page size:

D [25/Nov/2023:10:46:59 +0100] [Job 31] argv[5]="job-uuid=urn:uuid:4b2930c2-e125-3edb-78c6-ce8fde1704eb job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1700905619 time-at-processing=1700905619"

AFAIK if there are no settings from application, printer's default (may de server default or driver default) should be applied by scheduler or filter.

Can you attach .txt file with outputs from

lpoptions -p HP_OfficeJet_Pro_7740_series_F712A4 -l
and

lpoptions -p HP_OfficeJet_Pro_7740_series_F712A4 ?

What application did you use for printing the test page?

Can you try to print a normal A4 page, once without settings and then with settings? f.e.:

lp -d HP_OfficeJet_Pro_7740_series_F712A4 <some A4 document>

and

lp -d HP_OfficeJet_Pro_7740_series_F712A4 -o PageSize=A4 <some A4 document>

Do those two work? Printing test page uses a different filter functions, which can influence the output.

In any case, thank you for information!

@piratenpanda
Copy link
Author

Thanks for the reply. Here is some more:
printer-attributes.txt

Creating the test printer worked fine and printing a test page has the proper page dimensions. Everything looks fine.

lpoptions-l.txt

lpoptions.txt

lp -d HP_OfficeJet_Pro_7740_series_F712A4 <some A4 document>
produced a document with wrong page dimensions and wrong padding/borders, same for the other command as well unfortunately

@zdohnal
Copy link
Member

zdohnal commented Nov 27, 2023

I've looked deeper into the error_log to find any possible page size related logging and I found an interesting log:

D [25/Nov/2023:10:46:59 +0100] [Job 31] cfFilterGhostscript: Ghostscript command line: gs -dQUIET -dSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE -dNOMEDIAATTRS -dUsePDFX3Profile -sstdout=%stderr -sOutputFile=%stdout -sDEVICE=cups -sMediaType=Plain -sOutputType=0 -r600x600 -dMediaPosition=1 -dDEVICEWIDTHPOINTS=792 -dDEVICEHEIGHTPOINTS=1008 -dcupsBitsPerColor=8 -dcupsColorOrder=0 -dcupsColorSpace=1 -dcupsInteger0=26 -scupsRenderingIntent=auto -scupsPageSizeName=11x14 -dcupsManualCopies -I/usr/share/cups/fonts -c \'<</.HWMargins[11.990551 11.990551 11.990540 11.990540] /Margins[0 0]>>setpagedevice\' -f -_

The interesting part is -scupsPageSizeName=11x14 which seems like 11x14in from the driver - it looks like universal filter from cups-fillters guesses incorrect size - @tillkamppeter would you mind looking into it?

@piratenpanda
Copy link
Author

As a quick note: I made myself an Ubuntu LTS stick and printing from that works just fine. So maybe this bug got introduced later.

@zdohnal
Copy link
Member

zdohnal commented Nov 28, 2023

Ok, I found out the reason why it behaves this way - the HPLIP PPD has two size options with the same length and width:

*PageSize IndexCardA4/Index Card A4 8.27x11.69in : "<</cupsInteger0 26/PageSize[595.44 841.68]/ImagingBBox null>>setpagedevice"
...
*PageSize A4/A4 : "<</cupsInteger0 26/PageSize[595.44 841.68]/ImagingBBox null>>setpagedevice"

and ppdCacheCreateWithPPD() (which code is taken from CUPS, but it was not used in filters previously AFAIK, thus this didn't happen) ignores any additional size options which have the same sizes - however, the thrown away option A4 is as a default one, causing the filter to use the first size from the available list - 11x15.

@piratenpanda can you try to remove/comment out with *% the first line I mentioned and reinstall the printer with changed file like this:

$ sudo lpadmin -p HP_OfficeJet_Pro_7740_series_F712A4 -v socket://192.168.178.21 -P <path to the changed file> -E

and see if it helps?

@michaelrsweet @tillkamppeter it looks like HPLIP thought /cupsInteger makes a difference in CUPS and let the driver to have two size options with the same size, but I don't see this keyword parsed in the function - is it a driver issue to depend on it? And is it correct behavior to drop any duplicated size options from PPD?

@piratenpanda
Copy link
Author

With the changed ppd it works just fine

@zdohnal zdohnal added the bug Something isn't working label Nov 28, 2023
@zdohnal zdohnal changed the title Wrong media limits for A4 paper using HP OfficeJet 7740 Pro Wrong media limits for A4 paper using HP OfficeJet 7740 Pro due ignoring duplicated sizes in ppdCacheCreateWithPPD() Nov 28, 2023
@zdohnal
Copy link
Member

zdohnal commented Nov 28, 2023

Moving to libppd - since the code which is in use and causes the issue lives there, but the possible fix will have to happen in CUPS as well.

@zdohnal zdohnal transferred this issue from OpenPrinting/cups Nov 28, 2023
@michaelrsweet
Copy link
Member

Yeah I'm not sure what they are trying to do but it isn't right, even for regular PPDs. Both use the same commands and the cupsInteger0 value (26) is the PCL media size value for A4... Probably the right fix is to exclude any sizes that use a non-standard name for a standard size.

zdohnal added a commit to zdohnal/libppd that referenced this issue Nov 29, 2023
Previously, if there were two sizes with the same size, but different
names in PPD, the second was ignored during generating sizes for PPD
cache. This behavior breaks already broken PPDs, which provide two or
more different size names for the same width and length (which is
incorrect), and if the ignored size was the PPD default (such as A4),
user couldn't print a test page.

After this fix, we use PPD size name from CUPS if the size is
standarized.

Fixes OpenPrinting#29
@zdohnal
Copy link
Member

zdohnal commented Nov 29, 2023

Thinking about it deeper - what if the HPLIP (or any other) filter does depend on using non-standard size name? In such cases we might need to keep all the sizes, even the duplicate ones... WDYT? @tillkamppeter @michaelrsweet

@zdohnal
Copy link
Member

zdohnal commented Nov 29, 2023

In case my idea is not useful, I've created PR for Mike's suggestion - use always standard name if the size is standardized.

@tillkamppeter
Copy link
Member

Letting ppd-cache.c keep duplicate sizes would preserve the non-standard names which some sizes got in addition, but is it conforming with IPP standards to have duplicate page sizes in the list?

We can also have:

  1. Non-duplicate paper sizes with non-standard name
  2. The default page size's name is non-standard, as the only incarnation of that size has a non-standard name, or the incarnation with non-standard name is selected as default
  3. All incarnations of a given size have non-standard names

By replacing all entries of each page size by one entry with standard name and changing the default page sizes name to the standard nameof the size referenced by it should solve all the above problems.

Only if the driver needs the non-standard names one needs to somehow preserve them, for example by keeping the duplicate sizes ...

zdohnal added a commit to zdohnal/libppd that referenced this issue Aug 2, 2024
@szlt5 found out libppd does not use the same delta as CUPS, which
causes filters to use first size from the array, because the similar
size according PWG (which recommends max delta 0.5mm) is not matched as
useable.

Related to OpenPrinting#29, but not fixing the original issue.
tillkamppeter pushed a commit that referenced this issue Aug 2, 2024
@szlt5 found out libppd does not use the same delta as CUPS, which
causes filters to use first size from the array, because the similar
size according PWG (which recommends max delta 0.5mm) is not matched as
useable.

Related to #29, but not fixing the original issue.
zdohnal added a commit to zdohnal/libppd that referenced this issue Aug 2, 2024
…ting#29)

@szlt5 found out libppd does not use the same delta as CUPS, which
causes filters to use first size from the array, because the similar
size according PWG (which recommends max delta 0.5mm) is not matched as
useable.

Fixes OpenPrinting#29
@zdohnal zdohnal closed this as completed in d53abd9 Aug 2, 2024
@vijay-prema
Copy link

Thank you for this. After years of working just fine, I suddenly ran into the issue on Ubuntu, and the comment out suggestion in the PPD fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants