CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Base API dealing with PPD information. More...
Data Structures | |
struct | caps_ppd_option |
Structure to keep the information read-in from an external PPD files. More... | |
struct | caps_ppd_device_info |
Some printer device product specific information to be used inside the PPD. More... | |
struct | caps_ppd_resolution |
Definition of one supported resolution in Dots Per Inch (DPI). More... | |
struct | caps_ppd_media_size |
Definition of the min/max printing medium the manual feed can handle. More... | |
struct | caps_ppd_media_margins |
Definition to calculate the printable area on all printing media. More... | |
struct | caps_ppd_custom_medium |
Definition of a custom medium. More... | |
struct | caps_ppd_selection_entry |
Definition of one 'option' entry a PPD selection provides. More... | |
struct | caps_ppd_selection |
Description of an OpenUI/CloseUI PPD selection. More... | |
struct | caps_ppd_base |
Basic description of common features a printing device/printing driver can provide. More... | |
Enumerations | |
enum | caps_ppd_paper_types { LIBCAPS_PT_SINGLE , LIBCAPS_PT_ENDLESS } |
enum | caps_ppd_paper_leading_edges { LIBCAPS_PLE_UNDEFINED = 0 , LIBCAPS_PLE_SHORT = 1 , LIBCAPS_PLE_LONG = 2 , LIBCAPS_PLE_PLUS_90_DEGREE = 4 , LIBCAPS_PLE_MINUS_90_DEGREE = 8 } |
enum | caps_ppd_color_formats { LIBCAPS_CT_MONOCHROME = 1 , LIBCAPS_CT_GRAY = 2 , LIBCAPS_CT_RGB = 4 , LIBCAPS_CT_CMYK = 8 } |
enum | caps_ppd_common_features { LIBCAPS_GA_DUPLEX = 1 , LIBCAPS_GA_SINGLE_TRAY = 2 , LIBCAPS_GA_MANUAL_FEED = 4 , LIBCAPS_GA_CUSTOM_MEDIA = 8 , LIBCAPS_GA_CUTTER = 16 } |
enum | caps_ppd_option_type { LIBCAPS_OT_PICKONE , LIBCAPS_OT_PICKMANY , LIBCAPS_OT_BOOLEAN } |
Definition of the three possible OpenUI/CloseUI types. More... | |
Handle PPD file's content e.g. read it or create it on the fly
Reading the "PostScript Printer Description File Format Specification" each line in a PPD file conforms to:
*KEYWORD[ [*]NAME[/DESCRIPTION]]:[ ]VALUE *
A few examples:
*SomeOption: "some value" *OpenUI *SomeKeyword/SomeDescription: SomeAction *OrderDependency: 10 AnySetup *SomeKeyword *DefaultSomeKeyword: SomeOption *SomeKeyword SomeOption: "some code" *SomeKeyword SomeOption/SomeDescription: "some code" *CloseUI *SomeKeyword *?query SomeKeyword: "some query code"
enum caps_ppd_paper_types |
Printing media insertion direction and the printing coordinates
Short edge is leading (portrait) (LIBCAPS_PLE_SHORT): -> printing client processes in portrait mode
-------+ P |+-------------------+ R || PAPER | I || | ^ N || | | <--- media moving direction T || | X E || | | R |+-------------------+ | -------+ <----------Y-----+
Long edge is leading (landscape) (LIBCAPS_PLE_LONG): -> printing client processes in landscape mode
-------+ |+-----------+ || PAPER | P || | R || | I || | ^ N || | | <--- media moving direction T || | | E || | X R || | | || | | |+-----------+ | -------+ <------Y----+
Some coordinates will change if the printing media can be rotated when printing. In this case it depends on the landscape mode how the printing client must process its document.
Short edge is leading (LIBCAPS_PLE_SHORT): -> printing client processes in portrait mode
-------+ P |+-------------+ R || PAPER | ^ I || | X N |+-------------+ | <--- media moving direction T | <-------Y----+ E | R | -------+
For this usecase various landscape variants are now possible:
Long edge is leading for a small printing media (LIBCAPS_PLE_LONG): -> printing client processes in landscape mode
-------+ P |+-------+ R || PAPER | I || | ^ N || | | T || | X <--- media moving direction E || | | R |+-------+ | -------+ <--Y---+
Long edge is leading for a small printing media (LIBCAPS_PLE_PLUS_90_DEGREE): -> printing client processes in portrait mode
-------+ <--X---+ P |+-------+ | R || PAPER | | I || | Y N || | | T || | V <--- media moving direction E || | R |+-------+ -------+
Long edge is leading for a small printing media (LIBCAPS_PLE_MINUS_90_DEGREE): -> printing client processes in landscape mode
-------+ P | +-------+ R | | PAPER | I | ^ | | N | | | | <--- media moving direction T | Y | | E | | | | R | | +-------+ -------+ +---X--->
The LIBCAPS_PLE_PLUS_90_DEGREE and LIBCAPS_PLE_MINUS_90_DEGREE flags are used to create the PPD's LandscapeOrientation attribute. Since this attribute is globally only, all trays in a printing device share the same orientation. It's not possible to consider this orientation on a per tray base (which would be really useful!). So if you using more than one pre-marked printing media in different trays, all must be loaded in the same orientation.
The LIBCAPS_PLE_PLUS_90_DEGREE and LIBCAPS_PLE_MINUS_90_DEGREE flags are a run-time feature and should not be set in a static manner in the printing driver.
Enumerator | |
---|---|
LIBCAPS_PLE_UNDEFINED | Use the default settings LIBCAPS_PLE_SHORT instead |
LIBCAPS_PLE_SHORT | Short edge is leading |
LIBCAPS_PLE_LONG | Long edge is leading |
LIBCAPS_PLE_PLUS_90_DEGREE | Portrait to landscape orientation, counterclock wise rotation |
LIBCAPS_PLE_MINUS_90_DEGREE | Portrait to landscape orientation, clockwise rotation |
Colour formats the printer/printer driver supports
Defines the colour space(s) the printer driver can deal with. If more then one is given (to be ored) the PPD gets entries to let the user select one for a job. Thus, a user can print the same image in greyscale for testing purposes and in colour for the final print.
LIBCAPS_CT_MONOCHROME:
LIBCAPS_CT_GRAY:
LIBCAPS_CT_RGB:
LIBCAPS_CT_CMYK:
From the PPD spec about the "*DefaultColorSpace" entry:
"This keyword indicates the default native color space of the device. The native color space is the color space that all colors are converted into before rendering."
For the "*DefaultColorSpace" the real value for colour printing devices depends on its default_color_format setting.
Enumerator | |
---|---|
LIBCAPS_CT_MONOCHROME | Black/white, e.g. monochrome |
LIBCAPS_CT_GRAY | Gray scale |
LIBCAPS_CT_RGB | RGB colours |
LIBCAPS_CT_CMYK | CMYK colours |
Some common basic features a printing device can provide
Refer for details in caps_ppd_base::common_features.
enum caps_ppd_option_type |
void caps_libppd_init | ( | void | ) |
Initialize the library
struct caps_ppd_options_table * caps_ppd_options_table_create | ( | void | ) |
Create and init a table to handle PPD options
void caps_ppd_options_table_clean_up | ( | struct caps_ppd_options_table * | pot | ) |
Free up the memory used by the PPD option's table
[in,out] | pot | The table to free (can be NULL, gets ignored then) |
int caps_ppd_options_table_file_read | ( | struct caps_ppd_options_table * | pot, |
const char * | ppd_file_name | ||
) |
Read in a whole PPD file and create an option table of its content
[in,out] | pot | The table to add the PPD content to |
[in] | ppd_file_name | The path to the file to read |
0 | On success |
negative | errno |
struct caps_ppd_option * caps_ppd_option_get | ( | const struct caps_ppd_options_table * | pot, |
const char * | keyword | ||
) |
Get an option from the PPD table
[in] | pot | The table to search in |
[in] | keyword | Option's keyword |
option | Valid pointer to the option if found |
NULL | If the option wasn't found |
The keyword
must match exactly to be found.
struct caps_ppd_option * caps_ppd_option_with_name_get | ( | const struct caps_ppd_options_table * | pot, |
const char * | keyword, | ||
const char * | name | ||
) |
Get a named option from the PPD table
[in] | pot | The table to search in |
[in] | keyword | option's keyword |
[in] | name | option's name (can be NULL) |
option | Valid pointer to the option if found |
NULL | If the option wasn't found (keyword and/or name ) |
The keyword
and the name
(if given) must match exactly to be found.
void caps_ppd_option_add | ( | struct caps_ppd_options_table * | pot, |
const char * | keyword, | ||
const char * | name, | ||
const char * | description, | ||
const char * | value | ||
) |
Add a new option entry into the PPD option table
[in,out] | pot | The table to add the option to |
[in] | keyword | Option's keyword |
[in] | name | Option's name (can be NULL) |
[in] | description | Option's description (can be NULL) |
[in] | value | Option's value |
struct caps_ppd_options_table * caps_ppd_options_table_duplicate | ( | const struct caps_ppd_options_table * | src | ) |
Create a copy of an existing PPD option table
[in] | src | Source PPD option table |
src
tableSince the entries contain pointer to external objects, this is a so called "deep copy".
const struct caps_ppd_option * caps_ppd_options_table_base_get | ( | const struct caps_ppd_options_table * | pot | ) |
Retrieve the option table array base
[in] | pot | The PPD option table to get the array base from |
table | Base address of the managed table |
NULL | If the table is uninitialized and thus, empty. |
size_t caps_ppd_options_table_element_count_get | ( | const struct caps_ppd_options_table * | pot | ) |
Retrieve the option table array size (e.g. element count)
[in] | pot | The PPD option table to get the array element count from |
number | Elements count |
0 | If the array is empty. |
void caps_ppd_info_generate | ( | struct caps_ppd_options_table * | db, |
FILE * | ppd_file, | ||
const struct caps_ppd_device_info * | prod_info, | ||
const struct caps_ppd_base * | cpb | ||
) |
Create a "Postscript Printer Description" (aka. PPD) file on demand and an option table (a subset of the PPD file)
[in,out] | db | The option table to fill (must already be allocated with caps_ppd_options_table_create()) |
[in,out] | ppd_file | FILE handle to fill with the PPD content |
[in] | prod_info | Printer device product information. Can be NULL |
[in] | cpb | Printing device capabilities description |
If prod_info
is NULL, some information like the product name or manufacturer is unknown and cannot be added to the generated PPD file. Maybe some printer management dialogues will then show some useless information.
int caps_ppd_paper_format_validate | ( | const char * | paper_name | ) |
Check if the given medium format name is a valid one (e.g. "known")
[in] | paper_name | Name of the paper to check |
0 | If paper name is valid/known |
-EINVAL | Format name is invalid |
This is a wrapper around libpaper and for convinience.
struct caps_rect caps_ppd_paper_format_size_get | ( | const char * | paper_name | ) |
Get dimension information about a specific medium format name
[in] | paper_name | Name of the paper (refer "paperconf -a" for valid names) |
paper_name
in portrait orientationIf the paper isn't known, the returned size will be 0.0 in both axis.
This is a wrapper around libpaper and for convinience.
const char * caps_ppd_paper_format_name_get | ( | const struct caps_rect * | size | ) |
Get the medium format name for a specific size
[in] | size | The size information (in [pts]) |
Returns the best matching format name like a4 or letter for the specific size. This is a convenience function and a wrapper around libpaper and the returned name is more or less guessed.
If it returns "custom", nobody has a clue what kind of format it is. Be prepared!
const char * caps_ppd_paper_default_format_get | ( | void | ) |
Get the default name of the systems medium format name
This is a wrapper around libpaper and for convinience.