3 <!-- SECTION: Programming -->
5 <title>Introduction to the PPD Compiler
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8">
8 <meta name=
"creator" content=
"Mini-XML v2.11">
9 <meta name=
"author" content=
"Unknown">
10 <meta name=
"copyright" content=
"Unknown">
11 <meta name=
"version" content=
"0.0">
12 <style type=
"text/css"><!--
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
17 H1, H2, H3, H4, H5, H6, P, TD, TH {
18 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
22 font-family: monaco, courier, monospace;
27 font-family: monaco, courier, monospace;
31 border-left: solid 2px #777;
40 PRE.command, PRE.example {
67 PRE.command EM, PRE.example EM {
68 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
72 font-family: monaco, courier, monospace;
88 -moz-border-radius: 10px;
93 text-decoration: none;
96 A:link:hover, A:visited:hover, A:active {
97 text-decoration: underline;
104 TR.data, TD.data, TR.data TD {
107 border-bottom: solid 1pt #999999;
111 border-bottom: solid 1pt #999999;
118 border: solid thin #999999;
119 border-collapse: collapse;
135 border: solid thin #cccccc;
142 border-bottom: solid thin #999999;
151 caption-side: bottom;
175 border: thin solid black;
183 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
192 border-bottom: solid 2pt #000000;
195 DIV.indent, TABLE.indent {
203 border-collapse: collapse;
206 TABLE.indent TD, TABLE.indent TH {
211 border-collapse: collapse;
219 border-bottom: solid thin #cccccc;
224 vertical-align: bottom;
233 border-bottom: solid thin #eeeeee;
238 TABLE.list TR:nth-child(even) {
242 TABLE.list TR:nth-child(odd) {
261 font-family: monaco, courier, monospace;
265 border: solid thin #999999;
266 border-collapse: collapse;
271 DIV.summary TABLE TD, DIV.summary TABLE TH {
272 border: solid thin #999999;
278 DIV.summary TABLE THEAD TH {
282 /* API documentation styles... */
294 margin-bottom: 0.5em;
299 margin-bottom: 0.5em;
304 margin-bottom: 0.5em;
309 border: solid thin black;
318 div.contents ul.contents {
322 border-bottom: solid 2px gray;
332 border-bottom: solid 2px gray;
335 border-bottom: solid 2px gray;
347 border-bottom: solid 2px gray;
350 border-bottom: solid 2px gray;
353 border-bottom: solid 2px gray;
357 h1, h2, h3, h4, h5, h6 {
358 page-break-inside: avoid;
361 border: solid thin gray;
362 box-shadow: 3px 3px 5px rgba(0,0,0,0.5);
364 page-break-inside: avoid;
366 p code, li code, p.code, pre, ul.code li {
367 background: rgba(127,127,127,0.1);
368 border: thin dotted gray;
369 font-family: monospace;
372 -webkit-hyphens: manual;
373 page-break-inside: avoid;
375 p.code, pre, ul.code li {
382 text-decoration: none;
386 border: solid thin black;
393 h3 span.info, h4 span.info {
394 border-top-left-radius: 10px;
395 border-top-right-radius: 10px;
399 ul.code, ul.contents, ul.subcontents {
400 list-style-type: none;
410 ul.contents li ul.code, ul.contents li ul.subcontents {
414 border-collapse: collapse;
417 table.list tr:nth-child(even) {
418 background: rgba(127,127,127,0.1);]n}
420 border-right: 2px solid gray;
421 font-family: monospace;
422 padding: 5px 10px 5px 2px;
427 padding: 5px 2px 5px 10px;
434 border-bottom: solid 2px black;
437 border-bottom: solid 2px black;
443 PPD compiler documentation for CUPS.
445 Copyright © 2007-2012 by Apple Inc.
446 Copyright © 1997-2007 by Easy Software Products.
448 Licensed under Apache License v2.0. See the file "LICENSE" for more
452 <h1 class='title'
>Introduction to the PPD Compiler
</h1>
454 <P>This document describes how to use the CUPS PostScript Printer Description
455 (PPD) file compiler. The PPD compiler generates PPD files from simple text files
456 that describe the features and capabilities of one or more printers.
</P>
458 <BLOCKQUOTE><B>Note:
</B>
460 <P>The PPD compiler and related tools are deprecated and will be removed in a future release of CUPS.
</P>
464 <div class='summary'
><table summary='General Information'
>
468 <td>Programming:
<a href='raster-driver.html'
>Developing Raster Printer Drivers
</a><br>
469 Programming:
<a href='postscript-driver.html'
>Developing PostScript Printer Drivers
</a><br>
470 Programming:
<a href='api-filter.html'
>Filter and Backend Programming
</a><br>
471 Programming:
<a href='api-raster.html'
>Raster API
</a><br>
472 References:
<a href='ref-ppdcfile.html'
>PPD Compiler Driver Information File Reference
</a><br>
473 Specifications:
<a href='spec-ppd.html'
>CUPS PPD Extensions
</a></td>
477 <div class=
"contents">
478 <h2 class=
"title">Contents
</h2>
479 <ul class=
"contents">
480 <li><a href=
"#BASICS">The Basics
</a></li>
481 <li><a href=
"#DRV">Driver Information Files
</a><ul class=
"subcontents">
482 <li><a href=
"#SIMPLE">A Simple Example
</a></li>
483 <li><a href=
"#GROUPING">Grouping and Inheritance
</a></li>
484 <li><a href=
"#COLOR">Color Support
</a></li>
485 <li><a href=
"#OPTIONS">Defining Custom Options and Option Groups
</a></li>
486 <li><a href=
"#DEFINE">Defining Constants
</a></li>
487 <li><a href=
"#CONDITIONAL">Conditional Statements
</a></li>
488 <li><a href=
"#CONSTRAINTS">Defining Constraints
</a></li>
490 <li><a href=
"#LOCALIZATION">Localization
</a><ul class=
"subcontents">
491 <li><a href=
"#PPDPO">The ppdpo Utility
</a></li>
492 <li><a href=
"#PPDC_CATALOG">Using Message Catalogs with the PPD Compiler
</a></li>
497 <h2 class='title'
><a name='BASICS'
>The Basics
</a></h2>
499 <P>The PPD compiler,
<a href='man-ppdc.html'
><code>ppdc(
1)
</code></a>, is a
500 simple command-line tool that takes a single
<I>driver information file
</I>,
501 which by convention uses the extension
<VAR>.drv
</VAR>, and produces one or more
502 PPD files that may be distributed with your printer drivers for use with CUPS.
503 For example, you would run the following command to create the English language
504 PPD files defined by the driver information file
<VAR>mydrivers.drv
</VAR>:
</P>
506 <pre class='command'
>
510 <P>The PPD files are placed in a subdirectory called
511 <VAR>ppd
</VAR>. The
<TT>-d
</TT> option is used to put the PPD
512 files in a different location, for example:
</p>
514 <pre class='command'
>
515 ppdc -d myppds mydrivers.drv
518 <P>places the PPD files in a subdirectory named
519 <VAR>myppds
</VAR>. Finally, use the
<TT>-l
</TT> option to
520 specify the language localization for the PPD files that are
521 created, for example:
</P>
523 <pre class='command'
>
524 ppdc -d myppds/de -l de mydrivers.drv
525 ppdc -d myppds/en -l en mydrivers.drv
526 ppdc -d myppds/es -l es mydrivers.drv
527 ppdc -d myppds/fr -l fr mydrivers.drv
528 ppdc -d myppds/it -l it mydrivers.drv
531 <P>creates PPD files in German (de), English (en), Spanish (es),
532 French (fr), and Italian (it) in the corresponding
533 subdirectories. Specify multiple languages (separated by commas) to produce
534 "globalized" PPD files:
</p>
536 <pre class='command'
>
537 ppdc -d myppds -l de,en,es,fr,it mydrivers.drv
541 <h2 class='title'
><a name='DRV'
>Driver Information Files
</a></h2>
543 <P>The driver information files accepted by the PPD compiler are
544 plain text files that define the various attributes and options
545 that are included in the PPD files that are generated. A driver
546 information file can define the information for one or more printers and
547 their corresponding PPD files.
</P>
549 <p class='example'
><a name=
"LISTING1">Listing
1:
"examples/minimum.drv"</a></p>
551 <pre class='example'
>
552 <I>// Include standard font and media definitions
</I>
553 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
554 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
556 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
557 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
559 <I>// Manufacturer, model name, and version
</I>
560 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
561 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
562 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
564 <I>// Each filter provided by the driver...
</I>
565 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
567 <I>// Supported page sizes
</I>
568 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
569 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
571 <I>// Supported resolutions
</I>
572 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
574 <I>// Specify the name of the PPD file we want to generate...
</I>
575 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
579 <h3><a name='SIMPLE'
>A Simple Example
</a></h3>
581 <P>The example in
<A HREF=
"#LISTING1">Listing
1</A> shows a driver information
582 file which defines the minimum required attributes to provide a valid PPD file.
583 The first part of the file includes standard definition files for fonts and
586 <pre class='example'
>
587 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
588 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
591 <P>The
<TT>#include
</TT> directive works just like the C/C++ include directive;
592 files included using the angle brackets (
<TT><filename
></TT>) are found
593 in any of the standard include directories and files included using quotes
594 (
<TT>"filename"</TT>) are found in the same directory as the source or include
595 file. The
<TT><font.defs
></TT> include file defines the standard fonts
596 which are included with GPL Ghostscript and the Apple PDF RIP, while the
597 <TT><media.defs
></TT> include file defines the standard media sizes
598 listed in Appendix B of the Adobe PostScript Printer Description File Format
601 <P>CUPS provides several other standard include files:
</P>
605 <LI><TT><epson.h
></TT> - Defines all of the rastertoepson driver
608 <LI><TT><escp.h
></TT> - Defines all of the rastertoescpx driver
611 <LI><TT><hp.h
></TT> - Defines all of the rastertohp driver
614 <LI><TT><label.h
></TT> - Defines all of the rastertolabel driver
617 <LI><TT><pcl.h
></TT> - Defines all of the rastertopclx driver
620 <LI><TT><raster.defs
></TT> - Defines all of the CUPS raster format
625 <P>Next we list all of the fonts that are available in the driver; for CUPS
626 raster drivers, the following line is all that is usually supplied:
</P>
628 <pre class='example'
>
629 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
632 <P>The
<TT>Font
</TT> directive specifies the name of a single font or the
633 asterisk to specify all fonts. For example, you would use the following line to
634 define an additional bar code font that you are supplying with your printer
637 <pre class='example'
>
638 <I>// name encoding version charset status
</I>
639 <a href='ref-ppdcfile.html#Font'
>Font
</a> Barcode-Foo Special
"(1.0)" Special ROM
642 <P>The name of the font is
<TT>Barcode-Foo
</TT>. Since it is not a standard
643 text font, the encoding and charset name
<TT>Special
</TT> is used. The version
644 number is
<TT>1.0</TT> and the status (where the font is located) is
645 <TT>ROM
</TT> to indicate that the font does not need to be embedded in
646 documents that use the font for this printer.
</P>
648 <P>Third comes the manufacturer, model name, and version number information
651 <pre class='example'
>
652 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
653 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
654 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
657 <P>These strings are used when the user (or auto-configuration program) selects
658 the printer driver for a newly connected device.
</p>
660 <P>The list of filters comes after the information strings; for the example in
661 <A HREF=
"#LISTING1">Listing
1</A>, we have a single filter that takes CUPS
664 <pre class='example'
>
665 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
668 <P>Each filter specified in the driver information file is the equivalent of a
669 printer driver for that format; if a user submits a print job in a different
670 format, CUPS figures out the sequence of commands that will produce a supported
671 format for the least relative cost.
</P>
673 <P>Once we have defined the driver information we specify the supported options.
674 For the example driver we support a single resolution of
600 dots per inch and
675 two media sizes, A4 and Letter:
</P>
677 <pre class='example'
>
678 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
679 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
681 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
684 <P>The asterisk in front of the
<TT>MediaSize
</TT> and
<TT>Resolution
</TT>
685 directives specify that those option choices are the default. The
686 <TT>MediaSize
</TT> directive is followed by a media size name which is normally
687 defined in the
<TT><media.defs
></TT> file and corresponds to a standard
688 Adobe media size name. If the default media size is
<TT>Letter
</TT>, the PPD
689 compiler will override it to be
<TT>A4
</TT> for non-English localizations for
690 you automatically.
</P>
692 <P>The
<TT>Resolution
</TT> directive accepts several values after it as
697 <LI>Colorspace for this resolution, if any. In the example file, the
698 colorspace
<TT>k
</TT> is used which corresponds to black. For printer
699 drivers that support color printing, this field is usually specified as
700 "-" for
"no change".
</LI>
702 <LI>Bits per color. In the example file, we define
8 bits per color, for
703 a continuous-tone grayscale output. All versions of CUPS support
1 and
704 8 bits per color. CUPS
1.2 and higher (macOS
10.5 and higher) also
705 supports
16 bits per color.
</LI>
707 <LI>Rows per band. In the example file, we define
0 rows per band to
708 indicate that our printer driver does not process the page in
711 <LI>Row feed. In the example, we define the feed value to be
0 to
712 indicate that our printer driver does not interleave the output.
</LI>
714 <LI>Row step. In the example, we define the step value to be
0 to
715 indicate that our printer driver does not interleave the output. This
716 value normally indicates the spacing between the nozzles of an inkjet
717 printer - when combined with the previous two values, it informs the
718 driver how to stagger the output on the page to produce interleaved
719 lines on the page for higher-resolution output.
</LI>
721 <LI>Choice name and text. In the example, we define the choice name and
722 text to be
<TT>"600dpi/600 DPI"</TT>. The name and text are separated by
723 slash (
<TT>/
</TT>) character; if no text is specified, then the name is
724 used as the text. The PPD compiler parses the name to determine the
725 actual resolution; the name can be of the form
726 <TT><I>RESOLUTION
</I>dpi
</TT> for resolutions that are equal
727 horizontally and vertically or
<TT><I>HRES
</I>x
<I>VRES
</I>dpi
</TT> for
728 isometric resolutions. Only integer resolution values are supported, so
729 a resolution name of
<TT>300dpi
</TT> is valid while
<TT>300.1dpi
</TT> is
734 <P>Finally, the
<TT>PCFileName
</TT> directive specifies that the named PPD file
735 should be written for the current driver definitions:
</P>
737 <pre class='example'
>
738 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
741 <P>The filename follows the directive and
<I>must
</I> conform to the Adobe
742 filename requirements in the Adobe Postscript Printer Description File Format
743 Specification. Specifically, the filename may not exceed
8 characters followed
744 by the extension
<VAR>.ppd
</VAR>. The
<TT>FileName
</TT> directive can be used to
745 specify longer filenames:
</P>
747 <pre class='example'
>
748 <a href='ref-ppdcfile.html#FileName'
>FileName
</a> "FooJet 2000"
752 <h3><a name='GROUPING'
>Grouping and Inheritance
</a></h3>
754 <P>The previous example created a single PPD file. Driver information files can
755 also define multiple printers by using the PPD compiler grouping functionality.
756 Directives are grouped using the curly braces (
<TT>{
</TT> and
<TT>}
</TT>) and
757 every group that uses the
<TT>PCFileName
</TT> or
<TT>FileName
</TT> directives
758 produces a PPD file with that name.
<A HREF=
"#LISTING2">Listing
2</A> shows a
759 variation of the original example that uses two groups to define two printers
760 that share the same printer driver filter but provide two different resolution
763 <p class='example'
><a name=
"LISTING2">Listing
2:
"examples/grouping.drv"</a></p>
765 <pre class='example'
>
767 <I>// Include standard font and media definitions
</I>
768 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
769 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
771 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
772 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
774 <I>// Manufacturer and version
</I>
775 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
776 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
778 <I>// Each filter provided by the driver...
</I>
779 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
781 <I>// Supported page sizes
</I>
782 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
783 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
786 <I>// Supported resolutions
</I>
787 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
789 <I>// Specify the model name and filename...
</I>
790 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
791 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
795 <I>// Supported resolutions
</I>
796 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "1200dpi/1200 DPI"
798 <I>// Specify the model name and filename...
</I>
799 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
800 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojt2k1.ppd"
804 <P>The second example is essentially the same as the first, except that each
805 printer model is defined inside of a pair of curly braces. For example, the
806 first printer is defined using:
</P>
808 <pre class='example'
>
810 // Supported resolutions
811 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
813 // Specify the model name and filename...
814 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
815 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
819 <P>The printer
<I>inherits
</I> all of the definitions from the parent group (the
820 top part of the file) and adds the additional definitions inside the curly
821 braces for that printer driver. When we define the second group, it also
822 inherits the same definitions from the parent group but
<I>none
</I> of the
823 definitions from the first driver. Groups can be nested to any number of levels
824 to support variations of similar models without duplication of information.
</P>
827 <h3><a name='COLOR'
>Color Support
</a></h3>
829 <P>For printer drivers that support color printing, the
830 <TT>ColorDevice
</TT> and
<TT>ColorModel
</TT> directives should be
831 used to tell the printing system that color output is desired
832 and in what formats.
<A HREF=
"#LISTING3">Listing
3</A> shows a
833 variation of the previous example which includes a color printer
834 that supports printing at
300 and
600 DPI.
</P>
836 <P>The key changes are the addition of the
<TT>ColorDevice
</TT>
839 <pre class='example'
>
840 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
843 <P>which tells the printing system that the printer supports
844 color printing, and the
<TT>ColorModel
</TT> directives:
</P>
846 <pre class='example'
>
847 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
848 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
851 <P>which tell the printing system which colorspaces are supported by the printer
852 driver for color printing. Each of the
<TT>ColorModel
</TT> directives is
853 followed by the option name and text (
<TT>Gray/Grayscale
</TT> and
854 <TT>RGB/Color
</TT>), the colorspace name (
<TT>w
</TT> and
<TT>rgb
</TT>), the
855 color organization (
<TT>chunky
</TT>), and the compression mode number
856 (
<TT>0</TT>) to be passed to the driver. The option name can be any of the
857 standard Adobe
<TT>ColorModel
</TT> names:
</P>
861 <LI><TT>Gray
</TT> - Grayscale output.
863 <LI><TT>RGB
</TT> - Color output, typically using the RGB
864 colorspace, but without a separate black channel.
866 <LI><TT>CMYK
</TT> - Color output with a separate black
871 <P>Custom names can be used, however it is recommended that you use your vendor
872 prefix for any custom names, for example
"fooName".
</P>
874 <P>The colorspace name can be any of the following universally supported
878 <LI><TT>w
</TT> - Luminance
</LI>
880 <LI><TT>rgb
</TT> - Red, green, blue
</LI>
882 <LI><TT>k
</TT> - Black
</LI>
884 <LI><TT>cmy
</TT> - Cyan, magenta, yellow
</LI>
886 <LI><TT>cmyk
</TT> - Cyan, magenta, yellow, black
</LI>
890 <P>The color organization can be any of the following values:
</P>
894 <LI><TT>chunky
</TT> - Color values are passed together on a line
895 as RGB RGB RGB RGB
</LI>
897 <LI><TT>banded
</TT> - Color values are passed separately
898 on a line as RRRR GGGG BBBB; not supported by the Apple
901 <LI><TT>planar
</TT> - Color values are passed separately
902 on a page as RRRR RRRR RRRR ... GGGG GGGG GGGG ... BBBB
903 BBBB BBBB; not supported by the Apple RIP filters
</LI>
907 <P>The compression mode value is passed to the driver in the
908 <TT>cupsCompression
</TT> attribute. It is traditionally used to select an
909 appropriate compression mode for the color model but can be used for any
910 purpose, such as specifying a photo mode vs. standard mode.
</P>
912 <p class='example'
><a name=
"LISTING3">Listing
3:
"examples/color.drv"</a></p>
914 <pre class='example'
>
916 <I>// Include standard font and media definitions
</I>
917 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
918 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
920 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
921 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
923 <I>// Manufacturer and version
</I>
924 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
925 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
927 <I>// Each filter provided by the driver...
</I>
928 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
930 <I>// Supported page sizes
</I>
931 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
932 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
935 <I>// Supported resolutions
</I>
936 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
938 <I>// Specify the model name and filename...
</I>
939 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
940 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
944 <I>// Supports color printing
</I>
945 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
947 <I>// Supported colorspaces
</I>
948 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
949 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
951 <I>// Supported resolutions
</I>
952 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "300dpi/300 DPI"
953 <a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "600dpi/600 DPI"
955 <I>// Specify the model name and filename...
</I>
956 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet Color"
957 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojetco.ppd"
962 <h3><a name='OPTIONS'
>Defining Custom Options and Option Groups
</a></h3>
964 <P>The
<TT>Group
</TT>,
<TT>Option
</TT>, and
<TT>Choice
</TT>
965 directives are used to define or select a group, option, or
966 choice.
<A HREF=
"#LISTING4">Listing
4</A> shows a variation of
967 the first example that provides two custom options in a group
970 <p class='example'
><a name=
"LISTING4">Listing
4:
"examples/custom.drv"</a></p>
972 <pre class='example'
>
974 <I>// Include standard font and media definitions
</I>
975 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
976 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
978 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
979 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
981 <I>// Manufacturer, model name, and version
</I>
982 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
983 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
984 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
986 <I>// Each filter provided by the driver...
</I>
987 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
989 <I>// Supported page sizes
</I>
990 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
991 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
993 <I>// Supported resolutions
</I>
994 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
996 <I>// Option Group
</I>
997 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm"
999 <I>// Boolean option
</I>
1000 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
1001 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
1002 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
1004 <I>// Multiple choice option
</I>
1005 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooOutputType/Output Quality" PickOne AnySetup
10
1006 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Auto/Automatic Selection"
1007 "<</OutputType(Auto)>>setpagedevice""
1008 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Text/Optimize for Text
"
1009 "<</OutputType(Text)
>>setpagedevice
""
1010 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Graph/Optimize for Graphics"
1011 "<</OutputType(Graph)>>setpagedevice""
1012 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Photo/Optimize for Photos
"
1013 "<</OutputType(Photo)
>>setpagedevice
""
1015 <I>// Specify the name of the PPD file we want to generate...
</I>
1016 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
1019 <P>The custom group is introduced by the
<TT>Group
</TT>
1020 directive which is followed by the name and optionally text for
1023 <pre class='example'
>
1024 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm/Footastic Options"
1027 <P>The group name must conform to the PPD specification and
1028 cannot exceed
40 characters in length. If you specify user text,
1029 it cannot exceed
80 characters in length. The groups
1030 <TT>General
</TT>,
<TT>Extra
</TT>, and
1031 <TT>InstallableOptions
</TT> are predefined by CUPS; the general
1032 and extra groups are filled by the UI options defined by the PPD
1033 specification. The
<TT>InstallableOptions
</TT> group is reserved
1034 for options that define whether accessories for the printer
1035 (duplexer unit, finisher, stapler, etc.) are installed.
</P>
1037 <P>Once the group is specified, the
<TT>Option
</TT> directive is
1038 used to introduce a new option:
</P>
1040 <pre class='example'
>
1041 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
1044 <P>The directive is followed by the name of the option and any
1045 optional user text, the option type, the PostScript document group, and
1046 the sort order number. The option name must conform to the PPD specification
1047 and cannot exceed
40 characters in length. If you specify user text, it
1048 cannot exceed
80 characters in length.
</P>
1050 <P>The option type can be
<TT>Boolean
</TT> for true/false
1051 selections,
<TT>PickOne
</TT> for picking one of many choices, or
1052 <TT>PickMany
</TT> for picking zero or more choices. Boolean
1053 options can have at most two choices with the names
1054 <TT>False
</TT> and
<TT>True
</TT>. Pick options can have any
1055 number of choices, although for Windows compatibility reasons
1056 the number of choices should not exceed
255.
</P>
1058 <P>The PostScript document group is typically
<TT>AnySetup
</TT>,
1059 meaning that the option can be introduced at any point in the
1060 PostScript document. Other values include
<TT>PageSetup
</TT> to
1061 include the option before each page and
<TT>DocumentSetup
</TT>
1062 to include the option once at the beginning of the document.
</P>
1064 <P>The sort order number is used to sort the printer commands
1065 associated with each option choice within the PostScript
1066 document. This allows you to setup certain options before others
1067 as required by the printer. For most CUPS raster printer
1068 drivers, the value
<TT>10</TT> can be used for all options.
</P>
1070 <P>Once the option is specified, each option choice can be
1071 listed using the
<TT>Choice
</TT> directive:
</P>
1073 <pre class='example'
>
1074 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
1075 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
1078 <P>The directive is followed by the choice name and optionally
1079 user text, and the PostScript commands that should be inserted
1080 when printing a file to this printer. The option name must
1081 conform to the PPD specification and cannot exceed
40 characters
1082 in length. If you specify user text, it cannot exceed
80
1083 characters in length.
</P>
1085 <P>The PostScript commands are also interpreted by any RIP
1086 filters, so these commands typically must be present for all
1087 option choices. Most commands take the form:
</P>
1089 <pre class='example'
>
1090 <</name value
>>setpagedevice
1093 <P>where
<TT>name
</TT> is the name of the PostScript page device
1094 attribute and
<TT>value
</TT> is the numeric or string value for
1098 <h3><a name='DEFINE'
>Defining Constants
</a></h3>
1100 <P>Sometimes you will want to define constants for your drivers
1101 so that you can share values in different groups within the same
1102 driver information file, or to share values between different
1103 driver information files using the
<TT>#include
</TT> directive.
1104 The
<TT>#define
</TT> directive is used to define constants for
1105 use in your printer definitions:
</P>
1107 <pre class='example'
>
1108 <a href='ref-ppdcfile.html#_define'
>#define
</a> NAME value
1111 <P>The
<TT>NAME
</TT> is any sequence of letters, numbers, and
1112 the underscore. The
<TT>value
</TT> is a number or string; if the
1113 value contains spaces you must put double quotes around it, for
1116 <pre class='example'
>
1117 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO
"My String Value"
1120 <P>Constants can also be defined on the command-line using the
<tt>-D
</tt>
1123 <pre class='command'
>
1124 ppdc
-DNAME=
"value" filename.drv
1127 <P>Once defined, you use the notation
<TT>$NAME
</TT> to substitute the value of
1128 the constant in the file, for example:
</P>
1130 <pre class='example'
>
1131 <a href='ref-ppdcfile.html#_define'
>#define
</a> MANUFACTURER
"Foo"
1132 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_600
0
1133 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_1200
1
1136 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1137 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_600
1138 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1143 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1144 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_1200
1145 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
1150 <P>Numeric constants can be bitwise OR'd together by placing the constants
1151 inside parenthesis, for example:
</P>
1153 <pre class='example'
>
1154 <I>// ModelNumber capability bits
</I>
1155 <a href='ref-ppdcfile.html#_define'
>#define
</a> DUPLEX
1
1156 <a href='ref-ppdcfile.html#_define'
>#define
</a> COLOR
2
1161 <I>// Define a model number specifying the capabilities of the printer...
</I>
1162 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> ($DUPLEX $COLOR)
1168 <h3><a name='CONDITIONAL'
>Conditional Statements
</a></h3>
1170 <p>The PPD compiler supports conditional compilation using the
<tt>#if
</tt>,
1171 <tt>#elif
</tt>,
<tt>#else
</tt>, and
<tt>#endif
</tt> directives. The
<tt>#if
</tt>
1172 and
<tt>#elif
</tt> directives are followed by a constant name or an expression.
1173 For example, to include a group of options when
"ADVANCED" is defined:
</p>
1175 <pre class='example'
>
1176 <a href='ref-ppdcfile.html#_if'
>#if
</a> ADVANCED
1177 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Advanced/Advanced Options"
1178 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooCyanAdjust/Cyan Adjustment"
1179 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1180 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1181 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1182 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1183 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1184 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooMagentaAdjust/Magenta Adjustment"
1185 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1186 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1187 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1188 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1189 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1190 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooYellowAdjust/Yellow Adjustment"
1191 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1192 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1193 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1194 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1195 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1196 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooBlackAdjust/Black Adjustment"
1197 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1198 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1199 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1200 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1201 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1202 <a href='ref-ppdcfile.html#_endif'
>#endif
</a>
1206 <h3><a name='CONSTRAINTS'
>Defining Constraints
</a></h3>
1208 <P>Constraints are strings that are used to specify that one or more option
1209 choices are incompatible, for example two-sided printing on transparency media.
1210 Constraints are also used to prevent the use of uninstalled features such as the
1211 duplexer unit, additional media trays, and so forth.
</P>
1213 <P>The
<TT>UIConstraints
</TT> directive is used to specify a constraint that is
1214 placed in the PPD file. The directive is followed by a string using one of the
1215 following formats:
</P>
1217 <pre class='example'
>
1218 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2"
1219 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2"
1220 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2 Choice2"
1221 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2 Choice2"
1224 <P>Each option name is preceded by the asterisk (
<TT>*
</TT>). If no choice is
1225 given for an option, then all choices
<I>except
</I> <TT>False
</TT> and
1226 <TT>None
</TT> will conflict with the other option and choice(s). Since the PPD
1227 compiler automatically adds reciprocal constraints (option A conflicts with
1228 option B, so therefore option B conflicts with option A), you need only specify
1229 the constraint once.
</P>
1231 <p class='example'
><a name=
"LISTING5">Listing
5:
"examples/constraint.drv"</a></p>
1233 <pre class='example'
>
1235 <I>// Include standard font and media definitions
</I>
1236 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
1237 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
1239 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
1240 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
1242 <I>// Manufacturer, model name, and version
</I>
1243 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
1244 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1245 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
1247 <I>// Each filter provided by the driver...
</I>
1248 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
1250 <I>// Supported page sizes
</I>
1251 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
1252 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
1254 <I>// Supported resolutions
</I>
1255 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
1257 <I>// Installable Option Group
</I>
1258 <a href='ref-ppdcfile.html#Group'
>Group
</a> "InstallableOptions/Options Installed"
1260 <I>// Duplexing unit option
</I>
1261 <a href='ref-ppdcfile.html#Option'
>Option
</a> "OptionDuplexer/Duplexing Unit" Boolean AnySetup
10
1262 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Installed
""
1263 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "False/Not Installed" ""
1265 <I>// General Option Group
</I>
1266 <a href='ref-ppdcfile.html#Group'
>Group
</a> General
1268 <I>// Duplexing option
</I>
1269 <a href='ref-ppdcfile.html#Option'
>Option
</a> "Duplex/Two-Sided Printing" PickOne AnySetup
10
1270 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "None/No" "<</Duplex false>>setpagedevice""
1271 <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexNoTumble/Long Edge Binding
"
1272 "<</Duplex true/Tumble false
>>setpagedevice
""
1273 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "DuplexTumble/Short Edge Binding"
1274 "<</Duplex true/Tumble true>>setpagedevice""
1276 <I>// Only allow duplexing if the duplexer is installed</I>
1277 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1279 <I>// Specify the name of the PPD file we want to generate...</I>
1280 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd
"
1283 <P><A HREF="#LISTING5
">Listing 5</A> shows a variation of the first example with
1284 an added <TT>Duplex</TT> option and installable option for the duplexer,
1285 <TT>OptionDuplex</TT>. A constraint is added at the end to specify that any
1286 choice of the <TT>Duplex</TT> option that is not <TT>None</TT> is incompatible
1287 with the "Duplexer Installed
" option set to "Not Installed
"
1288 (<TT>False</TT>):</P>
1290 <pre class='example'>
1291 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1294 <h4>Enhanced Constraints</h4>
1296 <p>CUPS 1.4 supports constraints between 2 or more options using the
1297 <TT>Attribute</TT> directive. <TT>cupsUIConstraints</TT> attributes define
1298 the constraints, while <TT>cupsUIResolver</TT> attributes define option changes
1299 to resolve constraints. For example, we can specify the previous duplex
1300 constraint with a resolver that turns off duplexing with the following two
1303 <pre class='example'>
1304 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIConstraints DuplexOff "*Duplex *OptionDuplexer False
"
1305 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIResolver DuplexOff "*Duplex None
"
1308 <h2 class='title'><a name='LOCALIZATION'>Localization</a></h2>
1310 <p>The PPD compiler provides localization of PPD files in different languages
1311 through <i>message catalog</i> files in the GNU gettext or Apple .strings
1312 formats. Each user text string and several key PPD attribute values such as
1313 <tt>LanguageVersion</tt> and <tt>LanguageEncoding</tt> are looked up in the
1314 corresponding message catalog and the translated text is substituted in the
1315 generated PPD files. One message catalog file can be used by multiple driver
1316 information files, and each file contains a single language translation.</p>
1318 <h3><a name='PPDPO'>The ppdpo Utility</a></h3>
1320 <p>While CUPS includes localizations of all standard media sizes and options in
1321 several languages, your driver information files may provide their own media
1322 sizes and options that need to be localized. CUPS provides a utility program to
1323 aid in the localization of drivers called <a
1324 href='man-ppdpo.html'><tt>ppdpo(1)</tt></a>. The <tt>ppdpo</tt> program creates
1325 or updates a message catalog file based upon one or more driver information
1326 files. New messages are added with the word "TRANSLATE
" added to the front of
1327 the translation string to make locating new strings for translation easier. The
1328 program accepts the message catalog filename and one or more driver information
1331 <p>For example, run the following command to create a new German message catalog
1332 called <var>de.po</var> for all of the driver information files in the current
1335 <pre class='command'>
1336 ppdpo -o de.po *.drv
1339 <p>If the file <var>de.po</var> already exists, <tt>ppdpo</tt> will update the
1340 contents of the file with any new messages that need to be translated. To create
1341 an Apple .strings file instead, specify the output filename with a .strings
1342 extension, for example:</p>
1344 <pre class='command'>
1345 ppdpo -o de.strings *.drv
1348 <h3><a name='PPDC_CATALOG'>Using Message Catalogs with the PPD Compiler</a></h3>
1350 <p>Once you have created a message catalog, use the <a
1351 href='ref-ppdcfile.html#_po'><tt>#po</tt></a> directive to declare it in each
1352 driver information file. For example, to declare the German message catalog for
1355 <pre class='example'>
1356 <a href='ref-ppdcfile.html#_po'>#po</a> de "de.po
" // German
1359 <p>In fact, you can use the <tt>#po</tt> directive as many times as needed:</p>
1361 <pre class='example'>
1362 <a href='ref-ppdcfile.html#_po'>#po</a> de "de.po
" // German
1363 <a href='ref-ppdcfile.html#_po'>#po</a> es "es.po
" // Spanish
1364 <a href='ref-ppdcfile.html#_po'>#po</a> fr "fr.po
" // French
1365 <a href='ref-ppdcfile.html#_po'>#po</a> it "it.po
" // Italian
1366 <a href='ref-ppdcfile.html#_po'>#po</a> ja "ja.po
" // Japanese
1369 <p>The filename ("de.po
", etc.) can be relative to the location of the driver
1370 information file or an absolute path. Once defined, the PPD compiler will
1371 automatically generate a globalized PPD for every language declared in your
1372 driver information file. To generate a single-language PPD file, simply use the
1373 <tt>-l</tt> option to list the corresponding locale, for example:</p>
1375 <pre class='command'>
1376 ppdc -l de -d ppd/de mydrivers.drv
1379 <p>to generate German PPD files.</p>