CAPS Universe documentation  1.0.4
All you need to know to be successful
Data Structures | Functions | Variables
libcapsppd-generator.c File Reference

Generate PPD information based of the printer description. More...

Data Structures

struct  color_model_string
 

Functions

static const char * caps_ppd_translate (const struct caps_printing_device_info *cpdi, const char *string)
 
static void ppd_printer_base (struct caps_printing_device_info *cpdi, const struct caps_ppd_device_info *prod_info)
 
static void ppd_language_level (struct caps_printing_device_info *cpdi)
 
static void ppd_header (struct caps_printing_device_info *cpdi, const struct caps_ppd_device_info *prod_info)
 
static void ppd_printer_type (const struct caps_printing_device_info *cpdi)
 
static char * ppd_resolution_name (const struct caps_ppd_resolution *res)
 
static char * ppd_resolution_text (const struct caps_ppd_resolution *res)
 
static void ppd_print_one_resolution_entry (struct caps_printing_device_info *cpdi, const struct caps_ppd_resolution *res)
 
static void ppd_print_default_resolution_entry (struct caps_printing_device_info *cpdi, const struct caps_ppd_resolution *res)
 
static void ppd_defaults (struct caps_printing_device_info *cpdi)
 
static const char * get_color_model_name (enum caps_ppd_color_formats cf)
 
static int caps_colour_choice (struct caps_printing_device_info *cpdi)
 
static void caps_resolution_choice (struct caps_printing_device_info *cpdi)
 
static void caps_options (struct caps_printing_device_info *cpdi)
 
static void caps_emit_selection_entry (struct caps_printing_device_info *cpdi, const char *keyword, const struct caps_ppd_selection_entry *entry)
 
static void caps_emit_selection (struct caps_printing_device_info *cpdi, const struct caps_ppd_selection *selection)
 
static void caps_emit_selections (struct caps_printing_device_info *cpdi)
 
static enum caps_ppd_paper_leading_edges ensure_valid_orientation (enum caps_ppd_paper_leading_edges setting)
 
static void ppd_landscape_orientation (struct caps_printing_device_info *cpdi)
 
static void ppd_paper_edges (struct caps_printing_device_info *cpdi)
 
static bool ppd_check_if_paper_format_fits (const struct caps_ppd_media_size *coverage, double width, double height)
 
static char * word_capitalize (const char *str)
 
static void ppd_list_page_sizes (struct caps_printing_device_info *cpdi, const char *option, const char *printf_format, const struct caps_ppd_media_size *coverage, int include_value)
 
static void ppd_single_paper_dimension (struct caps_printing_device_info *cpdi, const struct caps_ppd_custom_medium *entry)
 
static void ppd_single_paper_imageable_area (struct caps_printing_device_info *cpdi, const struct caps_ppd_custom_medium *entry)
 
static void ppd_paper_single_tray (struct caps_printing_device_info *cpdi, const char *default_format, const struct caps_ppd_media_size *coverage)
 
static void ppd_paper_multi_tray (struct caps_printing_device_info *cpdi, const char *default_format, const struct caps_ppd_media_size *coverage)
 
static void ppd_paper_manual_feed (struct caps_printing_device_info *cpdi, const char *default_format, const struct caps_ppd_media_size *coverage)
 
static void ppd_paper_custom_list (struct caps_printing_device_info *cpdi, const char *default_format)
 
static void ppd_paper_dimension (struct caps_printing_device_info *cpdi, const char *default_format)
 
static void ppd_paper_imageable_area (struct caps_printing_device_info *cpdi, const char *default_format)
 
static void ppd_paper_sizes (struct caps_printing_device_info *cpdi)
 
static void ppp_duplex_print (struct caps_printing_device_info *cpdi)
 
static void ppd_paper_source (struct caps_printing_device_info *cpdi)
 
static void ppd_fonts (struct caps_printing_device_info *cpdi)
 
static __non_null void ppd_cutter_selection (struct caps_printing_device_info *cpdi)
 
static void _caps_ppd_create_ppd (struct caps_printing_device_info *cpdi, const struct caps_ppd_device_info *prod_info)
 
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)
 

Variables

static const struct color_model_string cmodels []
 
static struct caps_ppd_selection_entry generic_duplex_entries []
 
static const struct caps_ppd_selection generic_duplex_selection
 
static struct caps_ppd_selection_entry manual_feed_selections []
 
static const struct caps_ppd_selection manual_feed_selection
 
static const struct caps_ppd_selection_entry generic_cutter_selections []
 
static const struct caps_ppd_selection generic_cutter_selection
 

Detailed Description

These functions translate the information from the printer description (provided by the printing provider/printing driver) into

The text file can be forwarded to the printing coordinator and will be used by the printing client to configure the print job in a printing device specific manner.

The array (or to be more precise: its content) will be used to setup the print job with data from the PPD selections and the IPP options (some of them also depends on the PPD content).

There are some keywords which are required:

DefaultImageableArea *DefaultPageRegion *DefaultPageSize *DefaultPaperDimension *FileVersion *FormatVersion *ImageableArea *LanguageEncoding *LanguageVersion *Manufacturer *ModelName *NickName *PageRegion *PageSize *PaperDimension *PCFileName *PPD-Adobe *Product *PSVersion *ShortNickName

*PageRegion + *DefaultPageRegion: for manual feed

*InputSlot Manual or *InputSlot ManualFeed. instead of *ManualFeed

*DefaultImageableArea will often be "Unknown" *DefaultPaperDimension as *DefaultPageSize, *DefaultPageRegion, and *DefaultImageableArea.

Function Documentation

◆ caps_ppd_translate()

static const char * caps_ppd_translate ( const struct caps_printing_device_info cpdi,
const char *  string 
)
static

Try to translate the description entry in a PPD file

Parameters
[in]cpdiThe printing device information
[in]stringThe string to translate
Returns
The translated string or the original string if no translation is available

This routine tries to translate the given string into the local language (LANG) using the domain of the calling printing driver. If the printing driver does not support it, domainname can be NULL and this routine tries to use its own po files. Some strings are common and maybe a shared translation is already available.

◆ ppd_printer_base()

static void ppd_printer_base ( struct caps_printing_device_info cpdi,
const struct caps_ppd_device_info prod_info 
)
static

Create printer device product information

Parameters
[in]cpdiThe static printer device info
[in]prod_infoPrinter device product information. Can be NULL

Creates some always required entries:

  • *Manufacturer
  • *Product
  • *ShortNickName
  • *ModelName
  • *NickName
Todo:
Limit *ShortNickName to 31 chars

◆ ppd_language_level()

static void ppd_language_level ( struct caps_printing_device_info cpdi)
static

Supported level must be defined by the interpreter!

The "LanguageLevel" keyword can be omitted: We do not support PostScript yet.

◆ ppd_header()

static void ppd_header ( struct caps_printing_device_info cpdi,
const struct caps_ppd_device_info prod_info 
)
static

Create the PPD file header

Parameters
[in]cpdiThe static printer device info
[in]prod_infoPrinter device product information. Can be NULL

Don't know if this kind of information is important. At least it will not be part of the internal database representation.

Note
At least the '*LanguageEncoding: utf8' entry should be important to let the reader know how to use the translation strings with non-ASCII characters.

◆ ppd_printer_type()

static void ppd_printer_type ( const struct caps_printing_device_info cpdi)
static

Create the printer type entries regarding its colour capabilities

Parameters
[in]cpdiThe static printer device info

The generated entries here aren't interpreted as the printer device capabilities. They are more meant to describe the printing driver which must deal with the data.

We violate the spec here, because it does not know a monochrome printer. It only mentions "gray" as a marker for printers with one colour only.

I think: Using 'monochrome' prints with dithering and 'gray' prints without dithering.

Note
LIBCAPS_CT_CMYK has precedence over LIBCAPS_CT_RGB for colour capabilities

◆ ppd_resolution_name()

static char * ppd_resolution_name ( const struct caps_ppd_resolution res)
static

Create the resolution's name

Parameters
[in]resThe resolution to create the descriptive text
Returns
Pointer to the string, must be free afterwards

According to the spec, the name should be of

  • <number>dpi for resolutions equal in both directions
  • <x>x<y>dpi for non-equal resolutions in both directions
Note
Does not return in case of memory failure
Precondition
The ipp_get_resolution_value() function relies on the generated string and its format
Postcondition
The returned pointer must be freed after use

◆ ppd_resolution_text()

static char * ppd_resolution_text ( const struct caps_ppd_resolution res)
static

Create the resolution's descriptive text

Parameters
[in]resThe resolution to create the descriptive text
Returns
Pointer to the string, must be free afterwards

The descritpive text is of the form

  • '<number> DPI' for resolutions equal in both directions
  • '<x>x<y> DPI' for non-equal resolutions in both directions
Note
Does not return in case of memory failure
Postcondition
The returned pointer must be freed after use

◆ ppd_print_one_resolution_entry()

static void ppd_print_one_resolution_entry ( struct caps_printing_device_info cpdi,
const struct caps_ppd_resolution res 
)
static

Create one entry to describe a printing resolution

Parameters
[in]cpdiCollected printing device info
[in]resResolution entry to add
Note
We do not support PostScript anymore, so we are free here what string we provide to setup the printing resolution

◆ ppd_print_default_resolution_entry()

static void ppd_print_default_resolution_entry ( struct caps_printing_device_info cpdi,
const struct caps_ppd_resolution res 
)
static

Create one entry to describe the default printing resolution

Parameters
[in]cpdiCollected printing device info
[in]resResolution info

◆ ppd_defaults()

static void ppd_defaults ( struct caps_printing_device_info cpdi)
static
Parameters
[in]cpdiCollected printing device info

From the spec about a single resolution:

‍"Builders of PPD files: If the device has only one resolution, *DefaultResolution may appear by itself, without *Resolution, *SetResolution, or any *OpenUI/*CloseU bracketing. See section 3.2 and section 4.5 for information on stand-alone default keywords."

◆ get_color_model_name()

static const char * get_color_model_name ( enum caps_ppd_color_formats  cf)
static

Convert the colour macro to the corresponding colour name

Parameters
[in]cfThe colour macro
Returns
The colour name
Note
This function does not return in the case the given cf is invalid

Valid colour macros are listed in cmodels

Todo:
change to index variant, refer predictable_numerical_value_*()

◆ caps_colour_choice()

static int caps_colour_choice ( struct caps_printing_device_info cpdi)
static
Parameters
[in]cpdiCollected printing device info
Note
We do not support PostScript anymore, so we are free here what string we provide to setup the colour mode

◆ caps_resolution_choice()

static void caps_resolution_choice ( struct caps_printing_device_info cpdi)
static
Parameters
[in]cpdiCollected printing device info

◆ caps_options()

static void caps_options ( struct caps_printing_device_info cpdi)
static
Parameters
[in]cpdiCollected printing device info

◆ caps_emit_selection_entry()

static void caps_emit_selection_entry ( struct caps_printing_device_info cpdi,
const char *  keyword,
const struct caps_ppd_selection_entry entry 
)
static

Emit one selectable entry inside an OpenUI/CloseUI block

Parameters
[in]cpdiCollected printing device info
[in]keywordThe base keyword the selection corresponds to
[in]entryThe selectable entry information

The generated output is a one-liner and has the form of:

 *<keyword> <option>[<translation>]: "[<value>]"

◆ caps_emit_selection()

static void caps_emit_selection ( struct caps_printing_device_info cpdi,
const struct caps_ppd_selection selection 
)
static

Emit an OpenUI/CloseUI selection block

Parameters
[in]cpdiCollected printing device info
[in]selectionThe selection information

The generated output has the form of:

 *OpenUI *<keyword>[<translation>]: <type>
 *OrderDependency: 10 AnySetup *<keyword>
 *Default<keyword>: <option>
 *[...]
 *CloseUI *<keyword>

◆ caps_emit_selections()

static void caps_emit_selections ( struct caps_printing_device_info cpdi)
static

Emit all PPD selection entries (on demand)

Parameters
[in]cpdiCollected printing device info

◆ ensure_valid_orientation()

static enum caps_ppd_paper_leading_edges ensure_valid_orientation ( enum caps_ppd_paper_leading_edges  setting)
static

Ensure valid defaults, if the leading edge setting is undefined

Parameters
[in]settingThe leading edge setting from the printer driver
Returns
A valid leading edge setting (e.g. edge_setting if already valid, else a default)

The purpose of this function is to ensure the conformance to the documentation in caps_ppd_paper_leading_edges and caps_ppd_base::default_leading_edges

◆ ppd_landscape_orientation()

static void ppd_landscape_orientation ( struct caps_printing_device_info cpdi)
static

Handle landscape orientation

Parameters
[in]cpdiCollected printing device info

If the medium is blank, this attributes makes no sense, because it isn't important how you rotate the print from landscape to portrait. But it makes sense, if the medium is special (envelopes), has punch holes or is pre-marked already.

Note
From the PPD spec: if there is no need for special handling, this keyword should be skipped.
This generic setting ("one for all") makes no sense, if the printer can deal with many media at once (due to more than one paper tray for example). In this case it is specific to the selected medium. So, use it only to make PPD readers happy and for backward compatibility.

◆ ppd_paper_edges()

static void ppd_paper_edges ( struct caps_printing_device_info cpdi)
static

Output the leading print medium edge (on demand)

Parameters
[in]cpdiCollected printing device info

From the spec:

‍…allows the user to tell the print manager how the current input slot has been configured to feed the page. This is both an assertion of how an input slot is set up (for cut-sheet media) and a partial request for page image orientation (for roll-fed media). […] *LeadingEdge should be displayed as a PickOne menu and should follow the rules for PickOne keywords, although it is not surrounded by *OpenUI/*CloseUI

Note
Fine. The value is paper tray specific, but can be given only "one for all"…
Precondition
libcapsraster depends on the "Short" and "Long" value keywords for the "DefaultLeadingEdge" entry.

◆ ppd_check_if_paper_format_fits()

static bool ppd_check_if_paper_format_fits ( const struct caps_ppd_media_size coverage,
double  width,
double  height 
)
static

Check if the given paper size fits into the physical limits of the printing device

Parameters
[in]coveragePhysical limits of the printing device
[in]widthPaper width to check
[in]heightPaper height to check
Returns
true is paper fits into the physical limits
Note
All units are 1/72 inch

◆ word_capitalize()

static char * word_capitalize ( const char *  str)
static

Change the first character of the first word to upper case

Precondition
The first character in str is expected as the beginning of the word

◆ ppd_list_page_sizes()

static void ppd_list_page_sizes ( struct caps_printing_device_info cpdi,
const char *  option,
const char *  printf_format,
const struct caps_ppd_media_size coverage,
int  include_value 
)
static

Create a list of PageSize, PageDimension or PageRegion entries

Parameters
[in]cpdiCollected printing device info
[in]optionName of the PPD option ('PageSize', 'PageDimension' or 'PageRegion')
[in]printf_formatThe format string (refer printf's manpage)
[in]coveragePhysical limits of the printing device
[in]include_value'true' to have the value in the option list as well

The created list is based on the paper names the libpaper knows.

Creates the following entries, if option is

 PageSize

and printf_format is

 : \"<</PageSize[%.0f %.0f]/ImagingBBox null>>setpagedevice\"\n
*[…]
*PageSize a4/A4: "<</PageSize[595 842]/ImagingBBox null>>setpagedevice"
*PageSize letter/Letter: "<</PageSize[612 792]/ImagingBBox null>>setpagedevice"
*PageSize note/Note: "<</PageSize[612 792]/ImagingBBox null>>setpagedevice"
*PageSize legal/Legal: "<</PageSize[612 1008]/ImagingBBox null>>setpagedevice"
*[…]

The "PageSize" keyword and its format name need to be part of the ppd option list! handle_ppd_parameter() relies on it.

◆ ppd_single_paper_dimension()

static void ppd_single_paper_dimension ( struct caps_printing_device_info cpdi,
const struct caps_ppd_custom_medium entry 
)
static

Emit one single paper dimension entry

Useful to read back the size in a generic manner

◆ ppd_single_paper_imageable_area()

static void ppd_single_paper_imageable_area ( struct caps_printing_device_info cpdi,
const struct caps_ppd_custom_medium entry 
)
static

Emit one single paper imageable area entry

Useful to read back the area in a generic manner

◆ ppd_paper_single_tray()

static void ppd_paper_single_tray ( struct caps_printing_device_info cpdi,
const char *  default_format,
const struct caps_ppd_media_size coverage 
)
static

Emit the definition for a paper in a single tray

Parameters
[in]cpdiCollected printing device info
[in]default_formatThe name of the default paper format
[in]coveragePhysical limits of the printing device

Used when the printer has exactly one tray with one paper loaded. Expectation is, this tray is loaded with a paper the user knows and has set in the configs. Offer this single paper to the printing clients

For example if 'DIN A4' is the loaded paper:

 *DefaultPageSize: A4
 *PageSize A4/A4: "<</.HWMargins [12.5 12.5 12.5 12.5] /PageSize[595 842]/ImagingBBox null>>setpagedevice"

We do not support PostScript anymore, so we are free here what string we provide to setup the page size

This entry is used by the print job generator to have an idea about the printing capabilities of the printer for this specific paper.

Some print dialougs only show this entry, if it is framed by OpenUI/CloseUI m( Since it would be nice to show the user the currently available paper format, we need to add these user interface entries...

Precondition
default_format must be valid
Todo:
first charactor of default_format in uppercase (TODO)

◆ ppd_paper_multi_tray()

static void ppd_paper_multi_tray ( struct caps_printing_device_info cpdi,
const char *  default_format,
const struct caps_ppd_media_size coverage 
)
static

Emit the available paper definition for a multi tray

Parameters
[in]cpdiCollected printing device info
[in]default_formatThe default paper format from the list
[in]coveragePhysical limits of the printing device

In a multi tray printing device all page formats are possible.

We do not support PostScript anymore, so we are free here what string we provide to setup the page size

Precondition
default_format must be valid

◆ ppd_paper_manual_feed()

static void ppd_paper_manual_feed ( struct caps_printing_device_info cpdi,
const char *  default_format,
const struct caps_ppd_media_size coverage 
)
static

Emit the available paper definition for a manual feed

Parameters
[in]cpdiCollected printing device info
[in]default_formatThe default paper format from the list
[in]coveragePhysical limits of the printing device

For a manual feed all page formats are possible.

We do not support PostScript anymore, so we are free here what string we provide to setup the page region

◆ ppd_paper_custom_list()

static void ppd_paper_custom_list ( struct caps_printing_device_info cpdi,
const char *  default_format 
)
static

Emit the custom media defintion

Parameters
[in]cpdiCollected printing device info
[in]default_formatThe default paper format from the list
Note
For the internal DefaultPaperDimension, the value of the DefaultPageSize is used instead to define all other related entries.

◆ ppd_paper_dimension()

static void ppd_paper_dimension ( struct caps_printing_device_info cpdi,
const char *  default_format 
)
static

Add a single paper dimension entry

Parameters
[in]cpdiCollected printing device info
[in]default_formatThe default paper format

For the PPD this adds a PaperDimension and a DefaultPaperDimension entry. For the internal database only a PaperDimension is required.

Note
For the internal DefaultPaperDimension, the value of the DefaultPageSize is used instead to define all other related entries.

◆ ppd_paper_imageable_area()

static void ppd_paper_imageable_area ( struct caps_printing_device_info cpdi,
const char *  default_format 
)
static
Parameters
[in]cpdiCollected printing device info
[in]default_formatThe default paper format in lower case

Creates a PPD content of the following type (content depends on the papers known to libpaper)

*DefaultImageableArea: a4
*ImageableArea a4/A4: "1.41 12.50 595.10 829.39"
*ImageableArea letter/Letter: "1.41 12.50 611.82 779.50"
*ImageableArea note/Note: "1.41 12.50 611.82 779.50"
*ImageableArea legal/Legal: "1.41 12.50 611.82 995.50"
*ImageableArea executive/Executive: "1.41 12.50 521.82 743.50"
*ImageableArea halfletter/Halfletter: "1.41 12.50 395.82 599.50"
*ImageableArea halfexecutive/Halfexecutive: "1.41 12.50 377.82 509.50"
*ImageableArea statement/Statement: "1.41 12.50 395.82 599.50"
*ImageableArea folio/Folio: "1.41 12.50 611.82 923.50"
*ImageableArea quarto/Quarto: "1.41 12.50 609.82 767.50"
*ImageableArea a5/A5: "1.41 12.50 419.35 582.78"
*ImageableArea a6/A6: "1.41 12.50 297.46 407.03"
*ImageableArea b5/B5: "1.41 12.50 498.72 696.16"
*ImageableArea b6/B6: "1.41 12.50 354.15 486.40"
*ImageableArea c5/C5: "1.41 12.50 459.04 636.63"
*ImageableArea c6/C6: "1.41 12.50 322.97 446.71"
*ImageableArea dl/DL: "1.41 12.50 311.63 611.12"
*ImageableArea comm10/Comm10: "1.41 12.50 296.82 671.50"
*ImageableArea monarch/Monarch: "1.41 12.50 278.82 527.50"
*ImageableArea flsa/Flsa: "1.41 12.50 611.82 923.50"
*ImageableArea flse/Flse: "1.41 12.50 611.82 923.50"

◆ ppd_paper_sizes()

static void ppd_paper_sizes ( struct caps_printing_device_info cpdi)
static

Define the paper size

Parameters
[in]cpdiCollected printing device info
Todo:

PageSize selects the paper tray as well (if known)

PageRegion should be used in conjunction with the manual feed, it does not select any paper tray

DefaultPageRegion can be "Unknown"

ImageableArea depends on portrait or landscape paper entry

DefaultImageableArea can be "Unknown"

MediaType optional, how to define?

Some information I found about their meaning:

https://lists.linux-foundation.org/pipermail/printing-summit/2006/000335.html On Tuesday 07 March 2006 13:43, Alexander Larsson wrote:

‍I'm working on the Gtk+ print dialog, and I have a question about PageSize and PageRegion.

It continues to confuse me, even after years of being exposed to these keywords. Let's see if I can remember correctly (don't have the PPD specs around here right now):

  • PageRegion is meant to be used for describing the imageable area on a sheet that is fed from the "manual tray". (And the manual tray is mean to be able to grokk very weird paper sizes, not fitting into any of the predefined ones...).
  • PageSize is meant to select a specific page size as is defined in the PPD by name. (Internally, PageSize is also an invocation to the physical printer to use an appropriate input slot and reserve an amount of memory in its interpreter to hold the image that will go to the

‍I'm not sure when and how to use these.

Ha!, there are even more "keywords" to be aware of, and which play their role in media selection: ImageableArea, PageSize, InputSlot, PaperDimension, MediaType, MediaColor, MediaWeight,...

Some of these, as well as their finely grained differences are more important for correctly authoring PPD files than for presenting their contents to the user GUI, though. (For the GUI, and for the user to take his picks, only the contents of "*OpenUI....*CloseUi" sections of the PPD are important.)

The ImageableArea is important in so far as it may describe a hard physical limit of the marking engine (which may be unable to print from paper edge to paper edge), and thusly should prevent/warn the application user if she designs a document that violates these limits; and/or the PostScript creation process should take care of these limits too.

MediaType is a way to select a specific medium (like "transparency", or "letterhead") without the user having to know which specific tray holds that medium. This option definitely needs correct setup on the device side first, before it is working correctly – but once set up, I'd expect it to work from the GUI.

MediaColor and MediaWeight are used similarly as MediaType (to select by color or by weight without knowing the actual slot); they also need prior device setup. (Of course, MediaType, MediaColor and MediaWeight keywords are present in only very few PPDs).

PaperDimension defines a paper by size (2 values: width and height), as opposed to by name (like "A4" or "Letter").

About InputSlot, see below...

‍Reading the PPD spec it seems like you're supposed to use PageSize if the user wants a specific page size, and doesn't care from where it comes, and PageRegion if the user specifies a specific InputSlot (and RequiresPageRegion for that slot is true).

PageRegion is for the input slot named as "ManualFeed".

‍However, I'm representing InputSlot as a dropdown selection in the UI, which means that InputSlot is always set (typically to its default value). In most use cases I think the user just wants to pick a page size though. In these cases we should ignore the InputSlot and use PageSize.

You can't "ignore" InputSlot selections. InputSlot and PageSize are two entirely different things. To give a few example data points:

  • Most HP LaserJets for workgroups (as well as most other vendors' equipment) are extensible, and you can add several InputSlots to them by stacking an additional paper tray unit underneath the marking engine unit.
  • These printers then may have up to 10 or more input trays; and each input tray may have flexible guides, that allow loading of different paper sizes (A5, A4, A3, Legal, Letter...).
  • Physical printers may or may not have a "media size autosensing" capability; humans may or may not have to "tell" the printer the mapping of "A4 size is in tray 1, A5 in tray2, and A3 in tray3".
  • You may have 10 trays, each one with white Letter paper; selecting a specific slot may not be of any relevance.
  • You may have 4 trays with different sizes or different paper colors (or letterhead forms), and a user may specifically select one slot specifically to really get the red A3 sheet to print on.
  • PageSize determines how the print "image" is to be sized for each sheet; it is a parameter that the PostScript generating program very often wants to be made aware of before it generates the (PS) printfile. (Here the "ImageableArea" value is also to be considered).
  • Usually, users of such printers know (or are told by their admins) which slot holds which paper type.
  • Some printers will print if "PageSize=A3" and "InputSlot=tray3" is selected even if "tray3" feeds only a A5 paper size (resulting in an "overflowing" image on the sheet); some printers will reject the job and display an error message on their front panel display, or ask for changing tray or load a different paper size.

‍The obvious way to handle this would be to have an "automatic" choice for InputSlot and use PageSize when that is set. I've been looking at various existing ppds it looks like some have "Auto" or "AutoSelect" choices. Is this something i can rely on?

Unfortunately, this is not always implemented correctly in some of the "professional" laser printers as are used in enterprises...

"Autoselect" choices are meant to give the physical printer the freedom to switch paper trays which are loaded with paper of equal sizes "on the fly" (if the first one in use is running out of paper in the middle of the job). You either make sure that all A4 trays of the printer are loaded with paper of the same white color, or you don't care if the paper color changes in the middle of the job from yellow to red since the yellow one was used up.

Pinning a paper tray (using any tray specifically, but not letting the printer do "autoselect") by explicitely choosing it will let the printer stop once that tray is empty (even if it has 5 other trays with the same sizes loaded).

Cheers, Kurt

Todo:
default_format shoud contain a string with the first character in uppercase

Chapter 6.3 of the PPD spec has an example for label printer *MaxMediaWidth, *MaxMediaHeight, *HWMargins should be listed in the PPD

◆ ppp_duplex_print()

static void ppp_duplex_print ( struct caps_printing_device_info cpdi)
static

Create duplex capability on demand

Parameters
[in]cpdiCollected printing device info

◆ ppd_paper_source()

static void ppd_paper_source ( struct caps_printing_device_info cpdi)
static
Parameters
[in]cpdiCollected printing device info

◆ ppd_fonts()

static void ppd_fonts ( struct caps_printing_device_info cpdi)
static
Parameters
[in]cpdiCollected printing device info

Supported fonts must be defined by the PS interpreter and the available fonts

Todo:
This is still a 'to be done'

◆ ppd_cutter_selection()

static __non_null void ppd_cutter_selection ( struct caps_printing_device_info cpdi)
static

Add a cutter selection on demand

Parameters
[in]cpdiCollected printing device info

◆ _caps_ppd_create_ppd()

static void _caps_ppd_create_ppd ( struct caps_printing_device_info cpdi,
const struct caps_ppd_device_info prod_info 
)
static

Create all parts of the PPD based on printer driver's settings

Parameters
[in]cpdiCollected printing device info
[in]prod_infoPrinter device product information. Can be NULL

Variable Documentation

◆ cmodels

const struct color_model_string cmodels[]
static
Initial value:
= {
{ .val = 0, },
{ .val = LIBCAPS_CT_MONOCHROME, .name = "Mono", },
{ .val = LIBCAPS_CT_GRAY, .name = "Gray", },
{ .val = LIBCAPS_CT_RGB, .name = "RGB", },
{ .val = LIBCAPS_CT_CMYK, .name = "CMYK", },
}
@ LIBCAPS_CT_RGB
Definition: libcapsppd.h:204
@ LIBCAPS_CT_GRAY
Definition: libcapsppd.h:203
@ LIBCAPS_CT_MONOCHROME
Definition: libcapsppd.h:202
@ LIBCAPS_CT_CMYK
Definition: libcapsppd.h:205

◆ generic_duplex_entries

struct caps_ppd_selection_entry generic_duplex_entries[]
static
Initial value:
= {
{ .option = "one-sided", .description = ( "Off (1-Sided)" ), },
{ .option = "two-sided-long-edge", .description = ( "Long-Edge (Portrait)" ), },
{ .option = "two-sided-short-edge", .description = ( "Short-Edge (Landscape)" ), },
}

Duplex printing capability choices

The names used here correspond to the keywords used by IPP parameter sides Description

◆ generic_duplex_selection

const struct caps_ppd_selection generic_duplex_selection
static
Initial value:
= {
.option_type = LIBCAPS_OT_PICKONE,
.option = "Duplex",
.description = ( "2-Sided Printing" ),
.entry_count = (sizeof( generic_duplex_entries )/sizeof( generic_duplex_entries [0])),
.default_entry = 0,
}
@ LIBCAPS_OT_PICKONE
Definition: libcapsppd.h:282
static struct caps_ppd_selection_entry generic_duplex_entries[]
Definition: libcapsppd-generator.c:1329

Duplex printing capability selection

◆ manual_feed_selections

struct caps_ppd_selection_entry manual_feed_selections[]
static
Initial value:
= {
{ .option = "Auto", .description = ( "Automatic Selection" ), },
{ .option = "Manual", .description = ( "Manual Feed" ), },
}

Paper source choices, if the printer has a manual feed

◆ manual_feed_selection

const struct caps_ppd_selection manual_feed_selection
static
Initial value:
= {
.option_type = LIBCAPS_OT_PICKONE,
.option = "InputSlot",
.description = ( "Media Source" ),
.entry_count = (sizeof( manual_feed_selections )/sizeof( manual_feed_selections [0])),
.default_entry = 0,
}
static struct caps_ppd_selection_entry manual_feed_selections[]
Definition: libcapsppd-generator.c:1358

Paper source selection, if the printer has a manual feed

◆ generic_cutter_selections

const struct caps_ppd_selection_entry generic_cutter_selections[]
static
Initial value:
= {
{ .option = "False", .description = ( "No" ), },
{ .option = "True", .description = ( "Yes" ), },
}

Let the user select if the cutter should does its work

◆ generic_cutter_selection

const struct caps_ppd_selection generic_cutter_selection
static
Initial value:
= {
.option_type = LIBCAPS_OT_PICKONE,
.option = "CutMedia",
.description = ( "Cut Media" ),
.entry_count = (sizeof( generic_cutter_selections )/sizeof( generic_cutter_selections [0])),
.default_entry = (sizeof( generic_cutter_selections )/sizeof( generic_cutter_selections [0])) - 1,
}
static const struct caps_ppd_selection_entry generic_cutter_selections[]
Definition: libcapsppd-generator.c:1416