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;
37 border: dotted thin #999999;
42 PRE.command EM, PRE.example EM {
43 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
47 font-family: monaco, courier, monospace;
58 border: solid thin #999999;
69 -moz-border-radius: 10px;
74 text-decoration: none;
77 A:link:hover, A:visited:hover, A:active {
78 text-decoration: underline;
85 TR.data, TD.data, TR.data TD {
88 border-bottom: solid 1pt #999999;
92 border-bottom: solid 1pt #999999;
99 border: solid thin #999999;
100 border-collapse: collapse;
116 border: solid thin #cccccc;
123 border-bottom: solid thin #999999;
132 caption-side: bottom;
156 border: thin solid black;
164 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
170 border-bottom: solid 2pt #000000;
173 DIV.indent, TABLE.indent {
181 border-collapse: collapse;
184 TABLE.indent TD, TABLE.indent TH {
189 border-collapse: collapse;
197 border-bottom: solid thin #cccccc;
202 vertical-align: bottom;
211 border-bottom: solid thin #eeeeee;
216 TABLE.list TR:nth-child(even) {
220 TABLE.list TR:nth-child(odd) {
239 font-family: monaco, courier, monospace;
243 border: solid thin #999999;
244 border-collapse: collapse;
249 DIV.summary TABLE TD, DIV.summary TABLE TH {
250 border: solid thin #999999;
256 DIV.summary TABLE THEAD TH {
260 /* API documentation styles... */
267 div.body h3, div.body h4, div.body h5 {
268 margin-bottom: 0.5em;
271 .class, .enumeration, .function, .struct, .typedef, .union {
272 border-bottom: solid thin #999999;
279 code, p.code, pre, ul.code li {
280 font-family: monaco, courier, monospace;
283 ul.code, ul.contents, ul.subcontents {
284 list-style-type: none;
294 ul.contents li ul.code, ul.contents li ul.subcontents {
307 margin-bottom: 0.5em;
310 /* This is just for the HTML files generated with the framedhelp target */
313 border: solid thin black;
322 div.contents ul.contents {
325 div.contents ul.subcontents li {
333 <P>This document describes how to use the CUPS PostScript Printer Description
334 (PPD) file compiler. The PPD compiler generates PPD files from simple text files
335 that describe the features and capabilities of one or more printers.
</P>
337 <div class='summary'
><table summary='General Information'
>
341 <td>Programming:
<a href='raster-driver.html'
>Developing Raster Printer Drivers
</a><br>
342 Programming:
<a href='postscript-driver.html'
>Developing PostScript Printer Drivers
</a><br>
343 Programming:
<a href='api-filter.html'
>Filter and Backend Programming
</a><br>
344 Programming:
<a href='api-raster.html'
>Raster API
</a><br>
345 References:
<a href='ref-ppdcfile.html'
>PPD Compiler Driver Information File Reference
</a><br>
346 Specifications:
<a href='spec-ppd.html'
>CUPS PPD Extensions
</a></td>
350 <h2 class=
"title">Contents
</h2>
351 <ul class=
"contents">
352 <ul class=
"subcontents">
353 <li><a href=
"#BASICS">The Basics
</a></li>
354 <li><a href=
"#DRV">Driver Information Files
</a><ul class=
"subcontents">
355 <li><a href=
"#SIMPLE">A Simple Example
</a></li>
356 <li><a href=
"#GROUPING">Grouping and Inheritance
</a></li>
357 <li><a href=
"#COLOR">Color Support
</a></li>
358 <li><a href=
"#OPTIONS">Defining Custom Options and Option Groups
</a></li>
359 <li><a href=
"#DEFINE">Defining Constants
</a></li>
360 <li><a href=
"#CONDITIONAL">Conditional Statements
</a></li>
361 <li><a href=
"#CONSTRAINTS">Defining Constraints
</a></li>
363 <h2 class='title'
><a name='BASICS'
>The Basics
</a></h2>
365 <P>The PPD compiler,
<a href='man-ppdc.html'
><code>ppdc(
1)
</code></a>, is a
366 simple command-line tool that takes a single
<I>driver information file
</I>,
367 which by convention uses the extension
<VAR>.drv
</VAR>, and produces one or more
368 PPD files that may be distributed with your printer drivers for use with CUPS.
369 For example, you would run the following command to create the English language
370 PPD files defined by the driver information file
<VAR>mydrivers.drv
</VAR>:
</P>
372 <pre class='command'
>
376 <P>The PPD files are placed in a subdirectory called
377 <VAR>ppd
</VAR>. The
<TT>-d
</TT> option is used to put the PPD
378 files in a different location, for example:
</p>
380 <pre class='command'
>
381 ppdc -d myppds mydrivers.drv
384 <P>places the PPD files in a subdirectory named
385 <VAR>myppds
</VAR>. Finally, use the
<TT>-l
</TT> option to
386 specify the language localization for the PPD files that are
387 created, for example:
</P>
389 <pre class='command'
>
390 ppdc -d myppds/de -l de mydrivers.drv
391 ppdc -d myppds/en -l en mydrivers.drv
392 ppdc -d myppds/es -l es mydrivers.drv
393 ppdc -d myppds/fr -l fr mydrivers.drv
394 ppdc -d myppds/it -l it mydrivers.drv
397 <P>creates PPD files in German (de), English (en), Spanish (es),
398 French (fr), and Italian (it) in the corresponding
399 subdirectories. Specify multiple languages (separated by commas) to produce
400 "globalized" PPD files:
</p>
402 <pre class='command'
>
403 ppdc -d myppds -l de,en,es,fr,it mydrivers.drv
407 <h2 class='title'
><a name='DRV'
>Driver Information Files
</a></h2>
409 <P>The driver information files accepted by the PPD compiler are
410 plain text files that define the various attributes and options
411 that are included in the PPD files that are generated. A driver
412 information file can define the information for one or more printers and
413 their corresponding PPD files.
</P>
415 <p class='example'
><a name=
"LISTING1">Listing
1:
"examples/minimum.drv"</a></p>
417 <pre class='example'
>
418 <I>// Include standard font and media definitions
</I>
419 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
420 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
422 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
423 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
425 <I>// Manufacturer, model name, and version
</I>
426 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
427 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
428 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
430 <I>// Each filter provided by the driver...
</I>
431 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
433 <I>// Supported page sizes
</I>
434 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
435 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
437 <I>// Supported resolutions
</I>
438 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
440 <I>// Specify the name of the PPD file we want to generate...
</I>
441 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
445 <h3><a name='SIMPLE'
>A Simple Example
</a></h3>
447 <P>The example in
<A HREF=
"#LISTING1">Listing
1</A> shows a driver information
448 file which defines the minimum required attributes to provide a valid PPD file.
449 The first part of the file includes standard definition files for fonts and
452 <pre class='example'
>
453 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
454 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
457 <P>The
<TT>#include
</TT> directive works just like the C/C++ include directive;
458 files included using the angle brackets (
<TT><filename
></TT>) are found
459 in any of the standard include directories and files included using quotes
460 (
<TT>"filename"</TT>) are found in the same directory as the source or include
461 file. The
<TT><font.defs
></TT> include file defines the standard fonts
462 which are included with GPL Ghostscript and the Apple PDF RIP, while the
463 <TT><media.defs
></TT> include file defines the standard media sizes
464 listed in Appendix B of the Adobe PostScript Printer Description File Format
467 <P>CUPS provides several other standard include files:
</P>
471 <LI><TT><epson.h
></TT> - Defines all of the rastertoepson driver
474 <LI><TT><escp.h
></TT> - Defines all of the rastertoescpx driver
477 <LI><TT><hp.h
></TT> - Defines all of the rastertohp driver
480 <LI><TT><label.h
></TT> - Defines all of the rastertolabel driver
483 <LI><TT><pcl.h
></TT> - Defines all of the rastertopclx driver
486 <LI><TT><raster.defs
></TT> - Defines all of the CUPS raster format
491 <P>Next we list all of the fonts that are available in the driver; for CUPS
492 raster drivers, the following line is all that is usually supplied:
</P>
494 <pre class='example'
>
495 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
498 <P>The
<TT>Font
</TT> directive specifies the name of a single font or the
499 asterisk to specify all fonts. For example, you would use the following line to
500 define an additional bar code font that you are supplying with your printer
503 <pre class='example'
>
504 <I>// name encoding version charset status
</I>
505 <a href='ref-ppdcfile.html#Font'
>Font
</a> Barcode-Foo Special
"(1.0)" Special ROM
508 <P>The name of the font is
<TT>Barcode-Foo
</TT>. Since it is not a standard
509 text font, the encoding and charset name
<TT>Special
</TT> is used. The version
510 number is
<TT>1.0</TT> and the status (where the font is located) is
511 <TT>ROM
</TT> to indicate that the font does not need to be embedded in
512 documents that use the font for this printer.
</P>
514 <P>Third comes the manufacturer, model name, and version number information
517 <pre class='example'
>
518 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
519 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
520 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
523 <P>These strings are used when the user (or auto-configuration program) selects
524 the printer driver for a newly connected device.
</p>
526 <P>The list of filters comes after the information strings; for the example in
527 <A HREF=
"#LISTING1">Listing
1</A>, we have a single filter that takes CUPS
530 <pre class='example'
>
531 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
534 <P>Each filter specified in the driver information file is the equivalent of a
535 printer driver for that format; if a user submits a print job in a different
536 format, CUPS figures out the sequence of commands that will produce a supported
537 format for the least relative cost.
</P>
539 <P>Once we have defined the driver information we specify the supported options.
540 For the example driver we support a single resolution of
600 dots per inch and
541 two media sizes, A4 and Letter:
</P>
543 <pre class='example'
>
544 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
545 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
547 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
550 <P>The asterisk in front of the
<TT>MediaSize
</TT> and
<TT>Resolution
</TT>
551 directives specify that those option choices are the default. The
552 <TT>MediaSize
</TT> directive is followed by a media size name which is normally
553 defined in the
<TT><media.defs
></TT> file and corresponds to a standard
554 Adobe media size name. If the default media size is
<TT>Letter
</TT>, the PPD
555 compiler will override it to be
<TT>A4
</TT> for non-English localizations for
556 you automatically.
</P>
558 <P>The
<TT>Resolution
</TT> directive accepts several values after it as
563 <LI>Colorspace for this resolution, if any. In the example file, the
564 colorspace
<TT>k
</TT> is used which corresponds to black. For printer
565 drivers that support color printing, this field is usually specified as
566 "-" for
"no change".
</LI>
568 <LI>Bits per color. In the example file, we define
8 bits per color, for
569 a continuous-tone grayscale output. All versions of CUPS support
1 and
570 8 bits per color. CUPS
1.2 and higher (Mac OS X
10.5 and higher) also
571 supports
16 bits per color.
</LI>
573 <LI>Rows per band. In the example file, we define
0 rows per band to
574 indicate that our printer driver does not process the page in
577 <LI>Row feed. In the example, we define the feed value to be
0 to
578 indicate that our printer driver does not interleave the output.
</LI>
580 <LI>Row step. In the example, we define the step value to be
0 to
581 indicate that our printer driver does not interleave the output. This
582 value normally indicates the spacing between the nozzles of an inkjet
583 printer - when combined with the previous two values, it informs the
584 driver how to stagger the output on the page to produce interleaved
585 lines on the page for higher-resolution output.
</LI>
587 <LI>Choice name and text. In the example, we define the choice name and
588 text to be
<TT>"600dpi/600 DPI"</TT>. The name and text are separated by
589 slash (
<TT>/
</TT>) character; if no text is specified, then the name is
590 used as the text. The PPD compiler parses the name to determine the
591 actual resolution; the name can be of the form
592 <TT><I>RESOLUTION
</I>dpi
</TT> for resolutions that are equal
593 horizontally and vertically or
<TT><I>HRES
</I>x
<I>VRES
</I>dpi
</TT> for
594 isometric resolutions. Only integer resolution values are supported, so
595 a resolution name of
<TT>300dpi
</TT> is valid while
<TT>300.1dpi
</TT> is
600 <P>Finally, the
<TT>PCFileName
</TT> directive specifies that the named PPD file
601 should be written for the current driver definitions:
</P>
603 <pre class='example'
>
604 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
607 <P>The filename follows the directive and
<I>must
</I> conform to the Adobe
608 filename requirements in the Adobe Postscript Printer Description File Format
609 Specification. Specifically, the filename may not exceed
8 characters followed
610 by the extension
<VAR>.ppd
</VAR>. The
<TT>FileName
</TT> directive can be used to
611 specify longer filenames:
</P>
613 <pre class='example'
>
614 <a href='ref-ppdcfile.html#FileName'
>FileName
</a> "FooJet 2000"
618 <h3><a name='GROUPING'
>Grouping and Inheritance
</a></h3>
620 <P>The previous example created a single PPD file. Driver information files can
621 also define multiple printers by using the PPD compiler grouping functionality.
622 Directives are grouped using the curly braces (
<TT>{
</TT> and
<TT>}
</TT>) and
623 every group that uses the
<TT>PCFileName
</TT> or
<TT>FileName
</TT> directives
624 produces a PPD file with that name.
<A HREF=
"#LISTING2">Listing
2</A> shows a
625 variation of the original example that uses two groups to define two printers
626 that share the same printer driver filter but provide two different resolution
629 <p class='example'
><a name=
"LISTING2">Listing
2:
"examples/grouping.drv"</a></p>
631 <pre class='example'
>
633 <I>// Include standard font and media definitions
</I>
634 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
635 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
637 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
638 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
640 <I>// Manufacturer and version
</I>
641 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
642 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
644 <I>// Each filter provided by the driver...
</I>
645 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
647 <I>// Supported page sizes
</I>
648 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
649 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
652 <I>// Supported resolutions
</I>
653 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
655 <I>// Specify the model name and filename...
</I>
656 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
657 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
661 <I>// Supported resolutions
</I>
662 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "1200dpi/1200 DPI"
664 <I>// Specify the model name and filename...
</I>
665 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
666 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojt2k1.ppd"
670 <P>The second example is essentially the same as the first, except that each
671 printer model is defined inside of a pair of curly braces. For example, the
672 first printer is defined using:
</P>
674 <pre class='example'
>
676 // Supported resolutions
677 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
679 // Specify the model name and filename...
680 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
681 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
685 <P>The printer
<I>inherits
</I> all of the definitions from the parent group (the
686 top part of the file) and adds the additional definitions inside the curly
687 braces for that printer driver. When we define the second group, it also
688 inherits the same definitions from the parent group but
<I>none
</I> of the
689 definitions from the first driver. Groups can be nested to any number of levels
690 to support variations of similar models without duplication of information.
</P>
693 <h3><a name='COLOR'
>Color Support
</a></h3>
695 <P>For printer drivers that support color printing, the
696 <TT>ColorDevice
</TT> and
<TT>ColorModel
</TT> directives should be
697 used to tell the printing system that color output is desired
698 and in what formats.
<A HREF=
"#LISTING3">Listing
3</A> shows a
699 variation of the previous example which includes a color printer
700 that supports printing at
300 and
600 DPI.
</P>
702 <P>The key changes are the addition of the
<TT>ColorDevice
</TT>
705 <pre class='example'
>
706 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
709 <P>which tells the printing system that the printer supports
710 color printing, and the
<TT>ColorModel
</TT> directives:
</P>
712 <pre class='example'
>
713 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
714 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
717 <P>which tell the printing system which colorspaces are supported by the printer
718 driver for color printing. Each of the
<TT>ColorModel
</TT> directives is
719 followed by the option name and text (
<TT>Gray/Grayscale
</TT> and
720 <TT>RGB/Color
</TT>), the colorspace name (
<TT>w
</TT> and
<TT>rgb
</TT>), the
721 color organization (
<TT>chunky
</TT>), and the compression mode number
722 (
<TT>0</TT>) to be passed to the driver. The option name can be any of the
723 standard Adobe
<TT>ColorModel
</TT> names:
</P>
727 <LI><TT>Gray
</TT> - Grayscale output.
729 <LI><TT>RGB
</TT> - Color output, typically using the RGB
730 colorspace, but without a separate black channel.
732 <LI><TT>CMYK
</TT> - Color output with a separate black
737 <P>Custom names can be used, however it is recommended that you use your vendor
738 prefix for any custom names, for example
"fooName".
</P>
740 <P>The colorspace name can be any of the following universally supported
744 <LI><TT>w
</TT> - Luminance
</LI>
746 <LI><TT>rgb
</TT> - Red, green, blue
</LI>
748 <LI><TT>k
</TT> - Black
</LI>
750 <LI><TT>cmy
</TT> - Cyan, magenta, yellow
</LI>
752 <LI><TT>cmyk
</TT> - Cyan, magenta, yellow, black
</LI>
756 <P>The color organization can be any of the following values:
</P>
760 <LI><TT>chunky
</TT> - Color values are passed together on a line
761 as RGB RGB RGB RGB
</LI>
763 <LI><TT>banded
</TT> - Color values are passed separately
764 on a line as RRRR GGGG BBBB; not supported by the Apple
767 <LI><TT>planar
</TT> - Color values are passed separately
768 on a page as RRRR RRRR RRRR ... GGGG GGGG GGGG ... BBBB
769 BBBB BBBB; not supported by the Apple RIP filters
</LI>
773 <P>The compression mode value is passed to the driver in the
774 <TT>cupsCompression
</TT> attribute. It is traditionally used to select an
775 appropriate compression mode for the color model but can be used for any
776 purpose, such as specifying a photo mode vs. standard mode.
</P>
778 <p class='example'
><a name=
"LISTING3">Listing
3:
"examples/color.drv"</a></p>
780 <pre class='example'
>
782 <I>// Include standard font and media definitions
</I>
783 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
784 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
786 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
787 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
789 <I>// Manufacturer and version
</I>
790 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
791 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
793 <I>// Each filter provided by the driver...
</I>
794 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
796 <I>// Supported page sizes
</I>
797 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
798 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
801 <I>// Supported resolutions
</I>
802 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
804 <I>// Specify the model name and filename...
</I>
805 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
806 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
810 <I>// Supports color printing
</I>
811 <a href='ref-ppdcfile.html#ColorDevice'
>ColorDevice
</a> true
813 <I>// Supported colorspaces
</I>
814 <a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> Gray/Grayscale w chunky
0
815 *
<a href='ref-ppdcfile.html#ColorModel'
>ColorModel
</a> RGB/Color rgb chunky
0
817 <I>// Supported resolutions
</I>
818 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "300dpi/300 DPI"
819 <a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> -
8 0 0 0 "600dpi/600 DPI"
821 <I>// Specify the model name and filename...
</I>
822 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet Color"
823 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojetco.ppd"
828 <h3><a name='OPTIONS'
>Defining Custom Options and Option Groups
</a></h3>
830 <P>The
<TT>Group
</TT>,
<TT>Option
</TT>, and
<TT>Choice
</TT>
831 directives are used to define or select a group, option, or
832 choice.
<A HREF=
"#LISTING4">Listing
4</A> shows a variation of
833 the first example that provides two custom options in a group
836 <p class='example'
><a name=
"LISTING4">Listing
4:
"examples/custom.drv"</a></p>
838 <pre class='example'
>
840 <I>// Include standard font and media definitions
</I>
841 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
842 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
844 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
845 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
847 <I>// Manufacturer, model name, and version
</I>
848 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
849 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
850 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
852 <I>// Each filter provided by the driver...
</I>
853 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
855 <I>// Supported page sizes
</I>
856 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
857 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
859 <I>// Supported resolutions
</I>
860 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
862 <I>// Option Group
</I>
863 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm"
865 <I>// Boolean option
</I>
866 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
867 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
868 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
870 <I>// Multiple choice option
</I>
871 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooOutputType/Output Quality" PickOne AnySetup
10
872 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Auto/Automatic Selection"
873 "<</OutputType(Auto)>>setpagedevice""
874 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Text/Optimize for Text
"
875 "<</OutputType(Text)
>>setpagedevice
""
876 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "Graph/Optimize for Graphics"
877 "<</OutputType(Graph)>>setpagedevice""
878 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Photo/Optimize for Photos
"
879 "<</OutputType(Photo)
>>setpagedevice
""
881 <I>// Specify the name of the PPD file we want to generate...
</I>
882 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "foojet2k.ppd"
885 <P>The custom group is introduced by the
<TT>Group
</TT>
886 directive which is followed by the name and optionally text for
889 <pre class='example'
>
890 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Footasm/Footastic Options"
893 <P>The group name must conform to the PPD specification and
894 cannot exceed
40 characters in length. If you specify user text,
895 it cannot exceed
80 characters in length. The groups
896 <TT>General
</TT>,
<TT>Extra
</TT>, and
897 <TT>InstallableOptions
</TT> are predefined by CUPS; the general
898 and extra groups are filled by the UI options defined by the PPD
899 specification. The
<TT>InstallableOptions
</TT> group is reserved
900 for options that define whether accessories for the printer
901 (duplexer unit, finisher, stapler, etc.) are installed.
</P>
903 <P>Once the group is specified, the
<TT>Option
</TT> directive is
904 used to introduce a new option:
</P>
906 <pre class='example'
>
907 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup
10
910 <P>The directive is followed by the name of the option and any
911 optional user text, the option type, the PostScript document group, and
912 the sort order number. The option name must conform to the PPD specification
913 and cannot exceed
40 characters in length. If you specify user text, it
914 cannot exceed
80 characters in length.
</P>
916 <P>The option type can be
<TT>Boolean
</TT> for true/false
917 selections,
<TT>PickOne
</TT> for picking one of many choices, or
918 <TT>PickMany
</TT> for picking zero or more choices. Boolean
919 options can have at most two choices with the names
920 <TT>False
</TT> and
<TT>True
</TT>. Pick options can have any
921 number of choices, although for Windows compatibility reasons
922 the number of choices should not exceed
255.
</P>
924 <P>The PostScript document group is typically
<TT>AnySetup
</TT>,
925 meaning that the option can be introduced at any point in the
926 PostScript document. Other values include
<TT>PageSetup
</TT> to
927 include the option before each page and
<TT>DocumentSetup
</TT>
928 to include the option once at the beginning of the document.
</P>
930 <P>The sort order number is used to sort the printer commands
931 associated with each option choice within the PostScript
932 document. This allows you to setup certain options before others
933 as required by the printer. For most CUPS raster printer
934 drivers, the value
<TT>10</TT> can be used for all options.
</P>
936 <P>Once the option is specified, each option choice can be
937 listed using the
<TT>Choice
</TT> directive:
</P>
939 <pre class='example'
>
940 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Yes
"<</cupsCompression 1>>setpagedevice"
941 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> False/No
"<</cupsCompression 0>>setpagedevice"
944 <P>The directive is followed by the choice name and optionally
945 user text, and the PostScript commands that should be inserted
946 when printing a file to this printer. The option name must
947 conform to the PPD specification and cannot exceed
40 characters
948 in length. If you specify user text, it cannot exceed
80
949 characters in length.
</P>
951 <P>The PostScript commands are also interpreted by any RIP
952 filters, so these commands typically must be present for all
953 option choices. Most commands take the form:
</P>
955 <pre class='example'
>
956 <</name value
>>setpagedevice
959 <P>where
<TT>name
</TT> is the name of the PostScript page device
960 attribute and
<TT>value
</TT> is the numeric or string value for
964 <h3><a name='DEFINE'
>Defining Constants
</a></h3>
966 <P>Sometimes you will want to define constants for your drivers
967 so that you can share values in different groups within the same
968 driver information file, or to share values between different
969 driver information files using the
<TT>#include
</TT> directive.
970 The
<TT>#define
</TT> directive is used to define constants for
971 use in your printer definitions:
</P>
973 <pre class='example'
>
974 <a href='ref-ppdcfile.html#_define'
>#define
</a> NAME value
977 <P>The
<TT>NAME
</TT> is any sequence of letters, numbers, and
978 the underscore. The
<TT>value
</TT> is a number or string; if the
979 value contains spaces you must put double quotes around it, for
982 <pre class='example'
>
983 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO
"My String Value"
986 <P>Constants can also be defined on the command-line using the
<tt>-D
</tt>
989 <pre class='command'
>
990 ppdc
-DNAME=
"value" filename.drv
993 <P>Once defined, you use the notation
<TT>$NAME
</TT> to substitute the value of
994 the constant in the file, for example:
</P>
996 <pre class='example'
>
997 <a href='ref-ppdcfile.html#_define'
>#define
</a> MANUFACTURER
"Foo"
998 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_600
0
999 <a href='ref-ppdcfile.html#_define'
>#define
</a> FOO_1200
1
1002 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1003 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_600
1004 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1009 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "$MANUFACTURER"
1010 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> $FOO_1200
1011 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2001"
1016 <P>Numeric constants can be bitwise OR'd together by placing the constants
1017 inside parenthesis, for example:
</P>
1019 <pre class='example'
>
1020 <I>// ModelNumber capability bits
</I>
1021 <a href='ref-ppdcfile.html#_define'
>#define
</a> DUPLEX
1
1022 <a href='ref-ppdcfile.html#_define'
>#define
</a> COLOR
2
1027 <I>// Define a model number specifying the capabilities of the printer...
</I>
1028 <a href='ref-ppdcfile.html#ModelNumber'
>ModelNumber
</a> ($DUPLEX $COLOR)
1034 <h3><a name='CONDITIONAL'
>Conditional Statements
</a></h3>
1036 <p>The PPD compiler supports conditional compilation using the
<tt>#if
</tt>,
1037 <tt>#elif
</tt>,
<tt>#else
</tt>, and
<tt>#endif
</tt> directives. The
<tt>#if
</tt>
1038 and
<tt>#elif
</tt> directives are followed by a constant name or an expression.
1039 For example, to include a group of options when
"ADVANCED" is defined:
</p>
1041 <pre class='example'
>
1042 <a href='ref-ppdcfile.html#_if'
>#if
</a> ADVANCED
1043 <a href='ref-ppdcfile.html#Group'
>Group
</a> "Advanced/Advanced Options"
1044 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooCyanAdjust/Cyan Adjustment"
1045 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1046 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1047 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1048 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1049 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1050 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooMagentaAdjust/Magenta Adjustment"
1051 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1052 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1053 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1054 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1055 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1056 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooYellowAdjust/Yellow Adjustment"
1057 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1058 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1059 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1060 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1061 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1062 <a href='ref-ppdcfile.html#Option'
>Option
</a> "fooBlackAdjust/Black Adjustment"
1063 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus10/+10%" ""
1064 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "plus5/+5%" ""
1065 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "none/No Adjustment" ""
1066 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus5/-5%" ""
1067 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "minus10/-10%" ""
1068 <a href='ref-ppdcfile.html#_endif'
>#endif
</a>
1072 <h3><a name='CONSTRAINTS'
>Defining Constraints
</a></h3>
1074 <P>Constraints are strings that are used to specify that one or more option
1075 choices are incompatible, for example two-sided printing on transparency media.
1076 Constraints are also used to prevent the use of uninstalled features such as the
1077 duplexer unit, additional media trays, and so forth.
</P>
1079 <P>The
<TT>UIConstraints
</TT> directive is used to specify a constraint that is
1080 placed in the PPD file. The directive is followed by a string using one of the
1081 following formats:
</P>
1083 <pre class='example'
>
1084 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2"
1085 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2"
1086 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 *Option2 Choice2"
1087 <a href='ref-ppdcfile.html#UIConstraints'
>UIConstraints
</a> "*Option1 Choice1 *Option2 Choice2"
1090 <P>Each option name is preceded by the asterisk (
<TT>*
</TT>). If no choice is
1091 given for an option, then all choices
<I>except
</I> <TT>False
</TT> and
1092 <TT>None
</TT> will conflict with the other option and choice(s). Since the PPD
1093 compiler automatically adds reciprocal constraints (option A conflicts with
1094 option B, so therefore option B conflicts with option A), you need only specify
1095 the constraint once.
</P>
1097 <p class='example'
><a name=
"LISTING5">Listing
5:
"examples/constraint.drv"</a></p>
1099 <pre class='example'
>
1101 <I>// Include standard font and media definitions
</I>
1102 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
1103 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
1105 <I>// List the fonts that are supported, in this case all standard fonts...
</I>
1106 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
1108 <I>// Manufacturer, model name, and version
</I>
1109 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
1110 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "FooJet 2000"
1111 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
1113 <I>// Each filter provided by the driver...
</I>
1114 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-raster
100 rastertofoo
1116 <I>// Supported page sizes
</I>
1117 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
1118 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
1120 <I>// Supported resolutions
</I>
1121 *
<a href='ref-ppdcfile.html#Resolution'
>Resolution
</a> k
8 0 0 0 "600dpi/600 DPI"
1123 <I>// Installable Option Group
</I>
1124 <a href='ref-ppdcfile.html#Group'
>Group
</a> "InstallableOptions/Options Installed"
1126 <I>// Duplexing unit option
</I>
1127 <a href='ref-ppdcfile.html#Option'
>Option
</a> "OptionDuplexer/Duplexing Unit" Boolean AnySetup
10
1128 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> True/Installed
""
1129 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "False/Not Installed" ""
1131 <I>// General Option Group
</I>
1132 <a href='ref-ppdcfile.html#Group'
>Group
</a> General
1134 <I>// Duplexing option
</I>
1135 <a href='ref-ppdcfile.html#Option'
>Option
</a> "Duplex/Two-Sided Printing" PickOne AnySetup
10
1136 *
<a href='ref-ppdcfile.html#Choice'
>Choice
</a> "None/No" "<</Duplex false>>setpagedevice""
1137 <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexNoTumble/Long Edge Binding
"
1138 "<</Duplex true/Tumble false
>>setpagedevice
""
1139 <a href='ref-ppdcfile.html#Choice'
>Choice
</a> "DuplexTumble/Short Edge Binding"
1140 "<</Duplex true/Tumble true>>setpagedevice""
1142 <I>// Only allow duplexing if the duplexer is installed</I>
1143 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1145 <I>// Specify the name of the PPD file we want to generate...</I>
1146 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd
"
1149 <P><A HREF="#LISTING5
">Listing 5</A> shows a variation of the first example with
1150 an added <TT>Duplex</TT> option and installable option for the duplexer,
1151 <TT>OptionDuplex</TT>. A constraint is added at the end to specify that any
1152 choice of the <TT>Duplex</TT> option that is not <TT>None</TT> is incompatible
1153 with the "Duplexer Installed
" option set to "Not Installed
"
1154 (<TT>False</TT>):</P>
1156 <pre class='example'>
1157 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False
"
1160 <h4>Enhanced Constraints</h4>
1162 <p>CUPS 1.4 supports constraints between 2 or more options using the
1163 <TT>Attribute</TT> directive. <TT>cupsUIConstraints</TT> attributes define
1164 the constraints, while <TT>cupsUIResolver</TT> attributes define option changes
1165 to resolve constraints. For example, we can specify the previous duplex
1166 constraint with a resolver that turns off duplexing with the following two
1169 <pre class='example'>
1170 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIConstraints DuplexOff "*Duplex *OptionDuplexer False
"
1171 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIResolver DuplexOff "*Duplex None
"