OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
1.08k stars 193 forks source link

How to use proper/custom page size on Android/Windows? #1017

Closed ValdikSS closed 3 months ago

ValdikSS commented 3 months ago

Not really an issue, but a question which may be useful for others as well (x-post from similar question https://github.com/michaelrsweet/lprint/issues/149)

Some printers, like Citizen CX-02 compact photo printer, use less-standard media sizes of IPP standard:

CX-02 GutenPrint PPD file contains the following sizes, using what it seems should have been PageRegion/ImageableArea for whatever reason (the dimensions are slightly larger than the described page sizes):

*PageSize B7/3.5x5:     "<</PageSize[261.120 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w144h432/2x6: "<</PageSize[297.600 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w243h432/3.375x6:     "<</PageSize[297.600 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w270h432/3.75x6:      "<</PageSize[297.600 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w288h432/4x6: "<</PageSize[297.600 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w288h432-div2/2x6*2:  "<</PageSize[297.600 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w324h432/4.5x6:       "<</PageSize[332.640 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w360h360/5x5: "<</PageSize[369.600 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w360h504/5x7: "<</PageSize[460.800 513.120]/ImagingBBox null>>setpagedevice"
*PageSize w360h504-div2/3.5x5*2:        "<</PageSize[460.800 522.240]/ImagingBBox null>>setpagedevice"
*PageSize w360h504-w360h360_w360h144/5x5+2x5:   "<</PageSize[460.800 513.120]/ImagingBBox null>>setpagedevice"
*PageSize w432h432/6x6: "<</PageSize[440.640 460.800]/ImagingBBox null>>setpagedevice"
*PageSize w432h576/6x8: "<</PageSize[460.800 584.640]/ImagingBBox null>>setpagedevice"
*PageSize w432h576-w432h432_w432h144/6x6+2x6:   "<</PageSize[460.800 584.640]/ImagingBBox null>>setpagedevice"
*PageSize w432h576-div4/2x6*4:  "<</PageSize[460.800 584.640]/ImagingBBox null>>setpagedevice"
*PageSize w432h576-div2/4x6*2:  "<</PageSize[460.800 599.520]/ImagingBBox null>>setpagedevice"
*PageSize w432h648/6x9: "<</PageSize[460.800 657.600]/ImagingBBox null>>setpagedevice"
*PageSize w432h648-div2/4.5x6*2:        "<</PageSize[460.800 672.480]/ImagingBBox null>>setpagedevice

PPD: Citizen-CX-02.txt

The following sizes are reported over IPP by CUPS. CUPS is unable to map any PageSize to a known IPP page size value, using custom everywhere:

media-supported (1setOf keyword) = custom_92.12x162.56mm_92.12x162.56mm,custom_104.99x162.56mm_104.99x162.56mm,custom_117.35x162.56mm_117.35x162.56mm,custom_130.39x162.56mm_130.39x162.56mm,custom_162.56x181.02mm_162.56x181.02mm,custom_162.56x184.23mm_162.56x184.23mm,custom_155.45x162.56mm_155.45x162.56mm,custom_162.56x206.25mm_162.56x206.25mm,custom_162.56x211.5mm_162.56x211.5mm,custom_162.56x231.99mm_162.56x231.99mm,custom_162.56x237.24mm_162.56x237.24mm
media-size-supported (1setOf collection) = {x-dimension=9212 y-dimension=16256},{x-dimension=10499 y-dimension=16256},{x-dimension=11735 y-dimension=16256},{x-dimension=13039 y-dimension=16256},{x-dimension=16256 y-dimension=18102},{x-dimension=16256 y-dimension=18423},{x-dimension=15545 y-dimension=16256},{x-dimension=16256 y-dimension=20625},{x-dimension=16256 y-dimension=21150},{x-dimension=16256 y-dimension=23199},{x-dimension=16256 y-dimension=23724}
…
media-col-database (1setOf collection) = {media-size={x-dimension=9212 y-dimension=16256} media-bottom-margin=1575 media-left-margin=0 media-right-margin=0 media-top-margin=1575},{media-size={x-dimension=10499 y-dimension=16256} media-bottom-margin=322 media-left-margin=5249 media-right-margin=0 media-top-margin=322},{media-size={x-dimension=11735 y-dimension=16256} media-bottom-margin=322 media-left-margin=0 media-right-margin=0 media-top-margin=322},{media-size={x-dimension=13039 y-dimension=16256} media-bottom-margin=1575 media-left-margin=0 media-right-margin=0 media-top-margin=1575},{media-size={x-dimension=16256 y-dimension=18102} media-bottom-margin=0 media-left-margin=1575 media-right-margin=1575 media-top-margin=0},{media-size={x-dimension=16256 y-dimension=18423} media-bottom-margin=0 media-left-margin=1575 media-right-margin=1575 media-top-margin=0},{media-size={x-dimension=15545 y-dimension=16256} media-bottom-margin=322 media-left-margin=0 media-right-margin=0 media-top-margin=322},{media-size={x-dimension=16256 y-dimension=20625} media-bottom-margin=0 media-left-margin=322 media-right-margin=322 media-top-margin=0},{media-size={x-dimension=16256 y-dimension=21150} media-bottom-margin=0 media-left-margin=322 media-right-margin=322 media-top-margin=0},{media-size={x-dimension=16256 y-dimension=23199} media-bottom-margin=0 media-left-margin=322 media-right-margin=322 media-top-margin=0},{media-size={x-dimension=16256 y-dimension=23724} media-bottom-margin=0 media-left-margin=322 media-right-margin=322 media-top-margin=0}
…
media-default (keyword) = custom_92.12x162.56mm_92.12x162.56mm
media-col-default (collection) = {media-size={x-dimension=9212 y-dimension=16256} media-bottom-margin=1575 media-left-margin=0 media-right-margin=0 media-top-margin=1575}

IPP: citizen.txt

This configuration allows to select the following paper sizes:

The printer doesn't support A4 or Letter. You won't be able to properly print on Windows.

After patching the PPD file to use proper sizes, the following is reported via IPP (notice na_ values):

media-supported (1setOf keyword) = custom_92.12x162.56mm_92.12x162.56mm,custom_104.99x162.56mm_104.99x162.56mm,na_index-4x6_4x6in,custom_117.35x162.56mm_117.35x162.56mm,custom_130.39x162.56mm_130.39x162.56mm,na_5x7_5x7in,custom_162.56x184.23mm_162.56x184.23mm,custom_162.56x181.02mm_162.56x181.02mm,custom_155.45x162.56mm_155.45x162.56mm,na_index-4x6-ext_6x8in,custom_162.56x206.25mm_162.56x206.25mm,custom_162.56x211.5mm_162.56x211.5mm,na_6x9_6x9in,custom_162.56x237.24mm_162.56x237.24mm

Patched IPP: citizen_patched.txt

This configuration allows to select the following paper sizes:

Questions:

  1. Is it possible to use all page sizes or define custom page size on Android in any way?
  2. How to use all/custom page sizes on Windows?

I've tried to add custom paper size on Windows by creating custom size in Print Server settings — it could not be selected for the printer. Also tried to print from both MS Edge (using standard browser's printing dialogue and system dialogue), as well as from Adobe Acrobat (with its own dialogue). Adding new page size (North America 6x9) by editing .gpd file did nothing, and adding a function to define user-defined page sizes as described here did not help either: there's a new option "User-Defined Size" as a paper size, but no way to set this size (probably requires more modification to .gpd).

ValdikSS commented 3 months ago

These are apparently all supported page sizes in Windows 11, extracted from C:\Windows\System32\APMon.dll (and also from here)

Spoiler ``` iso_a4_210x297mm na_letter_8.5x11in na_index-4x6_4x6in na_5x7_5x7in na_legal_8.5x14in iso_a3_297x420mm iso_a5_148x210mm na_ledger_11x17in jpn_hagaki_100x148mm oe_photo-l_3.5x5in na_govt-letter_8x10in jis_b4_257x364mm jis_b5_182x257mm om_dsc-photo_89x119mm om_photo-l_89x119mm om_card_54x86mm na_index-3x5_3x5in na_index-5x8_5x8in na_executive_7.25x10.5in iso_a6_105x148mm na_invoice_5.5x8.5in oe_square-photo_5x5in oe_square-photo_4x4in om_square-photo_89x89mm oe_photo-10r_10x12in oe_14x17_14x17in oe_business-card_2x3.5in om_business-card_55x85mm om_business-card_55x91mm na_monarch_3.875x7.5in na_number-9_3.875x8.875in na_number-10_4.125x9.5in iso_dl_110x220mm iso_b5_176x250mm iso_c4_229x324mm iso_c5_162x229mm jpn_kaku2_240x332mm jpn_chou3_120x235mm jpn_chou4_90x205mm jpn_chou40_90x225mm jpn_you4_105x235mm ```
michaelrsweet commented 3 months ago

OK, so first the Gutenprint PPD paper size dimensions are screwy - 4x6 is 4.13x6.4, for example - which is why you are seeing such strange sizes reported from CUPS. Nothing we can do here because we can only expose what the driver is reporting and having PaperDimension not matching the size names is only going to cause problems. Report that bug to the Gutenprint folks, please.

WRT what Android/Windows support for media sizes, we have reported this issue to Microsoft and Mopria before and they have promised to provide a fix, but I don't have an ETA and, again, there isn't anything we can do to "fix" this since we don't control their software. They have similar issues with "oddball" resolutions (like 203dpi/8-dots/mm which is a VERY common resolution for thermal printers) and other otherwise standard IPP features/values. They are working on it but right now their primary focus is on office/document printing and not photo/label/receipt printing.

Wish I had a better answer for you...

ValdikSS commented 3 months ago

we have reported this issue to Microsoft and Mopria before and they have promised to provide a fix

Did you report the issue to MS in public, on forum or via Feedback Hub? Do you have a link?

there isn't anything we can do to "fix" this since we don't control their software

Well maybe someone knows a driver which have all the functions for some existing printer, which still works according to Mopria standards, which could be reused? Windows supports custom page sizes (this is a standard feature of almost all proprietary driver), but this option should be added to the .gpd file.

Could you pin this issue for more visibility please?

//gutenprint bug: https://sourceforge.net/p/gimp-print/mailman/gimp-print-devel/thread/93406d3f-b877-46be-a2c8-de73924f90ef%40valdikss.org.ru/#msg58801121

michaelrsweet commented 3 months ago

we have reported this issue to Microsoft and Mopria before and they have promised to provide a fix

Did you report the issue to MS in public, on forum or via Feedback Hub? Do you have a link?

I had reported both publicly and via direct email; I don't have a public feedback URL (the only one I can find only works on Windows and only when I am logged in, so I don't think that would be useful...)

there isn't anything we can do to "fix" this since we don't control their software

Well maybe someone knows a driver which have all the functions for some existing printer, which still works according to Mopria standards, which could be reused? Windows supports custom page sizes (this is a standard feature of almost all proprietary driver), but this option should be added to the .gpd file.

OK, so AirPrint, Mopria, IPP Everywhere, and Wi-Fi Direct Print Services (the various "driverless" standards in rough order of popularity/usage) all use a single "driver" on the various Client OS's. Android is the only platform that has interchangeable print providers, but I can't recommend a specific one since the "best" varies based on what version of Android you are using... :/

For Windows, please do file your own issues with Microsoft to raise awareness - they've been very responsive when I've reported issues, and they are keen to have good IPP support since that is what Azure depends on...

ValdikSS commented 3 months ago

I don't have a public feedback URL (the only one I can find only works on Windows and only when I am logged in, so I don't think that would be useful...)

Yes, this is now their Feedback Hub works, only in their app. Please give a link, I could at least "me too" it.

all use a single "driver" on the various Client OS's

Yes, but there are Print Support Application (PSAs) which add additional options, including custom page size. Maybe there is such app which could be installed for any IPP printer, without any bound to the manufacturer or model? This is what I'm looking for.

Siedlerchr commented 3 months ago

These are apparently all supported page sizes in Windows 11, extracted from C:\Windows\System32\APMon.dll (and also Spoiler

I have a Windows 11 Insider build 25 ARM version from last September or so and there I can choose custom paper sizes, so I would like to compare the content of the dlls. How did you extract the sizes from the dll? ResourceHacker?

Siedlerchr commented 3 months ago

This is the printer settings from Microsoft Windows 11 Home Insider Preview, and you can see the custom paper format: Version 10.0.25967 Build 25967

printerWindows11ARm

ValdikSS commented 3 months ago

@Siedlerchr, interesting, thanks for sharing. Could you share your .ppd as well? I'll try to install the latest Insider Preview and test it.

ValdikSS commented 3 months ago

Updated to Windows 11 home 24H2 26120.1330 (dev channel) — no changes whatsoever. This printer reports both custom_min_ /custom_max_ in media-supported and paper x/y range in media-size-supported.

Screenshot_20240801_115019-fs8

ValdikSS commented 3 months ago

@Siedlerchr, could you please share .ppd and maybe IPP information?

Siedlerchr commented 3 months ago

I have impemented a virtual IPP printer server (for work) so I have full control over the attributes. Obviously, I cannot share everything here, but here is an excerpt from my media stuff:

Basically, I put my custom paper format in every media* related stuff (media col, media col db, media-col-ready) I figured most of the stuff out via wireshark by observing a real printer (Wireshark has a filter for ipp). That involed a lot of trial and error.

e.g.

media-supported (1setOf keyword): 'na_index-4x6_4x6in','om_84.67x63.50-label_84.67x63.50mm'
name: media-supported
keyword value: na_index-4x6_4x6in
keyword value: om_84.67x63.50-label_84.67x63.50mm

  name: media-col-database
            collection {media-bottom-margin,media-left-margin,media-right-margin,media-size{x-dimension,y-dimension},media-size-name,media-source,media-top-margin,media-type}
                memberAttrName: media-bottom-margin
                integer value: 1
                memberAttrName: media-left-margin
                integer value: 1
                memberAttrName: media-right-margin
                integer value: 1
                memberAttrName: media-size
                collection {x-dimension,y-dimension}
                    memberAttrName: x-dimension
                    integer value: 10160
                    memberAttrName: y-dimension
                    integer value: 15240
                memberAttrName: media-size-name
                keyword value: na_index-4x6_4x6in
                memberAttrName: media-source
                keyword value: main-roll
                memberAttrName: media-top-margin
                integer value: 1
                memberAttrName: media-type
                keyword value: labels
            collection {media-bottom-margin,media-left-margin,media-right-margin,media-size{x-dimension,y-dimension},media-size-name,media-source,media-top-margin,media-type}
                memberAttrName: media-bottom-margin
                integer value: 0
                memberAttrName: media-left-margin
                integer value: 0
                memberAttrName: media-right-margin
                integer value: 0
                memberAttrName: media-size
                collection {x-dimension,y-dimension}
                    memberAttrName: x-dimension
                    integer value: 8467
                    memberAttrName: y-dimension
                    integer value: 6350
                memberAttrName: media-size-name
                keyword value: om_84.67x63.50-label_84.67x63.50mm
                memberAttrName: media-source
                keyword value: alternate-roll
                memberAttrName: media-top-margin
                integer value: 0
                memberAttrName: media-type
                keyword value: labels