[cups-devel] how to get supported media information for a particular printer

Michael Sweet msweet at apple.com
Wed Oct 4 17:10:01 PDT 2017


> On Oct 4, 2017, at 5:59 AM, My Sadhukhan <psadhukhan at gmail.com> wrote:
> 
> Thanks for the info. 
> It seems, I need to use CUPS_DEST_FLAGS_NONE for cupsConnectDest() where the connection is made to the CUPS scheduler 
> and not CUPS_DEST_FLAGS_DEVICE which connect directly to the device associated with the destination (as CUPS_DEST_FLAGS_DEVICE is not supported prior to 2.2.4)

Right, connecting to the device is a new feature.

> Also, when I use cupsGetDestMediaCount(http, dest, info, CUPS_MEDIA_FLAGS_READY); I was getting "media count" as 0

This is because CUPS currently does not track ready media (values are typically stale), which is why CUPS_DEST_FLAGS_DEVICE was added.

> and it only works if I specify CUPS_MEDIA_FLAGS_DEFAULT (or CUPS_MEDIA_FLAGS_EXACT) and the obtained media count is 2580 as can be seen here
> http://cr.openjdk.java.net/~psadhukhan/cups-media-log.txt
> 
> It seems most of the media information is duplicated around 100 times. 

That depends on the printer, but basically the full list of media describes all of the different supported combinations of size, source, type, and margins.

> 1. 
> Is there anyway we could get unique media size entry?

Media information goes well beyond size.  If you want to limit your UI to media sizes only (not recommended!), you'll need to make your own unique list from the full one.

>  From ppd file below, I could get that we support around 60 media size(s) [30 normal, 30 fullbleed] so I would expect cups api also would give around 60 media information (and not 2500+)

Keep in mind that CUPS is an IPP implementation and exposes the flexibility of IPP wherever possible.  The current use of PPD files is an implementation artifact, and you shouldn't expect CUPS to be limited to what is supported in PPD files.

> 2. 
> By using 
> ppd_option_t *ppdFindOption("PageSize"); and 
> then from ppd_option_t*, using ppd_choice_t->text.
> we could get the user-understandable media name
> 
> A3  A4  A5 A6  B4 (JIS) B5 (JIS) B6 (JIS)  Legal 
>  8.25x14 8x10  8x10.5  Letter etc
> which normal user can use to specify which media he wants to print
> 
> but from cups api using cups_size_t->media, we are getting 
> iso_a3_297x420mm
> iso_a4_210x297mm
> Is there anyway, we can get the same human understandable media name from cups?

The cupsLocalizeDestMedia function will give you a human-readable media size name.

_________________________________________________________
Michael Sweet, Senior Printing System Engineer



More information about the cups-devel mailing list