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 <h2 class='title'
><a name='BASICS'
>The Basics
</a></h2>
374 <P>The PPD compiler,
<a href='man-ppdc.html'
><code>ppdc(
1)
</code></a>, is a
375 simple command-line tool that takes a single
<I>driver information file
</I>,
376 which by convention uses the extension
<VAR>.drv
</VAR>, and produces one or more
377 PPD files that may be distributed with your printer drivers for use with CUPS.
378 For example, you would run the following command to create the English language
379 PPD files defined by the driver information file
<VAR>mydrivers.drv
</VAR>:
</P>
381 <pre class='command'
>
385 <P>The PPD files are placed in a subdirectory called
386 <VAR>ppd
</VAR>. The
<TT>-d
</TT> option is used to put the PPD
387 files in a different location, for example:
</p>
389 <pre class='command'
>
390 ppdc -d myppds mydrivers.drv
393 <P>places the PPD files in a subdirectory named
394 <VAR>myppds
</VAR>. Finally, use the
<TT>-l
</TT> option to
395 specify the language localization for the PPD files that are
396 created, for example:
</P>
398 <pre class='command'
>
399 ppdc -d myppds/de -l de mydrivers.drv
400 ppdc -d myppds/en -l en mydrivers.drv
401 ppdc -d myppds/es -l es mydrivers.drv
402 ppdc -d myppds/fr -l fr mydrivers.drv
403 ppdc -d myppds/it -l it mydrivers.drv
406 <P>creates PPD files in German (de), English (en), Spanish (es),
407 French (fr), and Italian (it) in the corresponding
408 subdirectories. Specify multiple languages (separated by commas) to produce
409 "globalized" PPD files:
</p>
411 <pre class='command'
>
412 ppdc -d myppds -l de,en,es,fr,it mydrivers.drv
416 <h2 class='title'
><a name='DRV'
>Driver Information Files
</a></h2>
418 <P>The driver information files accepted by the PPD compiler are
419 plain text files that define the various attributes and options
420 that are included in the PPD files that are generated. A driver
421 information file can define the information for one or more printers and
422 their corresponding PPD files.
</P>
424 <p class='example'
><a name=
"LISTING1">Listing
1:
"examples/minimum.drv"</a></p>
426 <pre class='example'
>
427 <I>// Include standard font and media definitions
</I>
428 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
429 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
431 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
432 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
434 <I>// Manufacturer, model name, and version
</I>
435 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
436 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
437 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
439 <I>// Each filter provided by the driver...
</I>
440 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
442 <I>// Supported page sizes
</I>
443 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
444 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
446 <I>// Supported resolutions
</I>
447 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
449 <I>// Specify the name of the PPD file we want to generate...
</I>
450 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
454 <h3><a name='SIMPLE'
>A Simple Example
</a></h3>
456 <P>The example in
<A HREF=
"#LISTING1">Listing
1</A> shows a driver information
457 file which defines the minimum required attributes to provide a valid PPD file.
458 The first part of the file includes standard definition files for fonts and
461 <pre class='example'
>
462 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
463 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
466 <P>The
<TT>#include
</TT> directive works just like the C/C++ include directive;
467 files included using the angle brackets (
<TT><filename
></TT>) are found
468 in any of the standard include directories and files included using quotes
469 (
<TT>"filename"</TT>) are found in the same directory as the source or include
470 file. The
<TT><font.defs
></TT> include file defines the standard fonts
471 which are included with GPL Ghostscript and the Apple PDF RIP, while the
472 <TT><media.defs
></TT> include file defines the standard media sizes
473 listed in Appendix B of the Adobe PostScript Printer Description File Format
476 <P>CUPS provides several other standard include files:
</P>
480 <LI><TT><epson.h
></TT> - Defines all of the rastertoepson driver
483 <LI><TT><escp.h
></TT> - Defines all of the rastertoescpx driver
486 <LI><TT><hp.h
></TT> - Defines all of the rastertohp driver
489 <LI><TT><label.h
></TT> - Defines all of the rastertolabel driver
492 <LI><TT><pcl.h
></TT> - Defines all of the rastertopclx driver
495 <LI><TT><raster.defs
></TT> - Defines all of the CUPS raster format
500 <P>Next we list all of the fonts that are available in the driver; for CUPS
501 raster drivers, the following line is all that is usually supplied:
</P>
503 <pre class='example'
>
504 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
507 <P>The
<TT>Font
</TT> directive specifies the name of a single font or the
508 asterisk to specify all fonts. For example, you would use the following line to
509 define an additional bar code font that you are supplying with your printer
512 <pre class='example'
>
513 <I>// name encoding version charset status
</I>
514 <a href='ref-ppdcfile.html#Font'
>Font
</a> Barcode-Foo Special
"(1.0)" Special ROM
517 <P>The name of the font is
<TT>Barcode-Foo
</TT>. Since it is not a standard
518 text font, the encoding and charset name
<TT>Special
</TT> is used. The version
519 number is
<TT>1.0</TT> and the status (where the font is located) is
520 <TT>ROM
</TT> to indicate that the font does not need to be embedded in
521 documents that use the font for this printer.
</P>
523 <P>Third comes the manufacturer, model name, and version number information
526 <pre class='example'
>
527 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
528 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
529 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
532 <P>These strings are used when the user (or auto-configuration program) selects
533 the printer driver for a newly connected device.
</p>
535 <P>The list of filters comes after the information strings; for the example in
536 <A HREF=
"#LISTING1">Listing
1</A>, we have a single filter that takes CUPS
539 <pre class='example'
>
540 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
543 <P>Each filter specified in the driver information file is the equivalent of a
544 printer driver for that format; if a user submits a print job in a different
545 format, CUPS figures out the sequence of commands that will produce a supported
546 format for the least relative cost.
</P>
548 <P>Once we have defined the driver information we specify the supported options.
549 For the example driver we support a single resolution of
600 dots per inch and
550 two media sizes, A4 and Letter:
</P>
552 <pre class='example'
>
553 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
554 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
556 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
559 <P>The asterisk in front of the
<TT>MediaSize
</TT> and
<TT>Resolution
</TT>
560 directives specify that those option choices are the default. The
561 <TT>MediaSize
</TT> directive is followed by a media size name which is normally
562 defined in the
<TT><media.defs
></TT> file and corresponds to a standard
563 Adobe media size name. If the default media size is
<TT>Letter
</TT>, the PPD
564 compiler will override it to be
<TT>A4
</TT> for non-English localizations for
565 you automatically.
</P>
567 <P>The
<TT>Resolution
</TT> directive accepts several values after it as
572 <LI>Colorspace for this resolution, if any. In the example file, the
573 colorspace
<TT>k
</TT> is used which corresponds to black. For printer
574 drivers that support color printing, this field is usually specified as
575 "-" for
"no change".
</LI>
577 <LI>Bits per color. In the example file, we define
8 bits per color, for
578 a continuous-tone grayscale output. All versions of CUPS support
1 and
579 8 bits per color. CUPS
1.2 and higher (Mac OS X
10.5 and higher) also
580 supports
16 bits per color.
</LI>
582 <LI>Rows per band. In the example file, we define
0 rows per band to
583 indicate that our printer driver does not process the page in
586 <LI>Row feed. In the example, we define the feed value to be
0 to
587 indicate that our printer driver does not interleave the output.
</LI>
589 <LI>Row step. In the example, we define the step value to be
0 to
590 indicate that our printer driver does not interleave the output. This
591 value normally indicates the spacing between the nozzles of an inkjet
592 printer - when combined with the previous two values, it informs the
593 driver how to stagger the output on the page to produce interleaved
594 lines on the page for higher-resolution output.
</LI>
596 <LI>Choice name and text. In the example, we define the choice name and
597 text to be
<TT>"600dpi/600 DPI"</TT>. The name and text are separated by
598 slash (
<TT>/
</TT>) character; if no text is specified, then the name is
599 used as the text. The PPD compiler parses the name to determine the
600 actual resolution; the name can be of the form
601 <TT><I>RESOLUTION
</I>dpi
</TT> for resolutions that are equal
602 horizontally and vertically or
<TT><I>HRES
</I>x
<I>VRES
</I>dpi
</TT> for
603 isometric resolutions. Only integer resolution values are supported, so
604 a resolution name of
<TT>300dpi
</TT> is valid while
<TT>300.1dpi
</TT> is
609 <P>Finally, the
<TT>PCFileName
</TT> directive specifies that the named PPD file
610 should be written for the current driver definitions:
</P>
612 <pre class='example'
>
613 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
616 <P>The filename follows the directive and
<I>must
</I> conform to the Adobe
617 filename requirements in the Adobe Postscript Printer Description File Format
618 Specification. Specifically, the filename may not exceed
8 characters followed
619 by the extension
<VAR>.ppd
</VAR>. The
<TT>FileName
</TT> directive can be used to
620 specify longer filenames:
</P>
622 <pre class='example'
>
623 <a href='ref-ppdcfile.html#FileName'
>FileName
</a> "FooJet 2000"
627 <h3><a name='GROUPING'
>Grouping and Inheritance
</a></h3>
629 <P>The previous example created a single PPD file. Driver information files can
630 also define multiple printers by using the PPD compiler grouping functionality.
631 Directives are grouped using the curly braces (
<TT>{
</TT> and
<TT>}
</TT>) and
632 every group that uses the
<TT>PCFileName
</TT> or
<TT>FileName
</TT> directives
633 produces a PPD file with that name.
<A HREF=
"#LISTING2">Listing
2</A> shows a
634 variation of the original example that uses two groups to define two printers
635 that share the same printer driver filter but provide two different resolution
638 <p class='example'
><a name=
"LISTING2">Listing
2:
"examples/grouping.drv"</a></p>
640 <pre class='example'
>
642 <I>// Include standard font and media definitions
</I>
643 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
644 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
646 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
647 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
649 <I>// Manufacturer and version
</I>
650 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
651 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
653 <I>// Each filter provided by the driver...
</I>
654 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
656 <I>// Supported page sizes
</I>
657 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
658 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
661 <I>// Supported resolutions
</I>
662 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
664 <I>// Specify the model name and filename...
</I>
665 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
666 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
670 <I>// Supported resolutions
</I>
671 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "1200dpi/1200 DPI"
673 <I>// Specify the model name and filename...
</I>
674 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
675 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojt2k1.ppd"
679 <P>The second example is essentially the same as the first, except that each
680 printer model is defined inside of a pair of curly braces. For example, the
681 first printer is defined using:
</P>
683 <pre class='example'
>
685 // Supported resolutions
686 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
688 // Specify the model name and filename...
689 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
690 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
694 <P>The printer
<I>inherits
</I> all of the definitions from the parent group (the
695 top part of the file) and adds the additional definitions inside the curly
696 braces for that printer driver. When we define the second group, it also
697 inherits the same definitions from the parent group but
<I>none
</I> of the
698 definitions from the first driver. Groups can be nested to any number of levels
699 to support variations of similar models without duplication of information.
</P>
702 <h3><a name='COLOR'
>Color Support
</a></h3>
704 <P>For printer drivers that support color printing, the
705 <TT>ColorDevice
</TT> and
<TT>ColorModel
</TT> directives should be
706 used to tell the printing system that color output is desired
707 and in what formats.
<A HREF=
"#LISTING3">Listing
3</A> shows a
708 variation of the previous example which includes a color printer
709 that supports printing at
300 and
600 DPI.
</P>
711 <P>The key changes are the addition of the
<TT>ColorDevice
</TT>
714 <pre class='example'
>
715 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
718 <P>which tells the printing system that the printer supports
719 color printing, and the
<TT>ColorModel
</TT> directives:
</P>
721 <pre class='example'
>
722 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
723 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
726 <P>which tell the printing system which colorspaces are supported by the printer
727 driver for color printing. Each of the
<TT>ColorModel
</TT> directives is
728 followed by the option name and text (
<TT>Gray/Grayscale
</TT> and
729 <TT>RGB/Color
</TT>), the colorspace name (
<TT>w
</TT> and
<TT>rgb
</TT>), the
730 color organization (
<TT>chunky
</TT>), and the compression mode number
731 (
<TT>0</TT>) to be passed to the driver. The option name can be any of the
732 standard Adobe
<TT>ColorModel
</TT> names:
</P>
736 <LI><TT>Gray
</TT> - Grayscale output.
738 <LI><TT>RGB
</TT> - Color output, typically using the RGB
739 colorspace, but without a separate black channel.
741 <LI><TT>CMYK
</TT> - Color output with a separate black
746 <P>Custom names can be used, however it is recommended that you use your vendor
747 prefix for any custom names, for example
"fooName".
</P>
749 <P>The colorspace name can be any of the following universally supported
753 <LI><TT>w
</TT> - Luminance
</LI>
755 <LI><TT>rgb
</TT> - Red, green, blue
</LI>
757 <LI><TT>k
</TT> - Black
</LI>
759 <LI><TT>cmy
</TT> - Cyan, magenta, yellow
</LI>
761 <LI><TT>cmyk
</TT> - Cyan, magenta, yellow, black
</LI>
765 <P>The color organization can be any of the following values:
</P>
769 <LI><TT>chunky
</TT> - Color values are passed together on a line
770 as RGB RGB RGB RGB
</LI>
772 <LI><TT>banded
</TT> - Color values are passed separately
773 on a line as RRRR GGGG BBBB; not supported by the Apple
776 <LI><TT>planar
</TT> - Color values are passed separately
777 on a page as RRRR RRRR RRRR ... GGGG GGGG GGGG ... BBBB
778 BBBB BBBB; not supported by the Apple RIP filters
</LI>
782 <P>The compression mode value is passed to the driver in the
783 <TT>cupsCompression
</TT> attribute. It is traditionally used to select an
784 appropriate compression mode for the color model but can be used for any
785 purpose, such as specifying a photo mode vs. standard mode.
</P>
787 <p class='example'
><a name=
"LISTING3">Listing
3:
"examples/color.drv"</a></p>
789 <pre class='example'
>
791 <I>// Include standard font and media definitions
</I>
792 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
793 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
795 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
796 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
798 <I>// Manufacturer and version
</I>
799 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
800 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
802 <I>// Each filter provided by the driver...
</I>
803 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
805 <I>// Supported page sizes
</I>
806 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
807 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
810 <I>// Supported resolutions
</I>
811 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
813 <I>// Specify the model name and filename...
</I>
814 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
815 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
819 <I>// Supports color printing
</I>
820 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
822 <I>// Supported colorspaces
</I>
823 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
824 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
826 <I>// Supported resolutions
</I>
827 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "300dpi/300 DPI"
828 <a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "600dpi/600 DPI"
830 <I>// Specify the model name and filename...
</I>
831 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet Color"
832 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojetco.ppd"
837 <h3><a name='OPTIONS'
>Defining Custom Options and Option Groups
</a></h3>
839 <P>The
<TT>Group
</TT>,
<TT>Option
</TT>, and
<TT>Choice
</TT>
840 directives are used to define or select a group, option, or
841 choice.
<A HREF=
"#LISTING4">Listing
4</A> shows a variation of
842 the first example that provides two custom options in a group
845 <p class='example'
><a name=
"LISTING4">Listing
4:
"examples/custom.drv"</a></p>
847 <pre class='example'
>
849 <I>// Include standard font and media definitions
</I>
850 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
851 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
853 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
854 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
856 <I>// Manufacturer, model name, and version
</I>
857 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
858 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
859 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
861 <I>// Each filter provided by the driver...
</I>
862 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
864 <I>// Supported page sizes
</I>
865 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
866 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
868 <I>// Supported resolutions
</I>
869 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
871 <I>// Option Group
</I>
872 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm"
874 <I>// Boolean option
</I>
875 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
876 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
877 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
879 <I>// Multiple choice option
</I>
880 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooOutputType/Output Quality" PickOne AnySetup
10
881 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Auto/Automatic Selection"
882 "<</OutputType(Auto)>>setpagedevice""
883 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Text/Optimize for Text
"
884 "<</OutputType(Text)
>>setpagedevice
""
885 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Graph/Optimize for Graphics"
886 "<</OutputType(Graph)>>setpagedevice""
887 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Photo/Optimize for Photos
"
888 "<</OutputType(Photo)
>>setpagedevice
""
890 <I>// Specify the name of the PPD file we want to generate...
</I>
891 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
894 <P>The custom group is introduced by the
<TT>Group
</TT>
895 directive which is followed by the name and optionally text for
898 <pre class='example'
>
899 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm/Footastic Options"
902 <P>The group name must conform to the PPD specification and
903 cannot exceed
40 characters in length. If you specify user text,
904 it cannot exceed
80 characters in length. The groups
905 <TT>General
</TT>,
<TT>Extra
</TT>, and
906 <TT>InstallableOptions
</TT> are predefined by CUPS; the general
907 and extra groups are filled by the UI options defined by the PPD
908 specification. The
<TT>InstallableOptions
</TT> group is reserved
909 for options that define whether accessories for the printer
910 (duplexer unit, finisher, stapler, etc.) are installed.
</P>
912 <P>Once the group is specified, the
<TT>Option
</TT> directive is
913 used to introduce a new option:
</P>
915 <pre class='example'
>
916 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
919 <P>The directive is followed by the name of the option and any
920 optional user text, the option type, the PostScript document group, and
921 the sort order number. The option name must conform to the PPD specification
922 and cannot exceed
40 characters in length. If you specify user text, it
923 cannot exceed
80 characters in length.
</P>
925 <P>The option type can be
<TT>Boolean
</TT> for true/false
926 selections,
<TT>PickOne
</TT> for picking one of many choices, or
927 <TT>PickMany
</TT> for picking zero or more choices. Boolean
928 options can have at most two choices with the names
929 <TT>False
</TT> and
<TT>True
</TT>. Pick options can have any
930 number of choices, although for Windows compatibility reasons
931 the number of choices should not exceed
255.
</P>
933 <P>The PostScript document group is typically
<TT>AnySetup
</TT>,
934 meaning that the option can be introduced at any point in the
935 PostScript document. Other values include
<TT>PageSetup
</TT> to
936 include the option before each page and
<TT>DocumentSetup
</TT>
937 to include the option once at the beginning of the document.
</P>
939 <P>The sort order number is used to sort the printer commands
940 associated with each option choice within the PostScript
941 document. This allows you to setup certain options before others
942 as required by the printer. For most CUPS raster printer
943 drivers, the value
<TT>10</TT> can be used for all options.
</P>
945 <P>Once the option is specified, each option choice can be
946 listed using the
<TT>Choice
</TT> directive:
</P>
948 <pre class='example'
>
949 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
950 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
953 <P>The directive is followed by the choice name and optionally
954 user text, and the PostScript commands that should be inserted
955 when printing a file to this printer. The option name must
956 conform to the PPD specification and cannot exceed
40 characters
957 in length. If you specify user text, it cannot exceed
80
958 characters in length.
</P>
960 <P>The PostScript commands are also interpreted by any RIP
961 filters, so these commands typically must be present for all
962 option choices. Most commands take the form:
</P>
964 <pre class='example'
>
965 <</name value
>>setpagedevice
968 <P>where
<TT>name
</TT> is the name of the PostScript page device
969 attribute and
<TT>value
</TT> is the numeric or string value for
973 <h3><a name='DEFINE'
>Defining Constants
</a></h3>
975 <P>Sometimes you will want to define constants for your drivers
976 so that you can share values in different groups within the same
977 driver information file, or to share values between different
978 driver information files using the
<TT>#include
</TT> directive.
979 The
<TT>#define
</TT> directive is used to define constants for
980 use in your printer definitions:
</P>
982 <pre class='example'
>
983 <a href='ref-ppdcfile.html#_define'
>#define
</a> NAME value
986 <P>The
<TT>NAME
</TT> is any sequence of letters, numbers, and
987 the underscore. The
<TT>value
</TT> is a number or string; if the
988 value contains spaces you must put double quotes around it, for
991 <pre class='example'
>
992 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO
"My String Value"
995 <P>Constants can also be defined on the command-line using the
<tt>-D
</tt>
998 <pre class='command'
>
999 ppdc
-DNAME=
"value" filename.drv
1002 <P>Once defined, you use the notation
<TT>$NAME
</TT> to substitute the value of
1003 the constant in the file, for example:
</P>
1005 <pre class='example'
>
1006 <a href='ref-ppdcfile.html#_define'
>#define
</a> MANUFACTURER
"Foo"
1007 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_600
0
1008 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_1200
1
1011 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1012 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_600
1013 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1018 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1019 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_1200
1020 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
1025 <P>Numeric constants can be bitwise OR'd together by placing the constants
1026 inside parenthesis, for example:
</P>
1028 <pre class='example'
>
1029 <I>// ModelNumber capability bits
</I>
1030 <a href='ref-ppdcfile.html#_define'
>#define
</a> DUPLEX
1
1031 <a href='ref-ppdcfile.html#_define'
>#define
</a> COLOR
2
1036 <I>// Define a model number specifying the capabilities of the printer...
</I>
1037 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> ($DUPLEX $COLOR)
1043 <h3><a name='CONDITIONAL'
>Conditional Statements
</a></h3>
1045 <p>The PPD compiler supports conditional compilation using the
<tt>#if
</tt>,
1046 <tt>#elif
</tt>,
<tt>#else
</tt>, and
<tt>#endif
</tt> directives. The
<tt>#if
</tt>
1047 and
<tt>#elif
</tt> directives are followed by a constant name or an expression.
1048 For example, to include a group of options when
"ADVANCED" is defined:
</p>
1050 <pre class='example'
>
1051 <a href='ref-ppdcfile.html#_if'
>#if
</a> ADVANCED
1052 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Advanced/Advanced Options"
1053 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooCyanAdjust/Cyan Adjustment"
1054 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1055 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1056 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1057 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1058 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1059 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooMagentaAdjust/Magenta Adjustment"
1060 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1061 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1062 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1063 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1064 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1065 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooYellowAdjust/Yellow Adjustment"
1066 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1067 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1068 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1069 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1070 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1071 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooBlackAdjust/Black Adjustment"
1072 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1073 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1074 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1075 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1076 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1077 <a href='ref-ppdcfile.html#_endif'
>#endif
</a>
1081 <h3><a name='CONSTRAINTS'
>Defining Constraints
</a></h3>
1083 <P>Constraints are strings that are used to specify that one or more option
1084 choices are incompatible, for example two-sided printing on transparency media.
1085 Constraints are also used to prevent the use of uninstalled features such as the
1086 duplexer unit, additional media trays, and so forth.
</P>
1088 <P>The
<TT>UIConstraints
</TT> directive is used to specify a constraint that is
1089 placed in the PPD file. The directive is followed by a string using one of the
1090 following formats:
</P>
1092 <pre class='example'
>
1093 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2"
1094 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2"
1095 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2 Choice2"
1096 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2 Choice2"
1099 <P>Each option name is preceded by the asterisk (
<TT>*
</TT>). If no choice is
1100 given for an option, then all choices
<I>except
</I> <TT>False
</TT> and
1101 <TT>None
</TT> will conflict with the other option and choice(s). Since the PPD
1102 compiler automatically adds reciprocal constraints (option A conflicts with
1103 option B, so therefore option B conflicts with option A), you need only specify
1104 the constraint once.
</P>
1106 <p class='example'
><a name=
"LISTING5">Listing
5:
"examples/constraint.drv"</a></p>
1108 <pre class='example'
>
1110 <I>// Include standard font and media definitions
</I>
1111 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
1112 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
1114 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
1115 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
1117 <I>// Manufacturer, model name, and version
</I>
1118 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
1119 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1120 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
1122 <I>// Each filter provided by the driver...
</I>
1123 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
1125 <I>// Supported page sizes
</I>
1126 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
1127 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
1129 <I>// Supported resolutions
</I>
1130 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
1132 <I>// Installable Option Group
</I>
1133 <a href='ref-ppdcfile.html#Group'
>Group
</a> "InstallableOptions/Options Installed"
1135 <I>// Duplexing unit option
</I>
1136 <a href='ref-ppdcfile.html#Option'
>Option
</a> "OptionDuplexer/Duplexing Unit" Boolean AnySetup
10
1137 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Installed
""
1138 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "False/Not Installed" ""
1140 <I>// General Option Group
</I>
1141 <a href='ref-ppdcfile.html#Group'
>Group
</a> General
1143 <I>// Duplexing option
</I>
1144 <a href='ref-ppdcfile.html#Option'
>Option
</a> "Duplex/Two-Sided Printing" PickOne AnySetup
10
1145 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "None/No" "<</Duplex false>>setpagedevice""
1146 <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexNoTumble/Long Edge Binding
"
1147 "<</Duplex true/Tumble false
>>setpagedevice
""
1148 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "DuplexTumble/Short Edge Binding"
1149 "<</Duplex true/Tumble true>>setpagedevice""
1151 <I>// Only allow duplexing if the duplexer is installed</I>
1152 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1154 <I>// Specify the name of the PPD file we want to generate...</I>
1155 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd
"
1158 <P><A HREF="#LISTING5
">Listing 5</A> shows a variation of the first example with
1159 an added <TT>Duplex</TT> option and installable option for the duplexer,
1160 <TT>OptionDuplex</TT>. A constraint is added at the end to specify that any
1161 choice of the <TT>Duplex</TT> option that is not <TT>None</TT> is incompatible
1162 with the "Duplexer Installed
" option set to "Not Installed
"
1163 (<TT>False</TT>):</P>
1165 <pre class='example'>
1166 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1169 <h4>Enhanced Constraints</h4>
1171 <p>CUPS 1.4 supports constraints between 2 or more options using the
1172 <TT>Attribute</TT> directive. <TT>cupsUIConstraints</TT> attributes define
1173 the constraints, while <TT>cupsUIResolver</TT> attributes define option changes
1174 to resolve constraints. For example, we can specify the previous duplex
1175 constraint with a resolver that turns off duplexing with the following two
1178 <pre class='example'>
1179 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIConstraints DuplexOff "*Duplex *OptionDuplexer False
"
1180 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIResolver DuplexOff "*Duplex None
"