Re: [Printing-architecture] names of paper sizes

Mignon Pelletier <[email protected]> Wed, 17 May 2023 12:24:46 -0700
Newsgroups dev.linux.lists.printing-architecture
Message-ID <[email protected]>
On 5/17/23 3:52 AM, Michael Sweet wrote:
> On May 14, 2023, at 6:04 PM, Mignon Pelletier 
> <[email protected]> wrote:
>> 2) How can I obtain the human-readable names, such as "30330 Return Address", preferably without using any deprecated APIs?
> The cupsLocalizeDestMedia function is provided for this since CUPS 2.0.

I had tried that, but cupLocalizeDestMedia() just returns a NULL 
pointer.  With this code:

     unsigned flags = 0;
     cups_size_t size;
     int i;
     int count = cupsGetDestMediaCount(CUPS_HTTP_DEFAULT,
                                       dest, info,
                                       flags);

     for (i = 0; i < count; i ++) {
         if (cupsGetDestMediaByIndex(CUPS_HTTP_DEFAULT, dest, info,
                                     i, flags,
                                     &size)) {
             const char *loc =
                 cupsLocalizeDestMedia (CUPS_HTTP_DEFAULT, dest, info,
                                        flags, &size);
             printf("  %s:\n", size.media);
             printf("     Local: %s\n", loc ? loc : "N/A");
         }
     }

I get:

   custom_12.7x47.67mm_12.7x47.67mm:
      Local: N/A
   custom_0.5x2in_0.5x2in:
      Local: N/A
   custom_0.75x2in_0.75x2in:
      Local: N/A
   custom_0.75x2.5in_0.75x2.5in:
      Local: N/A

etc.

Any idea why I'm getting NULL, or how I can troubleshoot that?

--Mignon