[cups] PPD API: Status, future and alternatives to handle printer-specific options

Michael Weghorn m.weghorn at posteo.de
Wed Feb 1 00:49:12 PST 2017

Hi Michael,

thank you very much for your quick reply.

On 2017-01-31 15:19, Michael Sweet wrote:
>> 2) What is the recommended way to handle printer-specific options in a 
>> print dialog? Which API should be used? (The implementation should 
>> support both "traditional" printers set up via PPD files and PPD-less 
>> printers like IPP Everywhere printers.)
> Use the new API.  CUPS maps old PPD options to IPP/IPP Everywhere 
> options.

Nice. I did not know that CUPS does this. Is it possible to map every 
PPD option to a respective IPP/IPP Everywhere option? I thought that 
only a few PPD options are actually standardized and vendors use a large 
amount of vendor-specific keywords in PPD files. How are those mapped to 
IPP/IPP Everywhere options?

I looked at the new API again and experimented but did not find out how 
to get all the printer-specific options and their possible values. Could 
you possibly give me a hint which functions to use?

With the deprecated PPD API, all options can be retrieved as follows 
(after setting up the printer using 'lpadmin -p myprinter -v 
<device_uri> -P <ppd_file> -E`):

#include <cups/cups.h>
#include <cups/ppd.h>

int main() {
     cups_dest_t *dests;
     int num_dests = cupsGetDests(&dests);

     // NOTE: printer with name "myprinter" needs to be set up first
     cups_dest_t *dest = cupsGetDest("myprinter", NULL, num_dests, 

     const char *ppdPath = cupsGetPPD(dest->name);
     ppd_file_t * ppdFile = ppdOpenFile(ppdPath);

     int ppdGroupCount = ppdFile->num_groups;
     for (int i = 0; i < ppdGroupCount; i++) {
         ppd_group_t group = ppdFile->groups[i];

         for (int j = 0; j < group.num_options; j++) {
             ppd_option_t option = group.options[j];

             printf("OPTION: %s\n", option.keyword);

             for (int k = 0; k < option.num_choices; k++) {
                 char * choice_value = option.choices[k].choice;
                 printf(" - %s\n", choice_value);
     cupsFreeDests(num_dests, dests);

What is the equivalent using the new API?


More information about the cups mailing list