1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- SECTION: Programming -->
5 <title>Introduction to the PPD Compiler
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta name=
"creator" content=
"Mini-XML v2.6">
8 <style type=
"text/css"><!--
10 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
13 H1, H2, H3, H4, H5, H6, P, TD, TH {
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
18 font-family: monaco, courier, monospace;
23 font-family: monaco, courier, monospace;
41 border: dotted thin #999999;
46 PRE.command EM, PRE.example EM {
47 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
51 font-family: monaco, courier, monospace;
62 border: solid thin #999999;
73 -moz-border-radius: 10px;
78 text-decoration: none;
81 A:link:hover, A:visited:hover, A:active {
82 text-decoration: underline;
89 TR.data, TD.data, TR.data TD {
92 border-bottom: solid 1pt #999999;
96 border-bottom: solid 1pt #999999;
103 border: solid thin #999999;
104 border-collapse: collapse;
120 border: solid thin #cccccc;
127 border-bottom: solid thin #999999;
136 caption-side: bottom;
160 border: thin solid black;
168 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
177 border-bottom: solid 2pt #000000;
180 DIV.indent, TABLE.indent {
188 border-collapse: collapse;
191 TABLE.indent TD, TABLE.indent TH {
196 border-collapse: collapse;
204 border-bottom: solid thin #cccccc;
209 vertical-align: bottom;
218 border-bottom: solid thin #eeeeee;
223 TABLE.list TR:nth-child(even) {
227 TABLE.list TR:nth-child(odd) {
246 font-family: monaco, courier, monospace;
250 border: solid thin #999999;
251 border-collapse: collapse;
256 DIV.summary TABLE TD, DIV.summary TABLE TH {
257 border: solid thin #999999;
263 DIV.summary TABLE THEAD TH {
267 /* API documentation styles... */
274 div.body h3, div.body h4, div.body h5 {
275 margin-bottom: 0.5em;
278 .class, .enumeration, .function, .struct, .typedef, .union {
279 border-bottom: solid thin #999999;
286 code, p.code, pre, ul.code li {
287 font-family: monaco, courier, monospace;
290 ul.code, ul.contents, ul.subcontents {
291 list-style-type: none;
301 ul.contents li ul.code, ul.contents li ul.subcontents {
314 margin-bottom: 0.5em;
317 /* This is just for the HTML files generated with the framedhelp target */
320 border: solid thin black;
329 div.contents ul.contents {
332 div.contents ul.subcontents li {
340 <h1 class='title'
>Introduction to the PPD Compiler
</h1>
342 <P>This document describes how to use the CUPS PostScript Printer Description
343 (PPD) file compiler. The PPD compiler generates PPD files from simple text files
344 that describe the features and capabilities of one or more printers.
</P>
346 <div class='summary'
><table summary='General Information'
>
350 <td>Programming:
<a href='raster-driver.html'
>Developing Raster Printer Drivers
</a><br>
351 Programming:
<a href='postscript-driver.html'
>Developing PostScript Printer Drivers
</a><br>
352 Programming:
<a href='api-filter.html'
>Filter and Backend Programming
</a><br>
353 Programming:
<a href='api-raster.html'
>Raster API
</a><br>
354 References:
<a href='ref-ppdcfile.html'
>PPD Compiler Driver Information File Reference
</a><br>
355 Specifications:
<a href='spec-ppd.html'
>CUPS PPD Extensions
</a></td>
359 <h2 class=
"title">Contents
</h2>
360 <ul class=
"contents">
361 <ul class=
"subcontents">
362 <li><a href=
"#BASICS">The Basics
</a></li>
363 <li><a href=
"#DRV">Driver Information Files
</a><ul class=
"subcontents">
364 <li><a href=
"#SIMPLE">A Simple Example
</a></li>
365 <li><a href=
"#GROUPING">Grouping and Inheritance
</a></li>
366 <li><a href=
"#COLOR">Color Support
</a></li>
367 <li><a href=
"#OPTIONS">Defining Custom Options and Option Groups
</a></li>
368 <li><a href=
"#DEFINE">Defining Constants
</a></li>
369 <li><a href=
"#CONDITIONAL">Conditional Statements
</a></li>
370 <li><a href=
"#CONSTRAINTS">Defining Constraints
</a></li>
372 <li><a href=
"#LOCALIZATION">Localization
</a><ul class=
"subcontents">
373 <li><a href=
"#PPDPO">The ppdpo Utility
</a></li>
374 <li><a href=
"#PPDC_CATALOG">Using Message Catalogs with the PPD Compiler
</a></li>
376 <h2 class='title'
><a name='BASICS'
>The Basics
</a></h2>
378 <P>The PPD compiler,
<a href='man-ppdc.html'
><code>ppdc(
1)
</code></a>, is a
379 simple command-line tool that takes a single
<I>driver information file
</I>,
380 which by convention uses the extension
<VAR>.drv
</VAR>, and produces one or more
381 PPD files that may be distributed with your printer drivers for use with CUPS.
382 For example, you would run the following command to create the English language
383 PPD files defined by the driver information file
<VAR>mydrivers.drv
</VAR>:
</P>
385 <pre class='command'
>
389 <P>The PPD files are placed in a subdirectory called
390 <VAR>ppd
</VAR>. The
<TT>-d
</TT> option is used to put the PPD
391 files in a different location, for example:
</p>
393 <pre class='command'
>
394 ppdc -d myppds mydrivers.drv
397 <P>places the PPD files in a subdirectory named
398 <VAR>myppds
</VAR>. Finally, use the
<TT>-l
</TT> option to
399 specify the language localization for the PPD files that are
400 created, for example:
</P>
402 <pre class='command'
>
403 ppdc -d myppds/de -l de mydrivers.drv
404 ppdc -d myppds/en -l en mydrivers.drv
405 ppdc -d myppds/es -l es mydrivers.drv
406 ppdc -d myppds/fr -l fr mydrivers.drv
407 ppdc -d myppds/it -l it mydrivers.drv
410 <P>creates PPD files in German (de), English (en), Spanish (es),
411 French (fr), and Italian (it) in the corresponding
412 subdirectories. Specify multiple languages (separated by commas) to produce
413 "globalized" PPD files:
</p>
415 <pre class='command'
>
416 ppdc -d myppds -l de,en,es,fr,it mydrivers.drv
420 <h2 class='title'
><a name='DRV'
>Driver Information Files
</a></h2>
422 <P>The driver information files accepted by the PPD compiler are
423 plain text files that define the various attributes and options
424 that are included in the PPD files that are generated. A driver
425 information file can define the information for one or more printers and
426 their corresponding PPD files.
</P>
428 <p class='example'
><a name=
"LISTING1">Listing
1:
"examples/minimum.drv"</a></p>
430 <pre class='example'
>
431 <I>// Include standard font and media definitions
</I>
432 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
433 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
435 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
436 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
438 <I>// Manufacturer, model name, and version
</I>
439 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
440 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
441 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
443 <I>// Each filter provided by the driver...
</I>
444 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
446 <I>// Supported page sizes
</I>
447 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
448 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
450 <I>// Supported resolutions
</I>
451 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
453 <I>// Specify the name of the PPD file we want to generate...
</I>
454 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
458 <h3><a name='SIMPLE'
>A Simple Example
</a></h3>
460 <P>The example in
<A HREF=
"#LISTING1">Listing
1</A> shows a driver information
461 file which defines the minimum required attributes to provide a valid PPD file.
462 The first part of the file includes standard definition files for fonts and
465 <pre class='example'
>
466 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
467 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
470 <P>The
<TT>#include
</TT> directive works just like the C/C++ include directive;
471 files included using the angle brackets (
<TT><filename
></TT>) are found
472 in any of the standard include directories and files included using quotes
473 (
<TT>"filename"</TT>) are found in the same directory as the source or include
474 file. The
<TT><font.defs
></TT> include file defines the standard fonts
475 which are included with GPL Ghostscript and the Apple PDF RIP, while the
476 <TT><media.defs
></TT> include file defines the standard media sizes
477 listed in Appendix B of the Adobe PostScript Printer Description File Format
480 <P>CUPS provides several other standard include files:
</P>
484 <LI><TT><epson.h
></TT> - Defines all of the rastertoepson driver
487 <LI><TT><escp.h
></TT> - Defines all of the rastertoescpx driver
490 <LI><TT><hp.h
></TT> - Defines all of the rastertohp driver
493 <LI><TT><label.h
></TT> - Defines all of the rastertolabel driver
496 <LI><TT><pcl.h
></TT> - Defines all of the rastertopclx driver
499 <LI><TT><raster.defs
></TT> - Defines all of the CUPS raster format
504 <P>Next we list all of the fonts that are available in the driver; for CUPS
505 raster drivers, the following line is all that is usually supplied:
</P>
507 <pre class='example'
>
508 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
511 <P>The
<TT>Font
</TT> directive specifies the name of a single font or the
512 asterisk to specify all fonts. For example, you would use the following line to
513 define an additional bar code font that you are supplying with your printer
516 <pre class='example'
>
517 <I>// name encoding version charset status
</I>
518 <a href='ref-ppdcfile.html#Font'
>Font
</a> Barcode-Foo Special
"(1.0)" Special ROM
521 <P>The name of the font is
<TT>Barcode-Foo
</TT>. Since it is not a standard
522 text font, the encoding and charset name
<TT>Special
</TT> is used. The version
523 number is
<TT>1.0</TT> and the status (where the font is located) is
524 <TT>ROM
</TT> to indicate that the font does not need to be embedded in
525 documents that use the font for this printer.
</P>
527 <P>Third comes the manufacturer, model name, and version number information
530 <pre class='example'
>
531 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
532 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
533 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
536 <P>These strings are used when the user (or auto-configuration program) selects
537 the printer driver for a newly connected device.
</p>
539 <P>The list of filters comes after the information strings; for the example in
540 <A HREF=
"#LISTING1">Listing
1</A>, we have a single filter that takes CUPS
543 <pre class='example'
>
544 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
547 <P>Each filter specified in the driver information file is the equivalent of a
548 printer driver for that format; if a user submits a print job in a different
549 format, CUPS figures out the sequence of commands that will produce a supported
550 format for the least relative cost.
</P>
552 <P>Once we have defined the driver information we specify the supported options.
553 For the example driver we support a single resolution of
600 dots per inch and
554 two media sizes, A4 and Letter:
</P>
556 <pre class='example'
>
557 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
558 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
560 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
563 <P>The asterisk in front of the
<TT>MediaSize
</TT> and
<TT>Resolution
</TT>
564 directives specify that those option choices are the default. The
565 <TT>MediaSize
</TT> directive is followed by a media size name which is normally
566 defined in the
<TT><media.defs
></TT> file and corresponds to a standard
567 Adobe media size name. If the default media size is
<TT>Letter
</TT>, the PPD
568 compiler will override it to be
<TT>A4
</TT> for non-English localizations for
569 you automatically.
</P>
571 <P>The
<TT>Resolution
</TT> directive accepts several values after it as
576 <LI>Colorspace for this resolution, if any. In the example file, the
577 colorspace
<TT>k
</TT> is used which corresponds to black. For printer
578 drivers that support color printing, this field is usually specified as
579 "-" for
"no change".
</LI>
581 <LI>Bits per color. In the example file, we define
8 bits per color, for
582 a continuous-tone grayscale output. All versions of CUPS support
1 and
583 8 bits per color. CUPS
1.2 and higher (Mac OS X
10.5 and higher) also
584 supports
16 bits per color.
</LI>
586 <LI>Rows per band. In the example file, we define
0 rows per band to
587 indicate that our printer driver does not process the page in
590 <LI>Row feed. In the example, we define the feed value to be
0 to
591 indicate that our printer driver does not interleave the output.
</LI>
593 <LI>Row step. In the example, we define the step value to be
0 to
594 indicate that our printer driver does not interleave the output. This
595 value normally indicates the spacing between the nozzles of an inkjet
596 printer - when combined with the previous two values, it informs the
597 driver how to stagger the output on the page to produce interleaved
598 lines on the page for higher-resolution output.
</LI>
600 <LI>Choice name and text. In the example, we define the choice name and
601 text to be
<TT>"600dpi/600 DPI"</TT>. The name and text are separated by
602 slash (
<TT>/
</TT>) character; if no text is specified, then the name is
603 used as the text. The PPD compiler parses the name to determine the
604 actual resolution; the name can be of the form
605 <TT><I>RESOLUTION
</I>dpi
</TT> for resolutions that are equal
606 horizontally and vertically or
<TT><I>HRES
</I>x
<I>VRES
</I>dpi
</TT> for
607 isometric resolutions. Only integer resolution values are supported, so
608 a resolution name of
<TT>300dpi
</TT> is valid while
<TT>300.1dpi
</TT> is
613 <P>Finally, the
<TT>PCFileName
</TT> directive specifies that the named PPD file
614 should be written for the current driver definitions:
</P>
616 <pre class='example'
>
617 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
620 <P>The filename follows the directive and
<I>must
</I> conform to the Adobe
621 filename requirements in the Adobe Postscript Printer Description File Format
622 Specification. Specifically, the filename may not exceed
8 characters followed
623 by the extension
<VAR>.ppd
</VAR>. The
<TT>FileName
</TT> directive can be used to
624 specify longer filenames:
</P>
626 <pre class='example'
>
627 <a href='ref-ppdcfile.html#FileName'
>FileName
</a> "FooJet 2000"
631 <h3><a name='GROUPING'
>Grouping and Inheritance
</a></h3>
633 <P>The previous example created a single PPD file. Driver information files can
634 also define multiple printers by using the PPD compiler grouping functionality.
635 Directives are grouped using the curly braces (
<TT>{
</TT> and
<TT>}
</TT>) and
636 every group that uses the
<TT>PCFileName
</TT> or
<TT>FileName
</TT> directives
637 produces a PPD file with that name.
<A HREF=
"#LISTING2">Listing
2</A> shows a
638 variation of the original example that uses two groups to define two printers
639 that share the same printer driver filter but provide two different resolution
642 <p class='example'
><a name=
"LISTING2">Listing
2:
"examples/grouping.drv"</a></p>
644 <pre class='example'
>
646 <I>// Include standard font and media definitions
</I>
647 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
648 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
650 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
651 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
653 <I>// Manufacturer and version
</I>
654 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
655 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
657 <I>// Each filter provided by the driver...
</I>
658 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
660 <I>// Supported page sizes
</I>
661 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
662 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
665 <I>// Supported resolutions
</I>
666 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
668 <I>// Specify the model name and filename...
</I>
669 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
670 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
674 <I>// Supported resolutions
</I>
675 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "1200dpi/1200 DPI"
677 <I>// Specify the model name and filename...
</I>
678 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
679 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojt2k1.ppd"
683 <P>The second example is essentially the same as the first, except that each
684 printer model is defined inside of a pair of curly braces. For example, the
685 first printer is defined using:
</P>
687 <pre class='example'
>
689 // Supported resolutions
690 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
692 // Specify the model name and filename...
693 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
694 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
698 <P>The printer
<I>inherits
</I> all of the definitions from the parent group (the
699 top part of the file) and adds the additional definitions inside the curly
700 braces for that printer driver. When we define the second group, it also
701 inherits the same definitions from the parent group but
<I>none
</I> of the
702 definitions from the first driver. Groups can be nested to any number of levels
703 to support variations of similar models without duplication of information.
</P>
706 <h3><a name='COLOR'
>Color Support
</a></h3>
708 <P>For printer drivers that support color printing, the
709 <TT>ColorDevice
</TT> and
<TT>ColorModel
</TT> directives should be
710 used to tell the printing system that color output is desired
711 and in what formats.
<A HREF=
"#LISTING3">Listing
3</A> shows a
712 variation of the previous example which includes a color printer
713 that supports printing at
300 and
600 DPI.
</P>
715 <P>The key changes are the addition of the
<TT>ColorDevice
</TT>
718 <pre class='example'
>
719 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
722 <P>which tells the printing system that the printer supports
723 color printing, and the
<TT>ColorModel
</TT> directives:
</P>
725 <pre class='example'
>
726 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
727 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
730 <P>which tell the printing system which colorspaces are supported by the printer
731 driver for color printing. Each of the
<TT>ColorModel
</TT> directives is
732 followed by the option name and text (
<TT>Gray/Grayscale
</TT> and
733 <TT>RGB/Color
</TT>), the colorspace name (
<TT>w
</TT> and
<TT>rgb
</TT>), the
734 color organization (
<TT>chunky
</TT>), and the compression mode number
735 (
<TT>0</TT>) to be passed to the driver. The option name can be any of the
736 standard Adobe
<TT>ColorModel
</TT> names:
</P>
740 <LI><TT>Gray
</TT> - Grayscale output.
742 <LI><TT>RGB
</TT> - Color output, typically using the RGB
743 colorspace, but without a separate black channel.
745 <LI><TT>CMYK
</TT> - Color output with a separate black
750 <P>Custom names can be used, however it is recommended that you use your vendor
751 prefix for any custom names, for example
"fooName".
</P>
753 <P>The colorspace name can be any of the following universally supported
757 <LI><TT>w
</TT> - Luminance
</LI>
759 <LI><TT>rgb
</TT> - Red, green, blue
</LI>
761 <LI><TT>k
</TT> - Black
</LI>
763 <LI><TT>cmy
</TT> - Cyan, magenta, yellow
</LI>
765 <LI><TT>cmyk
</TT> - Cyan, magenta, yellow, black
</LI>
769 <P>The color organization can be any of the following values:
</P>
773 <LI><TT>chunky
</TT> - Color values are passed together on a line
774 as RGB RGB RGB RGB
</LI>
776 <LI><TT>banded
</TT> - Color values are passed separately
777 on a line as RRRR GGGG BBBB; not supported by the Apple
780 <LI><TT>planar
</TT> - Color values are passed separately
781 on a page as RRRR RRRR RRRR ... GGGG GGGG GGGG ... BBBB
782 BBBB BBBB; not supported by the Apple RIP filters
</LI>
786 <P>The compression mode value is passed to the driver in the
787 <TT>cupsCompression
</TT> attribute. It is traditionally used to select an
788 appropriate compression mode for the color model but can be used for any
789 purpose, such as specifying a photo mode vs. standard mode.
</P>
791 <p class='example'
><a name=
"LISTING3">Listing
3:
"examples/color.drv"</a></p>
793 <pre class='example'
>
795 <I>// Include standard font and media definitions
</I>
796 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
797 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
799 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
800 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
802 <I>// Manufacturer and version
</I>
803 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
804 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
806 <I>// Each filter provided by the driver...
</I>
807 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
809 <I>// Supported page sizes
</I>
810 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
811 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
814 <I>// Supported resolutions
</I>
815 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
817 <I>// Specify the model name and filename...
</I>
818 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
819 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
823 <I>// Supports color printing
</I>
824 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
826 <I>// Supported colorspaces
</I>
827 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
828 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
830 <I>// Supported resolutions
</I>
831 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "300dpi/300 DPI"
832 <a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "600dpi/600 DPI"
834 <I>// Specify the model name and filename...
</I>
835 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet Color"
836 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojetco.ppd"
841 <h3><a name='OPTIONS'
>Defining Custom Options and Option Groups
</a></h3>
843 <P>The
<TT>Group
</TT>,
<TT>Option
</TT>, and
<TT>Choice
</TT>
844 directives are used to define or select a group, option, or
845 choice.
<A HREF=
"#LISTING4">Listing
4</A> shows a variation of
846 the first example that provides two custom options in a group
849 <p class='example'
><a name=
"LISTING4">Listing
4:
"examples/custom.drv"</a></p>
851 <pre class='example'
>
853 <I>// Include standard font and media definitions
</I>
854 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
855 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
857 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
858 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
860 <I>// Manufacturer, model name, and version
</I>
861 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
862 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
863 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
865 <I>// Each filter provided by the driver...
</I>
866 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
868 <I>// Supported page sizes
</I>
869 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
870 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
872 <I>// Supported resolutions
</I>
873 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
875 <I>// Option Group
</I>
876 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm"
878 <I>// Boolean option
</I>
879 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
880 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
881 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
883 <I>// Multiple choice option
</I>
884 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooOutputType/Output Quality" PickOne AnySetup
10
885 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Auto/Automatic Selection"
886 "<</OutputType(Auto)>>setpagedevice""
887 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Text/Optimize for Text
"
888 "<</OutputType(Text)
>>setpagedevice
""
889 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Graph/Optimize for Graphics"
890 "<</OutputType(Graph)>>setpagedevice""
891 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Photo/Optimize for Photos
"
892 "<</OutputType(Photo)
>>setpagedevice
""
894 <I>// Specify the name of the PPD file we want to generate...
</I>
895 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
898 <P>The custom group is introduced by the
<TT>Group
</TT>
899 directive which is followed by the name and optionally text for
902 <pre class='example'
>
903 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm/Footastic Options"
906 <P>The group name must conform to the PPD specification and
907 cannot exceed
40 characters in length. If you specify user text,
908 it cannot exceed
80 characters in length. The groups
909 <TT>General
</TT>,
<TT>Extra
</TT>, and
910 <TT>InstallableOptions
</TT> are predefined by CUPS; the general
911 and extra groups are filled by the UI options defined by the PPD
912 specification. The
<TT>InstallableOptions
</TT> group is reserved
913 for options that define whether accessories for the printer
914 (duplexer unit, finisher, stapler, etc.) are installed.
</P>
916 <P>Once the group is specified, the
<TT>Option
</TT> directive is
917 used to introduce a new option:
</P>
919 <pre class='example'
>
920 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
923 <P>The directive is followed by the name of the option and any
924 optional user text, the option type, the PostScript document group, and
925 the sort order number. The option name must conform to the PPD specification
926 and cannot exceed
40 characters in length. If you specify user text, it
927 cannot exceed
80 characters in length.
</P>
929 <P>The option type can be
<TT>Boolean
</TT> for true/false
930 selections,
<TT>PickOne
</TT> for picking one of many choices, or
931 <TT>PickMany
</TT> for picking zero or more choices. Boolean
932 options can have at most two choices with the names
933 <TT>False
</TT> and
<TT>True
</TT>. Pick options can have any
934 number of choices, although for Windows compatibility reasons
935 the number of choices should not exceed
255.
</P>
937 <P>The PostScript document group is typically
<TT>AnySetup
</TT>,
938 meaning that the option can be introduced at any point in the
939 PostScript document. Other values include
<TT>PageSetup
</TT> to
940 include the option before each page and
<TT>DocumentSetup
</TT>
941 to include the option once at the beginning of the document.
</P>
943 <P>The sort order number is used to sort the printer commands
944 associated with each option choice within the PostScript
945 document. This allows you to setup certain options before others
946 as required by the printer. For most CUPS raster printer
947 drivers, the value
<TT>10</TT> can be used for all options.
</P>
949 <P>Once the option is specified, each option choice can be
950 listed using the
<TT>Choice
</TT> directive:
</P>
952 <pre class='example'
>
953 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
954 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
957 <P>The directive is followed by the choice name and optionally
958 user text, and the PostScript commands that should be inserted
959 when printing a file to this printer. The option name must
960 conform to the PPD specification and cannot exceed
40 characters
961 in length. If you specify user text, it cannot exceed
80
962 characters in length.
</P>
964 <P>The PostScript commands are also interpreted by any RIP
965 filters, so these commands typically must be present for all
966 option choices. Most commands take the form:
</P>
968 <pre class='example'
>
969 <</name value
>>setpagedevice
972 <P>where
<TT>name
</TT> is the name of the PostScript page device
973 attribute and
<TT>value
</TT> is the numeric or string value for
977 <h3><a name='DEFINE'
>Defining Constants
</a></h3>
979 <P>Sometimes you will want to define constants for your drivers
980 so that you can share values in different groups within the same
981 driver information file, or to share values between different
982 driver information files using the
<TT>#include
</TT> directive.
983 The
<TT>#define
</TT> directive is used to define constants for
984 use in your printer definitions:
</P>
986 <pre class='example'
>
987 <a href='ref-ppdcfile.html#_define'
>#define
</a> NAME value
990 <P>The
<TT>NAME
</TT> is any sequence of letters, numbers, and
991 the underscore. The
<TT>value
</TT> is a number or string; if the
992 value contains spaces you must put double quotes around it, for
995 <pre class='example'
>
996 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO
"My String Value"
999 <P>Constants can also be defined on the command-line using the
<tt>-D
</tt>
1002 <pre class='command'
>
1003 ppdc
-DNAME=
"value" filename.drv
1006 <P>Once defined, you use the notation
<TT>$NAME
</TT> to substitute the value of
1007 the constant in the file, for example:
</P>
1009 <pre class='example'
>
1010 <a href='ref-ppdcfile.html#_define'
>#define
</a> MANUFACTURER
"Foo"
1011 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_600
0
1012 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_1200
1
1015 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1016 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_600
1017 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1022 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1023 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_1200
1024 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
1029 <P>Numeric constants can be bitwise OR'd together by placing the constants
1030 inside parenthesis, for example:
</P>
1032 <pre class='example'
>
1033 <I>// ModelNumber capability bits
</I>
1034 <a href='ref-ppdcfile.html#_define'
>#define
</a> DUPLEX
1
1035 <a href='ref-ppdcfile.html#_define'
>#define
</a> COLOR
2
1040 <I>// Define a model number specifying the capabilities of the printer...
</I>
1041 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> ($DUPLEX $COLOR)
1047 <h3><a name='CONDITIONAL'
>Conditional Statements
</a></h3>
1049 <p>The PPD compiler supports conditional compilation using the
<tt>#if
</tt>,
1050 <tt>#elif
</tt>,
<tt>#else
</tt>, and
<tt>#endif
</tt> directives. The
<tt>#if
</tt>
1051 and
<tt>#elif
</tt> directives are followed by a constant name or an expression.
1052 For example, to include a group of options when
"ADVANCED" is defined:
</p>
1054 <pre class='example'
>
1055 <a href='ref-ppdcfile.html#_if'
>#if
</a> ADVANCED
1056 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Advanced/Advanced Options"
1057 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooCyanAdjust/Cyan Adjustment"
1058 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1059 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1060 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1061 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1062 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1063 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooMagentaAdjust/Magenta Adjustment"
1064 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1065 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1066 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1067 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1068 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1069 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooYellowAdjust/Yellow Adjustment"
1070 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1071 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1072 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1073 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1074 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1075 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooBlackAdjust/Black Adjustment"
1076 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1077 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1078 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1079 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1080 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1081 <a href='ref-ppdcfile.html#_endif'
>#endif
</a>
1085 <h3><a name='CONSTRAINTS'
>Defining Constraints
</a></h3>
1087 <P>Constraints are strings that are used to specify that one or more option
1088 choices are incompatible, for example two-sided printing on transparency media.
1089 Constraints are also used to prevent the use of uninstalled features such as the
1090 duplexer unit, additional media trays, and so forth.
</P>
1092 <P>The
<TT>UIConstraints
</TT> directive is used to specify a constraint that is
1093 placed in the PPD file. The directive is followed by a string using one of the
1094 following formats:
</P>
1096 <pre class='example'
>
1097 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2"
1098 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2"
1099 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2 Choice2"
1100 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2 Choice2"
1103 <P>Each option name is preceded by the asterisk (
<TT>*
</TT>). If no choice is
1104 given for an option, then all choices
<I>except
</I> <TT>False
</TT> and
1105 <TT>None
</TT> will conflict with the other option and choice(s). Since the PPD
1106 compiler automatically adds reciprocal constraints (option A conflicts with
1107 option B, so therefore option B conflicts with option A), you need only specify
1108 the constraint once.
</P>
1110 <p class='example'
><a name=
"LISTING5">Listing
5:
"examples/constraint.drv"</a></p>
1112 <pre class='example'
>
1114 <I>// Include standard font and media definitions
</I>
1115 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
1116 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
1118 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
1119 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
1121 <I>// Manufacturer, model name, and version
</I>
1122 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
1123 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1124 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
1126 <I>// Each filter provided by the driver...
</I>
1127 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
1129 <I>// Supported page sizes
</I>
1130 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
1131 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
1133 <I>// Supported resolutions
</I>
1134 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
1136 <I>// Installable Option Group
</I>
1137 <a href='ref-ppdcfile.html#Group'
>Group
</a> "InstallableOptions/Options Installed"
1139 <I>// Duplexing unit option
</I>
1140 <a href='ref-ppdcfile.html#Option'
>Option
</a> "OptionDuplexer/Duplexing Unit" Boolean AnySetup
10
1141 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Installed
""
1142 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "False/Not Installed" ""
1144 <I>// General Option Group
</I>
1145 <a href='ref-ppdcfile.html#Group'
>Group
</a> General
1147 <I>// Duplexing option
</I>
1148 <a href='ref-ppdcfile.html#Option'
>Option
</a> "Duplex/Two-Sided Printing" PickOne AnySetup
10
1149 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "None/No" "<</Duplex false>>setpagedevice""
1150 <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexNoTumble/Long Edge Binding
"
1151 "<</Duplex true/Tumble false
>>setpagedevice
""
1152 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "DuplexTumble/Short Edge Binding"
1153 "<</Duplex true/Tumble true>>setpagedevice""
1155 <I>// Only allow duplexing if the duplexer is installed</I>
1156 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1158 <I>// Specify the name of the PPD file we want to generate...</I>
1159 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd
"
1162 <P><A HREF="#LISTING5
">Listing 5</A> shows a variation of the first example with
1163 an added <TT>Duplex</TT> option and installable option for the duplexer,
1164 <TT>OptionDuplex</TT>. A constraint is added at the end to specify that any
1165 choice of the <TT>Duplex</TT> option that is not <TT>None</TT> is incompatible
1166 with the "Duplexer Installed
" option set to "Not Installed
"
1167 (<TT>False</TT>):</P>
1169 <pre class='example'>
1170 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1173 <h4>Enhanced Constraints</h4>
1175 <p>CUPS 1.4 supports constraints between 2 or more options using the
1176 <TT>Attribute</TT> directive. <TT>cupsUIConstraints</TT> attributes define
1177 the constraints, while <TT>cupsUIResolver</TT> attributes define option changes
1178 to resolve constraints. For example, we can specify the previous duplex
1179 constraint with a resolver that turns off duplexing with the following two
1182 <pre class='example'>
1183 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIConstraints DuplexOff "*Duplex *OptionDuplexer False
"
1184 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIResolver DuplexOff "*Duplex None
"
1187 <h2 class='title'><a name='LOCALIZATION'>Localization</a></h2>
1189 <p>The PPD compiler provides localization of PPD files in different languages
1190 through <i>message catalog</i> files in the GNU gettext or Apple .strings
1191 formats. Each user text string and several key PPD attribute values such as
1192 <tt>LanguageVersion</tt> and <tt>LanguageEncoding</tt> are looked up in the
1193 corresponding message catalog and the translated text is substituted in the
1194 generated PPD files. One message catalog file can be used by multiple driver
1195 information files, and each file contains a single language translation.</p>
1197 <h3><a name='PPDPO'>The ppdpo Utility</a></h3>
1199 <p>While CUPS includes localizations of all standard media sizes and options in
1200 several languages, your driver information files may provide their own media
1201 sizes and options that need to be localized. CUPS provides a utility program to
1202 aid in the localization of drivers called <a
1203 href='man-ppdpo.html'><tt>ppdpo(1)</tt></a>. The <tt>ppdpo</tt> program creates
1204 or updates a message catalog file based upon one or more driver information
1205 files. New messages are added with the word "TRANSLATE
" added to the front of
1206 the translation string to make locating new strings for translation easier. The
1207 program accepts the message catalog filename and one or more driver information
1210 <p>For example, run the following command to create a new German message catalog
1211 called <var>de.po</var> for all of the driver information files in the current
1214 <pre class='command'>
1215 ppdpo -o de.po *.drv
1218 <p>If the file <var>de.po</var> already exists, <tt>ppdpo</tt> will update the
1219 contents of the file with any new messages that need to be translated. To create
1220 an Apple .strings file instead, specify the output filename with a .strings
1221 extension, for example:</p>
1223 <pre class='command'>
1224 ppdpo -o de.strings *.drv
1227 <h3><a name='PPDC_CATALOG'>Using Message Catalogs with the PPD Compiler</a></h3>
1229 <p>Once you have created a message catalog, use the <a
1230 href='ref-ppdcfile.html#_po'><tt>#po</tt></a> directive to declare it in each
1231 driver information file. For example, to declare the German message catalog for
1234 <pre class='example'>
1235 <a href='ref-ppdcfile.html#_po'>#po</a> de "de.po
" // German
1238 <p>In fact, you can use the <tt>#po</tt> directive as many times as needed:</p>
1240 <pre class='example'>
1241 <a href='ref-ppdcfile.html#_po'>#po</a> de "de.po
" // German
1242 <a href='ref-ppdcfile.html#_po'>#po</a> es "es.po
" // Spanish
1243 <a href='ref-ppdcfile.html#_po'>#po</a> fr "fr.po
" // French
1244 <a href='ref-ppdcfile.html#_po'>#po</a> it "it.po
" // Italian
1245 <a href='ref-ppdcfile.html#_po'>#po</a> ja "ja.po
" // Japanese
1248 <p>The filename ("de.po
", etc.) can be relative to the location of the driver
1249 information file or an absolute path. Once defined, the PPD compiler will
1250 automatically generate a globalized PPD for every language declared in your
1251 driver information file. To generate a single-language PPD file, simply use the
1252 <tt>-l</tt> option to list the corresponding locale, for example:</p>
1254 <pre class='command'>
1255 ppdc -l de -d ppd/de mydrivers.drv
1258 <p>to generate German PPD files.</p>