Skip to content

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

Closed

Description

@piratenpanda

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

Activity

  1. zdohnal commented on Nov 24, 2023

    @zdohnal
    Member

    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

  2. piratenpanda commented on Nov 25, 2023

    @piratenpanda
    Author

    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?

  3. zdohnal commented on Nov 27, 2023

    @zdohnal
    Member

    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!

  4. piratenpanda commented on Nov 27, 2023

    @piratenpanda
    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

  5. zdohnal commented on Nov 27, 2023

    @zdohnal
    Member

    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?

  6. piratenpanda commented on Nov 27, 2023

    @piratenpanda
    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.

  7. zdohnal commented on Nov 28, 2023

    @zdohnal
    Member

    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?

  8. piratenpanda commented on Nov 28, 2023

    @piratenpanda
    Author

    With the changed ppd it works just fine

  9. 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()[/+] on Nov 28, 2023
  10. zdohnal commented on Nov 28, 2023

    @zdohnal
    Member

    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.

  11. transferred this issue fromOpenPrinting/cupson Nov 28, 2023
  12. michaelrsweet commented on Nov 28, 2023

    @michaelrsweet
    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.

  13. added a commit that references this issue on Nov 29, 2023
    b6fa5b2
  14. zdohnal commented on Nov 29, 2023

    @zdohnal
    Member

    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

  15. zdohnal commented on Nov 29, 2023

    @zdohnal
    Member

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

  16. tillkamppeter commented on Dec 2, 2023

    @tillkamppeter
    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 ...

  17. added a commit that references this issue on Aug 2, 2024
    a0a3904
  18. added a commit that references this issue on Aug 6, 2024
    d53abd9
  19. vijay-prema commented on Dec 6, 2024

    @vijay-prema

    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

  20. Pivert commented on Jan 7, 2025

    @Pivert

    Hi,

    Finally, I have a solution. For now, it was easier to remove the line in the ppd file. Here is the diff:

    # diff /etc/cups/ppd/OfficeJet_Pro_7740.ppd.O /etc/cups/ppd/OfficeJet_Pro_7740.ppd
    2c2
    < *%%%% PPD file for HP Officejet Pro 7740 Series with CUPS.
    ---
    > *%%%% PPD file for HP Officejet Pro 7740 Series with CUPS. (Pivert Edit)
    279d278
    < *PageSize IndexCardA4/Index Card A4 8.27x11.69in : "<</cupsInteger0 26/PageSize[595.44 841.68]/ImagingBBox null>>setpagedevice"
    

    Thanks for the tip !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions