Skip to contentSkip to conversation

names of paper sizes

Printing-architecture Mignon Pelletier 3 participants 7 messages May 14, 2023 – Jun 8, 2023

lore
Share & tools
lore
#0 lore raw

I'm confused about the many names that a paper size can have.

If I query my DYMO LabelWriter 450 Turbo with code like this:

        ipp_attribute_t *media = cupsFindDestSupported(CUPS_HTTP_DEFAULT, dest, info, CUPS_MEDIA);
        int i, count = ippGetCount(media);

        puts("media supported:");
        for (i = 0; i < count; i ++)
            printf("  %s\n", ippGetString(media, i, NULL));

Then I get names like this:

  custom_54.19x22.27mm_54.19x22.27mm
  custom_25.4x54.02mm_25.4x54.02mm
  custom_1x1in_1x1in
  custom_2.25x1.25in_2.25x1.25in
  custom_0.75x2in_0.75x2in
  custom_41.32x88.9mm_41.32x88.9mm

However, if I run "lpoptions -p LabelWriter-450-Turbo -l", I get names like this:

PageSize/Media Size: w154h64 w72h154 w72h72 w162h90 w54h144 w118h252 w167h188 w79h252 w167h252 *w167h288 w154h198 w82h248 w154h64.1 w79h252.1 w102h252 w154h286 w154h198.1 w54h424 w131h221 w57h248

I checked the source code for lpoptions, and it is using ppdOpenFile() and related functions, rather than cupsFindDestSupported().  I'm curious why these different APIs are returning different names for the paper sizes.  Also, my understanding is that the PPD functions are deprecated and are removed in CUPSv3?

Looking at LabelWriter-450-Turbo.ppd, the paper sizes are listed like this:

*PaperDimension w102h252/30321 Large Address: "101.28 251.04" *PaperDimension w154h286/30323 Shipping: "153.12 285.84" *PaperDimension w154h198.1/30324 Diskette: "153.12 198.00" *PaperDimension w54h424/30325 Video Spine: "54.00 423.12" *PaperDimension w131h221/30326 Video Top: "130.56 220.56" *PaperDimension w57h248/30327 File Folder: "56.40 247.44" *PaperDimension w54h144.1/30330 Return Address: "54.00 144.00"

I can see that the name before the slash is what is being returned by lpoptions.  However, what I really want is the name after the slash, such as "30330 Return Address", because this is by far the most human-readable.

So, my questions are:

1) Where are the names reported by cupsFindDestSupported() coming from?
2) How can I obtain the human-readable names, such as "30330 Return Address", preferably without using any deprecated APIs?

Thanks,

--Mignon

#1 lore raw

Mignon,

Quoted 24 lines · Mignon Pelletier

I'm confused about the many names that a paper size can have.

If I query my DYMO LabelWriter 450 Turbo with code like this:

        ipp_attribute_t *media =
            cupsFindDestSupported(CUPS_HTTP_DEFAULT, dest, info,
                                  CUPS_MEDIA);
        int i, count = ippGetCount(media);

        puts("media supported:");
        for (i = 0; i < count; i ++)
            printf("  %s\n", ippGetString(media, i, NULL));

Then I get names like this:

custom_54.19x22.27mm_54.19x22.27mm
custom_25.4x54.02mm_25.4x54.02mm
custom_1x1in_1x1in
custom_2.25x1.25in_2.25x1.25in
custom_0.75x2in_0.75x2in
custom_41.32x88.9mm_41.32x88.9mm

Quoted 5 lines

However, if I run "lpoptions -p LabelWriter-450-Turbo -l", I get names like this:

PageSize/Media Size: w154h64 w72h154 w72h72 w162h90 w54h144 w118h252 w167h188 w79h252 w167h252 *w167h288 w154h198 w82h248 w154h64.1 w79h252.1 w102h252 w154h286 w154h198.1 w54h424 w131h221 w57h248

Correct. The names you get via IPP are PWG self-describing media size names, while the names reported by lpoptions are the Adobe PPD media size names (a much older "standard"). Both are accepted by the current version of CUPS but going forward only PWG media size names will work.

Quoted 2 lines

...
1) Where are the names reported by cupsFindDestSupported() coming from?

From cupsd, which converts the PPD names to PWG names. Localization information is placed in a separate .strings file for the queue that can be queried by the application.

Quoted 1 line

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.

________________________
Michael Sweet

#2 lore raw
Quoted 3 lines · Michael Sweet
Quoted 1 line · Mignon Pelletier

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

#3 lore raw

Mignon,

It might help to know what version of CUPS and what OS/Linux distribution you are using?

Quoted 39 lines · Mignon Pelletier
Quoted 3 lines · Michael Sweet
Quoted 1 line · Mignon Pelletier

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

Quoted 6 lines

etc.

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

--Mignon

________________________
Michael Sweet

#4 lore raw
Quoted 1 line · Michael Sweet

It might help to know what version of CUPS and what OS/Linux distribution you are using?

Oh, yes, sorry.  I'm on Ubuntu 20.04.6 LTS, which has CUPS 2.3.1.

--Mignon

#5 lore raw

Mignon,

Sorry for the delay, I've been doing some testing with CUPS 2.4.x and am getting the localized sizes. On Ubuntu 20.04 I get dimensional names (8.5 x 11 " for US Letter, etc.) but the names *are* getting localized...

Quoted 9 lines · Mignon Pelletier
Quoted 1 line · Michael Sweet

It might help to know what version of CUPS and what OS/Linux distribution you are using?

Oh, yes, sorry. I'm on Ubuntu 20.04.6 LTS, which has CUPS 2.3.1.

--Mignon

________________________
Michael Sweet

#6 lore raw

Le jeudi 08 juin 2023 à 13:49 -0400, Michael Sweet via Printing- architecture a écrit :

Quoted 6 lines

Mignon,

Sorry for the delay, I've been doing some testing with CUPS 2.4.x and am getting the localized sizes.  On Ubuntu 20.04 I get dimensional names (8.5 x 11 " for US Letter, etc.) but the names *are* getting localized...

Just for the record I had such issue long time ago (3 or 4 years). I did report it and you said that you also get localized name on your side. For sure I'm missing something as Mignon probably.

I haven't tried since long time though...

Regards,

Signature · 7 lines
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://photos.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B