The CUPS PPD API provides...
The <cups/ppd.h> header file must be included to use the ppd functions.
Programs using these functions must be linked to the CUPS library: libcups.a, libcups.so.2, libcups.2.dylib, libcups_s.a, or libcups2.lib depending on the platform. The following command compiles myprogram.c using GCC and the CUPS library:
gcc -o myprogram myprogram.c -lcups
Unless otherwise specified, the PPD API functions require CUPS 1.1 or higher.
Colorspaces
Name | Description |
---|---|
PPD_CS_CMY | CMY colorspace |
PPD_CS_CMYK | CMYK colorspace |
PPD_CS_GRAY | Grayscale colorspace |
PPD_CS_N | DeviceN colorspace |
PPD_CS_RGB | RGB colorspace |
PPD_CS_RGBK | RGBK (K = gray) colorspace |
Extended UI Types
Name | Description |
---|---|
PPD_UI_CUPS_CURVE | Specify start, end, and gamma numbers |
PPD_UI_CUPS_GAMMA | Specify a gamma number |
PPD_UI_CUPS_INTEGER | Specify an integer number |
PPD_UI_CUPS_INTEGER_ARRAY | Specify an array of integer numbers |
PPD_UI_CUPS_REAL | Specify a real number |
PPD_UI_CUPS_REAL_ARRAY | Specify an array of real numbers |
PPD_UI_CUPS_TEXT | Specify a string |
PPD_UI_CUPS_XY_ARRAY | Specify an array of X/Y real numbers |
Order dependency sections
Name | Description |
---|---|
PPD_ORDER_ANY | Option code can be anywhere in the file |
PPD_ORDER_DOCUMENT | ... must be in the DocumentSetup section |
PPD_ORDER_EXIT | ... must be sent prior to the document |
PPD_ORDER_JCL | ... must be sent as a JCL command |
PPD_ORDER_PAGE | ... must be in the PageSetup section |
PPD_ORDER_PROLOG | ... must be in the Prolog section |
Types and structures...
Name | Description |
---|---|
PPD_ALLOC_ERROR | Memory allocation error |
PPD_BAD_OPEN_GROUP | Bad OpenGroup |
PPD_BAD_OPEN_UI | Bad OpenUI/JCLOpenUI |
PPD_BAD_ORDER_DEPENDENCY | Bad OrderDependency |
PPD_BAD_UI_CONSTRAINTS | Bad UIConstraints |
PPD_FILE_OPEN_ERROR | Unable to open PPD file |
PPD_ILLEGAL_CHARACTER | Illegal control character |
PPD_ILLEGAL_MAIN_KEYWORD | Illegal main keyword string |
PPD_ILLEGAL_OPTION_KEYWORD | Illegal option keyword string |
PPD_ILLEGAL_TRANSLATION | Illegal translation string |
PPD_ILLEGAL_WHITESPACE | Illegal whitespace character |
PPD_INTERNAL_ERROR | Internal error |
PPD_LINE_TOO_LONG | Line longer than 255 chars |
PPD_MISSING_ASTERISK | Missing asterisk in column 0 |
PPD_MISSING_PPDADOBE4 | Missing PPD-Adobe-4.x header |
PPD_MISSING_VALUE | Missing value string |
PPD_NESTED_OPEN_GROUP | OpenGroup without a CloseGroup first |
PPD_NESTED_OPEN_UI | OpenUI/JCLOpenUI without a CloseUI/JCLCloseUI first |
PPD_NULL_FILE | NULL PPD file pointer |
PPD_OK | OK |
UI Types
Name | Description |
---|---|
PPD_UI_BOOLEAN | True or False option |
PPD_UI_PICKMANY | Pick zero or more from a list |
PPD_UI_PICKONE | Pick one from a list |
Free all memory used by the PPD file.
void ppdClose( ppd_file_t * ppd);
Name | Description |
---|---|
ppd | PPD file record |
Nothing.
Collect all marked options that reside in the specified section.
int ppdCollect( ppd_file_t * ppd, ppd_section_t section, ppd_choice_t *** choices);
Name | Description |
---|---|
ppd | PPD file data |
section | Section to collect |
choices | Pointers to choices |
Number of options marked
Check to see if there are any conflicts.
int ppdConflicts( ppd_file_t * ppd);
Name | Description |
---|---|
ppd | PPD to check |
Number of conflicts found
Emit code for marked options to a file.
int ppdEmit( ppd_file_t * ppd, FILE * fp, ppd_section_t section);
Name | Description |
---|---|
ppd | PPD file record |
fp | File to write to |
section | Section to write |
0 on success, -1 on failure
Emit code for marked options to a file.
int ppdEmitFd( ppd_file_t * ppd, int fd, ppd_section_t section);
Name | Description |
---|---|
ppd | PPD file record |
fd | File to write to |
section | Section to write |
0 on success, -1 on failure
Emit code for JCL options to a file.
int ppdEmitJCL( ppd_file_t * ppd, FILE * fp, int job_id, const char * user, const char * title);
Name | Description |
---|---|
ppd | PPD file record |
fp | File to write to |
job_id | Job ID |
user | Username |
title | Title |
0 on success, -1 on failure
Emit JCLEnd code to a file.
int ppdEmitJCLEnd( ppd_file_t * ppd, FILE * fp);
Name | Description |
---|---|
ppd | PPD file record |
fp | File to write to |
0 on success, -1 on failure
Returns the text assocated with a status.
const char * ppdErrorString( ppd_status_t status);
Name | Description |
---|---|
status | PPD status |
Status string
Find the first matching attribute...
ppd_attr_t * ppdFindAttr( ppd_file_t * ppd, const char * name, const char * spec);
Name | Description |
---|---|
ppd | PPD file data |
name | Attribute name |
spec | Specifier string or NULL |
Attribute or NULL if not found
Return a pointer to an option choice.
ppd_choice_t * ppdFindChoice( ppd_option_t * o, const char * choice);
Name | Description |
---|---|
o | Pointer to option |
choice | Name of choice |
Choice pointer or NULL
Return the marked choice for the specified option.
ppd_choice_t * ppdFindMarkedChoice( ppd_file_t * ppd, const char * option);
Name | Description |
---|---|
ppd | PPD file |
option | Keyword/option name |
Pointer to choice or NULL
Find the next matching attribute...
ppd_attr_t * ppdFindNextAttr( ppd_file_t * ppd, const char * name, const char * spec);
Name | Description |
---|---|
ppd | PPD file data |
name | Attribute name |
spec | Specifier string or NULL |
Attribute or NULL if not found
Return a pointer to the specified option.
ppd_option_t * ppdFindOption( ppd_file_t * ppd, const char * option);
Name | Description |
---|---|
ppd | PPD file data |
option | Option/Keyword name |
Pointer to option or NULL
Check to see if an option is marked...
int ppdIsMarked( ppd_file_t * ppd, const char * option, const char * choice);
Name | Description |
---|---|
ppd | PPD file data |
option | Option/Keyword name |
choice | Choice name |
Non-zero if option is marked
Return the status from the last ppdOpen*().
ppd_status_t ppdLastError( int * line);
Name | Description |
---|---|
line | Line number |
Status code
Mark all default options in the PPD file.
void ppdMarkDefaults( ppd_file_t * ppd);
Name | Description |
---|---|
ppd | PPD file record |
Nothing.
Mark an option in a PPD file. Notes: -1 is returned if the given option would conflict with any currently selected option.
int ppdMarkOption( ppd_file_t * ppd, const char * option, const char * choice);
Name | Description |
---|---|
ppd | PPD file record |
option | Keyword |
choice | Option name |
Number of conflicts
Read a PPD file into memory.
ppd_file_t * ppdOpen( FILE * fp);
Name | Description |
---|---|
fp | File to read from |
PPD file record
Read a PPD file into memory.
ppd_file_t * ppdOpen2( cups_file_t * fp);
Name | Description |
---|---|
fp | File to read from |
PPD file record
Read a PPD file into memory.
ppd_file_t * ppdOpenFd( int fd);
Name | Description |
---|---|
fd | File to read from |
PPD file record
Read a PPD file into memory.
ppd_file_t * ppdOpenFile( const char * filename);
Name | Description |
---|---|
filename | File to read from |
PPD file record
Get the page length for the given size.
float ppdPageLength( ppd_file_t * ppd, const char * name);
Name | Description |
---|---|
ppd | PPD file |
name | Size name |
Length of page in points or 0.0
Get the page size record for the given size.
ppd_size_t * ppdPageSize( ppd_file_t * ppd, const char * name);
Name | Description |
---|---|
ppd | PPD file record |
name | Size name |
Size record for page or NULL
Get the page width for the given size.
float ppdPageWidth( ppd_file_t * ppd, const char * name);
Name | Description |
---|---|
ppd | PPD file record |
name | Size name |
Width of page in points or 0.0
Set the conformance level for PPD files.
void ppdSetConformance( ppd_conform_t c);
Name | Description |
---|---|
c | Conformance level |
Nothing.
PPD Attribute Structure
struct ppd_attr_str { char name[PPD_MAX_NAME]; char spec[PPD_MAX_NAME]; char text[PPD_MAX_TEXT]; char * value; };
Name | Description |
---|---|
name[PPD_MAX_NAME] | Name of attribute (cupsXYZ) |
spec[PPD_MAX_NAME] | Specifier string, if any |
text[PPD_MAX_TEXT] | Human-readable text, if any |
value | Value string |
Option choices
struct ppd_choice_str { char choice[PPD_MAX_NAME]; char * code; char marked; ppd_option_t * option; char text[PPD_MAX_TEXT]; };
Name | Description |
---|---|
choice[PPD_MAX_NAME] | Computer-readable option name |
code | Code to send for this option |
marked | 0 if not selected, 1 otherwise |
option | Pointer to parent option structure |
text[PPD_MAX_TEXT] | Human-readable option name |
Emulators
struct ppd_emul_str { char name[PPD_MAX_NAME]; char * start; char * stop; };
Name | Description |
---|---|
name[PPD_MAX_NAME] | Emulator name |
start | Code to switch to this emulation |
stop | Code to stop this emulation |
Extended Options
struct ppd_ext_option_str { char * code; char keyword[PPD_MAX_NAME]; int marked; int num_params; ppd_option_t * option; ppd_ext_param_t ** params; };
Name | Description |
---|---|
code | Generic PS code for extended options |
keyword[PPD_MAX_NAME] | Name of option that is being extended... |
marked | Extended option is marked |
num_params | Number of parameters |
option | Option that is being extended... |
params | Parameters |
Extended Parameter
struct ppd_ext_param_str { ppd_ext_value_t * defval; char keyword[PPD_MAX_NAME]; ppd_ext_value_t * maxval; ppd_ext_value_t * minval; char text[PPD_MAX_TEXT]; ppd_ext_value_t * value; };
Name | Description |
---|---|
defval | Default values |
keyword[PPD_MAX_NAME] | Parameter name |
maxval | Maximum numeric values |
minval | Minimum numeric values |
text[PPD_MAX_TEXT] | Human-readable text |
value | Current values |
Files
struct ppd_file_str { int accurate_screens; ppd_attr_t ** attrs; int color_device; ppd_cs_t colorspace; ppd_const_t * consts; int contone_only; int cur_attr; float custom_margins[4]; float custom_max[2]; float custom_min[2]; ppd_emul_t * emulations; ppd_ext_option_t ** extended; char ** filters; int flip_duplex; char ** fonts; ppd_group_t * groups; char * jcl_begin; char * jcl_end; char * jcl_ps; int landscape; char * lang_encoding; char * lang_version; int language_level; int manual_copies; char * manufacturer; int model_number; char * modelname; char * nickname; int num_attrs; int num_consts; int num_emulations; int num_extended; int num_filters; int num_fonts; int num_groups; int num_profiles; int num_sizes; char * patches; char * pcfilename; char * product; ppd_profile_t * profiles; char * protocols; char * shortnickname; ppd_size_t * sizes; int throughput; char * ttrasterizer; int variable_sizes; };
Name | Description |
---|---|
accurate_screens | 1 = supports accurate screens, 0 = not |
attrs CUPS 1.1.19 | Attributes |
color_device | 1 = color device, 0 = grayscale |
colorspace | Default colorspace |
consts | UI/Non-UI constraints |
contone_only | 1 = continuous tone only, 0 = not |
cur_attr CUPS 1.1.19 | Current attribute |
custom_margins[4] | Margins around page |
custom_max[2] | Maximum variable page size |
custom_min[2] | Minimum variable page size |
emulations | Emulations and the code to invoke them |
extended CUPS 1.2 | Extended options |
filters | Filter strings... |
flip_duplex CUPS 1.1 | 1 = Flip page for back sides |
fonts | Pre-loaded fonts |
groups | UI groups |
jcl_begin | Start JCL commands |
jcl_end | End JCL commands |
jcl_ps | Enter PostScript interpreter |
landscape | -90 or 90 |
lang_encoding | Language encoding |
lang_version | Language version (English, Spanish, etc.) |
language_level | Language level of device |
manual_copies | 1 = Copies done manually, 0 = hardware |
manufacturer | Manufacturer name |
model_number | Device-specific model number |
modelname | Model name (general) |
nickname | Nickname (specific) |
num_attrs CUPS 1.1.19 | Number of attributes |
num_consts | Number of UI/Non-UI constraints |
num_emulations | Number of emulations supported |
num_extended CUPS 1.2 | Number of extended options |
num_filters | Number of filters |
num_fonts | Number of pre-loaded fonts |
num_groups | Number of UI groups |
num_profiles | Number of sRGB color profiles |
num_sizes | Number of page sizes |
patches | Patch commands to be sent to printer |
pcfilename CUPS 1.1.19 | PCFileName string |
product | Product name (from PS RIP/interpreter) |
profiles | sRGB color profiles |
protocols CUPS 1.1.19 | Protocols (BCP, TBCP) string |
shortnickname | Short version of nickname |
sizes | Page sizes |
throughput | Pages per minute |
ttrasterizer | Truetype rasterizer |
variable_sizes | 1 = supports variable sizes, 0 = doesn't |
Groups
struct ppd_group_str { char text[PPD_MAX_TEXT - PPD_MAX_NAME]; char name[PPD_MAX_NAME]; int num_options; int num_subgroups; ppd_option_t * options; struct ppd_group_str * subgroups; };
Name | Description |
---|---|
PPD_MAX_NAME] | Human-readable group name |
name[PPD_MAX_NAME] CUPS 1.1.18 | Group name |
num_options | Number of options |
num_subgroups | Number of sub-groups |
options | Options |
subgroups | Sub-groups (max depth = 1) |
Options
struct ppd_option_str { ppd_choice_t * choices; char conflicted; char defchoice[PPD_MAX_NAME]; char keyword[PPD_MAX_NAME]; int num_choices; float order; ppd_section_t section; char text[PPD_MAX_TEXT]; ppd_ui_t ui; };
Name | Description |
---|---|
choices | Option choices |
conflicted | 0 if no conflicts exist, 1 otherwise |
defchoice[PPD_MAX_NAME] | Default option choice |
keyword[PPD_MAX_NAME] | Option keyword name ("PageSize", etc.) |
num_choices | Number of option choices |
order | Order number |
section | Section for command |
text[PPD_MAX_TEXT] | Human-readable text |
ui | Type of UI option |
sRGB Color Profiles
struct ppd_profile_str { float density; float gamma; float matrix[3][3]; char media_type[PPD_MAX_NAME]; char resolution[PPD_MAX_NAME]; };
Name | Description |
---|---|
density | Ink density to use |
gamma | Gamma correction to use |
matrix[3][3] | Transform matrix |
media_type[PPD_MAX_NAME] | Media type or "-" |
resolution[PPD_MAX_NAME] | Resolution or "-" |
Page Sizes
struct ppd_size_str { float bottom; float left; float length; int marked; char name[PPD_MAX_NAME]; float right; float top; float width; };
Name | Description |
---|---|
bottom | Bottom printable margin in points |
left | Left printable margin in points |
length | Length of media in points |
marked | Page size selected? |
name[PPD_MAX_NAME] | Media size option |
right | Right printable margin in points |
top | Top printable margin in points |
width | Width of media in points |
PPD Attribute Structure
typedef struct ppd_attr_str ppd_attr_t;
Option choices
typedef struct ppd_choice_str ppd_choice_t;
Constraints
typedef struct ppd_const_t;
Emulators
typedef struct ppd_emul_str ppd_emul_t;
Extended Options
typedef struct ppd_ext_option_str ppd_ext_option_t;
Extended Parameter
typedef struct ppd_ext_param_str ppd_ext_param_t;
Extended UI Types
typedef enum ppd_ext_ui_e ppd_ext_ui_t;
Extended Values
typedef union ppd_ext_value_u ppd_ext_value_t;
Files
typedef struct ppd_file_str ppd_file_t;
Groups
typedef struct ppd_group_str ppd_group_t;
Options
typedef struct ppd_option_str ppd_option_t;
sRGB Color Profiles
typedef struct ppd_profile_str ppd_profile_t;
Order dependency sections
typedef enum ppd_section_e ppd_section_t;
Page Sizes
typedef struct ppd_size_str ppd_size_t;
UI Types
typedef enum ppd_ui_e ppd_ui_t;
Extended Values
union ppd_ext_value_u { float gamma; int integer; float real; char * text; };
Name | Description |
---|---|
gamma | Gamma value |
integer | Integer value |
real | Real value |
text | Text value |