CUPS and PPD
Hello!
I'm not sure this is the right list, if not please let me know.
I've seen that the CUPS PPD API is being deprecated, so I'm trying to move away from it.
But for the MediaType list I cannot find a way without PPD API. Currently the code is something like:
const char *PPDFile = cupsGetPPD(printer_name);
ppd_file_t *ppd = ppdOpenFile(PPDFile);
if (ppd)
{
ppd_option_t *opt = ppdFindOption(ppd, "MediaType"); if (opt)
{
ppd_choice_t *choice = opt->choices;
for (int k=0; k<opt->num_choices; k++)
{
... use choice->text here ...What would be the equivalent without using the PPD API?
Any pointer appreciated as I've not found a solution at this stage. I'm sure I'm just missing something obvious...
Thanks,
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Pascal,
The CUPS destination API is the replacement, specifically the cupsGetDestMedia* functions. The current CUPS Programming Manual shows how to use it.
FWIW, media type, size, and source are combined with the new API and the typical usage is to show the ready (loaded) media. You can also look for the supported "media-type" values with the cupsDestFindSupported function, in order to specify it separately.
Quoted 30 lines · Pascal Obry
Hello!
I'm not sure this is the right list, if not please let me know.
I've seen that the CUPS PPD API is being deprecated, so I'm trying to move away from it.
But for the MediaType list I cannot find a way without PPD API. Currently the code is something like:
const char *PPDFile =
cupsGetPPD(printer_name);
ppd_file_t*ppd = ppdOpenFile(PPDFile);if (ppd)
{ ppd_option_t *opt = ppdFindOption(ppd, "MediaType"); if (opt) { ppd_choice_t *choice = opt->choices; for (int k=0; k<opt->num_choices; k++) { ... use choice->text here ...
Quoted 19 lines
What would be the equivalent without using the PPD API?
Any pointer appreciated as I've not found a solution at this stage. I'm sure I'm just missing something obvious...
Thanks,
Signature · 11 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B _______________________________________________ Printing-architecture mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/printing-architecture
_________________________________________________________
Michael Sweet, Senior Printing System Engineer
Hello Michael,
Thanks for the quick response!
Quoted 3 lines
You can also
look for the supported "media-type" values with the cupsDestFindSupported function, in order to specify it separately.
That's why I was looking for :)
Still a little issue. With the following code:
ipp_attribute_t *attr = cupsFindDestSupported(hcon, dest, info, "media-type");
if (attr)
{
for (int k=0; k<ippGetCount(attr); k++)
{
printf (" %s\n", ippGetString(attr, k, NULL));I can list the supported paper, but as code:
stationery
epson-inkjet-paper--5
epson-matte-heavy-archival--5
fineart-paper-smooth--5
epson-photo-glossy--5
epson-premium-glossy-luster--5
epson-proof-satin--5
transparency
kodak-premium--5
ilford-omnijet--5
fuji-premium-photo--5
tetenal-photo-quality-glossy-matte--5
custom-1002--5
The last one is in fact "Canson Infinity Baryta". How can I retrieve this human readable name?
Thanks,
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
cupsLocalizeDestOption will give you the localized string, if the printer supplies one.
(but prior to CUPS 2.3 you need to connect to the device/printer to get the localized string for vendor-specific names...)
Quoted 38 lines · Pascal Obry
Hello Michael,
Thanks for the quick response!
Quoted 3 lines
You can also
look for the supported "media-type" values with the cupsDestFindSupported function, in order to specify it separately.That's why I was looking for :)
Still a little issue. With the following code:
ipp_attribute_t *attr = cupsFindDestSupported(hcon, dest, info, "media-type"); if (attr) { for (int k=0; k<ippGetCount(attr); k++) { printf (" %s\n", ippGetString(attr, k, NULL));I can list the supported paper, but as code:
stationery
epson-inkjet-paper--5
epson-matte-heavy-archival--5
fineart-paper-smooth--5
epson-photo-glossy--5
epson-premium-glossy-luster--5
epson-proof-satin--5
transparency
kodak-premium--5
ilford-omnijet--5
fuji-premium-photo--5
tetenal-photo-quality-glossy-matte--5
custom-1002--5
Quoted 13 lines
The last one is in fact "Canson Infinity Baryta". How can I retrieve this human readable name?
Thanks,
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
_________________________________________________________
Michael Sweet, Senior Printing System Engineer
Hi Michael,
Quoted 2 lines
cupsLocalizeDestOption will give you the localized string, if the printer supplies one.
Ok.
Quoted 2 lines
(but prior to CUPS 2.3 you need to connect to the device/printer to get the localized string for vendor-specific names...)
I see, but now using:
http_t *hcon = cupsConnectDest(dest, CUPS_DEST_FLAGS_DEVICE, 2000, &cancel, resource, sizeof(resource), NULL, (void *)NULL);
Makes attr null in the following code:
ipp_attribute_t *attr = cupsFindDestSupported(hcon, dest, info, "media-type");
With CUPS_DEST_FLAGS_NONE I can list media.
I'm on CUPS 2.2.6.
Any idea?
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Pascal,
First, make sure you've gotten a copy of the attributes from the device with cupsCopyDestInfo.
Second, make sure your printer actually reports the media types separately; the following command will show:
ipptool -tv PRINTER-URI get-printer-attributes.test | grep media-type-supported
(the CUPS media APIs help insulate you from dealing with these things BTW...)
Quoted 18 lines · Pascal Obry
Hi Michael,
Quoted 2 lines
cupsLocalizeDestOption will give you the localized string, if the printer supplies one.
Ok.
Quoted 2 lines
(but prior to CUPS 2.3 you need to connect to the device/printer to get the localized string for vendor-specific names...)
I see, but now using:
http_t *hcon = cupsConnectDest(dest, CUPS_DEST_FLAGS_DEVICE, 2000, &cancel, resource, sizeof(resource), NULL, (void *)NULL);Makes attr null in the following code:
Quoted 17 lines
ipp_attribute_t *attr = cupsFindDestSupported(hcon, dest, info, "media-type");With
CUPS_DEST_FLAGS_NONEI can list media.I'm on CUPS 2.2.6.
Any idea?
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
_________________________________________________________
Michael Sweet, Senior Printing System Engineer
Michael,
Quoted 2 lines
First, make sure you've gotten a copy of the attributes from the device with cupsCopyDestInfo.
Right, this is done on my code.
Quoted 5 lines
Second, make sure your printer actually reports the media types separately; the following command will show:
ipptool -tv PRINTER-URI get-printer-attributes.test | grep media-
type-supported
$ ipptool -tv http://localhost:631/printers/Epson_Stylus_Pro_3880 get-printer-attributes.test | grep media-type-supported media-type-supported (1setOf keyword) = stationery,postcard,photographic-glossy,transparency,envelope,back- film,photographic-matte,matte-heavy,stationery-inkjet,stationery- coated,photo,photographic-glossy,semigloss,luster,archival-matte,water- color-radiant,photographic-glossy,ilford,color-life,other
Quoted 2 lines
(the CUPS media APIs help insulate you from dealing with these things BTW...)
I'm certainly missing some information here. I've only worked with the PPD API, so all this is new to me and I do not find lot of documentation around.
Thanks,
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Hello Michael,
Making progress, I just found out that I can retrieve the attributes when using cupsGetDestWithURI() but not cupsGetDests() and cupsGetDest() if CUPS_DEST_FLAGS_DEVICE is used.
That is:
cups_dest_t *dests;
int num_dests = cupsGetDests(&dests);
cups_dest_t *dest = cupsGetDest(printer_name, NULL, num_dests, dests);Does not work, as reported previously cupsFindDestSupported returns null. But I can list attributes with:
cups_dest_t *dest = cupsGetDestWithURI(NULL, printer_uri);
Yet, the localized is still not working. So I'm not sure how to move away from PPD API for media-type. This is quite important to have the proper paper names listed here.
I have tried for an Epson 3880 with the gutenprint driver or the turboprint driver. Do you see something I'm missing?
Thanks,
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Hello Michael,
Sorry to bother you again with this. But now I'm not sure we are talking about the same thing. The get cupsLocalizeDestValue() is to handle the translation in different language I suppose, but what I want is to get the "text" field for a *MediaType line.
With the PPD API one could do:
ppd_option_t *opt = ppdFindOption(ppd, "MediaType");
if (opt)
{
ppd_choice_t *choice = opt->choices;
for (int k=0; k<opt->num_choices; k++)
{
printf ("PPD: media type %s | %s\n", choice->choice,
choice->text);
choice++;
}And the choice->choice above is "Luster" in "Luster/Premium Luster Photo Paper" (see PPD def just below) and choice->text is the second part (human readable string) after the / so "Premium Luster Photo Paper".
*MediaType Luster/Premium Luster Photo Paper:
"<</MediaType(Luster)>>setpagedevice"
And what I'm looking for is a way to get the human readable part without resorting on the PPD API. I've tried many things, but fails to get this value.
Is that possible without the PPD API?
Thanks,
Signature · 8 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://photos.obry.net http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Pascal,
The cupsLocalizeDestValue API is there to get the equivalent of the PPD choice text field. However, for a driver-based queue we currently do not generate the strings file (being tracked by Issue #5194) so unless it is a standard choice you'll just get the unlocalized (US english) keyword string.
FWIW, I think it would be useful for you to do development with a printer that actually supports IPP, if for any other reason to see where things are going and the functionality that is available on a modern printer without additional driver software...
Quoted 22 lines · Pascal Obry
Hello Michael,
Sorry to bother you again with this. But now I'm not sure we are talking about the same thing. The get
cupsLocalizeDestValue()is to handle the translation in different language I suppose, but what I want is to get the "text" field for a *MediaType line.With the PPD API one could do:
ppd_option_t *opt = ppdFindOption(ppd, "MediaType"); if (opt) { ppd_choice_t *choice = opt->choices; for (int k=0; k<opt->num_choices; k++) { printf ("PPD: media type %s | %s\n", choice->choice, choice->text); choice++; }And the
choice->choiceabove is "Luster" in "Luster/Premium Luster Photo Paper" (see PPD def just below) andchoice->textis the second part (human readable string) after the / so "Premium Luster Photo Paper".
Quoted 17 lines
*MediaType Luster/Premium Luster Photo Paper: "<</MediaType(Luster)>>setpagedevice"
And what I'm looking for is a way to get the human readable part without resorting on the PPD API. I've tried many things, but fails to get this value.
Is that possible without the PPD API?
Thanks,
Signature · 8 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://photos.obry.net <http://photos.obry.net/> http://www.obry.net <http://www.obry.net/> gpg --keyserver keys.gnupg.net <http://keys.gnupg.net/> --recv-key F949BD3B
_________________________________________________________
Michael Sweet, Senior Printing System Engineer
Re: [Printing-architecture] CUPS and Borderless
Hello Michael,
I'm wondering what is the solution to check, using the CUPS IPP API, if a printer does support borderless printing?
Is that with cupsGetDestMediaByIndex(..., &size)? Where in size we have for a given paper left, top, bottom and right set to 0?
Thanks,
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Re: [Printing-architecture] CUPS and Borderless
Pascal,
You can use the cupsGetDestMedia* APIs with the CUPS_MEDIA_FLAGS_BORDERLESS flags value.
Quoted 5 lines · Pascal Obry
Hello Michael,
Quoted 16 lines
I'm wondering what is the solution to check, using the CUPS IPP API, if a printer does support borderless printing?
Is that with
cupsGetDestMediaByIndex(..., &size)? Where in size we have for a given paper left, top, bottom and right set to 0?Thanks,
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
_________________________________________________________
Michael Sweet, Senior Printing System Engineer
Re: [Printing-architecture] CUPS and Borderless
Michael,
Quoted 2 lines
You can use the cupsGetDestMedia* APIs with the
CUPS_MEDIA_FLAGS_BORDERLESSflags value.
I tried that already, but when using CUPS_MEDIA_FLAGS_BORDERLESS for the Epson 3880 gutenprint driver I get 0 media.
Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Re: [Printing-architecture] CUPS and Borderless
Pascal,
Make sure you are testing with the latest CUPS code - I've fixed a bunch of bugs in the media code, particularly with the Gutenprint PPDs.
Quoted 19 lines · Pascal Obry
Michael,
Quoted 2 lines
You can use the cupsGetDestMedia* APIs with the
CUPS_MEDIA_FLAGS_BORDERLESSflags value.I tried that already, but when using
CUPS_MEDIA_FLAGS_BORDERLESSfor the Epson 3880 gutenprint driver I get 0 media.Signature · 7 lines
Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B
_________________________________________________________
Michael Sweet, Senior Printing System Engineer