]> git.ipfire.org Git - thirdparty/cups.git/blob - doc/help/ppd-compiler.html
Update documentation (Issue #5252)
[thirdparty/cups.git] / doc / help / ppd-compiler.html
1 <!doctype html>
2 <html>
3 <!-- SECTION: Programming -->
4 <head>
5 <title>Introduction to the PPD Compiler</title>
6 <meta name="keywords" content="Programming">
7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
8 <meta name="creator" content="Mini-XML v2.11">
9 <meta name="author" content="Unknown">
10 <meta name="copyright" content="Unknown">
11 <meta name="version" content="0.0">
12 <style type="text/css"><!--
13 BODY {
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
15 }
16
17 H1, H2, H3, H4, H5, H6, P, TD, TH {
18 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
19 }
20
21 KBD {
22 font-family: monaco, courier, monospace;
23 font-weight: bold;
24 }
25
26 PRE {
27 font-family: monaco, courier, monospace;
28 }
29
30 BLOCKQUOTE {
31 border-left: solid 2px #777;
32 margin: 1em 0;
33 padding: 10px;
34 }
35
36 BLOCKQUOTE OL LI {
37 margin-left: -1em;
38 }
39
40 PRE.command, PRE.example {
41 background: #eee;
42 margin: 0 36pt;
43 padding: 10px;
44 }
45
46 P.compact {
47 margin: 0;
48 }
49
50 P.example {
51 font-style: italic;
52 margin-left: 36pt;
53 }
54
55 DL.man DD {
56 margin-left: 5em;
57 }
58
59 DL.man DT {
60 margin-left: 0;
61 }
62
63 PRE.man {
64 margin: 0;
65 }
66
67 PRE.command EM, PRE.example EM {
68 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
69 }
70
71 P.command {
72 font-family: monaco, courier, monospace;
73 margin-left: 36pt;
74 }
75
76 P.formula {
77 font-style: italic;
78 margin-left: 36pt;
79 }
80
81 A IMG {
82 border: none;
83 }
84
85 A:link:hover IMG {
86 background: #f0f0f0;
87 border-radius: 10px;
88 -moz-border-radius: 10px;
89 }
90
91 A:link, A:visited {
92 font-weight: inherit;
93 text-decoration: none;
94 }
95
96 A:link:hover, A:visited:hover, A:active {
97 text-decoration: underline;
98 }
99
100 SUB, SUP {
101 font-size: 50%;
102 }
103
104 TR.data, TD.data, TR.data TD {
105 margin-top: 10pt;
106 padding: 5pt;
107 border-bottom: solid 1pt #999999;
108 }
109
110 TR.data TH {
111 border-bottom: solid 1pt #999999;
112 padding-top: 10pt;
113 padding-left: 5pt;
114 text-align: left;
115 }
116
117 DIV.table TABLE {
118 border: solid thin #999999;
119 border-collapse: collapse;
120 border-spacing: 0;
121 margin-left: auto;
122 margin-right: auto;
123 }
124
125 DIV.table CAPTION {
126 caption-side: top;
127 font-size: 120%;
128 font-style: italic;
129 font-weight: bold;
130 margin-left: auto;
131 margin-right: auto;
132 }
133
134 DIV.table TABLE TD {
135 border: solid thin #cccccc;
136 padding: 5pt 10pt 0;
137 }
138
139 DIV.table TABLE TH {
140 background: #cccccc;
141 border: none;
142 border-bottom: solid thin #999999;
143 }
144
145 DIV.figure TABLE {
146 margin-left: auto;
147 margin-right: auto;
148 }
149
150 DIV.figure CAPTION {
151 caption-side: bottom;
152 font-size: 120%;
153 font-style: italic;
154 font-weight: bold;
155 margin-left: auto;
156 margin-right: auto;
157 }
158
159 TH.label {
160 text-align: right;
161 vertical-align: top;
162 }
163
164 TH.sublabel {
165 text-align: right;
166 font-weight: normal;
167 }
168
169 HR {
170 border: solid thin;
171 }
172
173 SPAN.info {
174 background: black;
175 border: thin solid black;
176 color: white;
177 font-size: 80%;
178 font-style: italic;
179 font-weight: bold;
180 white-space: nowrap;
181 }
182
183 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
184 float: right;
185 font-size: 100%;
186 }
187
188 H1.title {
189 }
190
191 H2.title, H3.title {
192 border-bottom: solid 2pt #000000;
193 }
194
195 DIV.indent, TABLE.indent {
196 margin-top: 2em;
197 margin-left: auto;
198 margin-right: auto;
199 width: 90%;
200 }
201
202 TABLE.indent {
203 border-collapse: collapse;
204 }
205
206 TABLE.indent TD, TABLE.indent TH {
207 padding: 0;
208 }
209
210 TABLE.list {
211 border-collapse: collapse;
212 margin-left: auto;
213 margin-right: auto;
214 width: 90%;
215 }
216
217 TABLE.list TH {
218 background: white;
219 border-bottom: solid thin #cccccc;
220 color: #444444;
221 padding-top: 10pt;
222 padding-left: 5pt;
223 text-align: left;
224 vertical-align: bottom;
225 white-space: nowrap;
226 }
227
228 TABLE.list TH A {
229 color: #4444cc;
230 }
231
232 TABLE.list TD {
233 border-bottom: solid thin #eeeeee;
234 padding-top: 5pt;
235 padding-left: 5pt;
236 }
237
238 TABLE.list TR:nth-child(even) {
239 background: #f8f8f8;
240 }
241
242 TABLE.list TR:nth-child(odd) {
243 background: #f4f4f4;
244 }
245
246 DT {
247 margin-left: 36pt;
248 margin-top: 12pt;
249 }
250
251 DD {
252 margin-left: 54pt;
253 }
254
255 DL.category DT {
256 font-weight: bold;
257 }
258
259 P.summary {
260 margin-left: 36pt;
261 font-family: monaco, courier, monospace;
262 }
263
264 DIV.summary TABLE {
265 border: solid thin #999999;
266 border-collapse: collapse;
267 border-spacing: 0;
268 margin: 10px;
269 }
270
271 DIV.summary TABLE TD, DIV.summary TABLE TH {
272 border: solid thin #999999;
273 padding: 5px;
274 text-align: left;
275 vertical-align: top;
276 }
277
278 DIV.summary TABLE THEAD TH {
279 background: #eeeeee;
280 }
281
282 /* API documentation styles... */
283 div.body h1 {
284 font-size: 250%;
285 font-weight: bold;
286 margin: 0;
287 }
288 div.body h2 {
289 font-size: 250%;
290 margin-top: 1.5em;
291 }
292 div.body h3 {
293 font-size: 150%;
294 margin-bottom: 0.5em;
295 margin-top: 1.5em;
296 }
297 div.body h4 {
298 font-size: 110%;
299 margin-bottom: 0.5em;
300 margin-top: 1.5em;
301 }
302 div.body h5 {
303 font-size: 100%;
304 margin-bottom: 0.5em;
305 margin-top: 1.5em;
306 }
307 div.contents {
308 background: #e8e8e8;
309 border: solid thin black;
310 padding: 10px;
311 }
312 div.contents h1 {
313 font-size: 110%;
314 }
315 div.contents h2 {
316 font-size: 100%;
317 }
318 div.contents ul.contents {
319 font-size: 80%;
320 }
321 .class {
322 border-bottom: solid 2px gray;
323 }
324 .constants {
325 }
326 .description {
327 margin-top: 0.5em;
328 }
329 .discussion {
330 }
331 .enumeration {
332 border-bottom: solid 2px gray;
333 }
334 .function {
335 border-bottom: solid 2px gray;
336 margin-bottom: 0;
337 }
338 .members {
339 }
340 .method {
341 }
342 .parameters {
343 }
344 .returnvalue {
345 }
346 .struct {
347 border-bottom: solid 2px gray;
348 }
349 .typedef {
350 border-bottom: solid 2px gray;
351 }
352 .union {
353 border-bottom: solid 2px gray;
354 }
355 .variable {
356 }
357 h1, h2, h3, h4, h5, h6 {
358 page-break-inside: avoid;
359 }
360 blockquote {
361 border: solid thin gray;
362 box-shadow: 3px 3px 5px rgba(0,0,0,0.5);
363 padding: 0px 10px;
364 page-break-inside: avoid;
365 }
366 p code, li code, p.code, pre, ul.code li {
367 background: rgba(127,127,127,0.1);
368 border: thin dotted gray;
369 font-family: monospace;
370 font-size: 90%;
371 hyphens: manual;
372 -webkit-hyphens: manual;
373 page-break-inside: avoid;
374 }
375 p.code, pre, ul.code li {
376 padding: 10px;
377 }
378 p code, li code {
379 padding: 2px 5px;
380 }
381 a:link, a:visited {
382 text-decoration: none;
383 }
384 span.info {
385 background: black;
386 border: solid thin black;
387 color: white;
388 font-size: 80%;
389 font-style: italic;
390 font-weight: bold;
391 white-space: nowrap;
392 }
393 h3 span.info, h4 span.info {
394 border-top-left-radius: 10px;
395 border-top-right-radius: 10px;
396 float: right;
397 padding: 3px 6px;
398 }
399 ul.code, ul.contents, ul.subcontents {
400 list-style-type: none;
401 margin: 0;
402 padding-left: 0;
403 }
404 ul.code li {
405 margin: 0;
406 }
407 ul.contents > li {
408 margin-top: 1em;
409 }
410 ul.contents li ul.code, ul.contents li ul.subcontents {
411 padding-left: 2em;
412 }
413 table.list {
414 border-collapse: collapse;
415 width: 100%;
416 }
417 table.list tr:nth-child(even) {
418 background: rgba(127,127,127,0.1);]n}
419 table.list th {
420 border-right: 2px solid gray;
421 font-family: monospace;
422 padding: 5px 10px 5px 2px;
423 text-align: right;
424 vertical-align: top;
425 }
426 table.list td {
427 padding: 5px 2px 5px 10px;
428 text-align: left;
429 vertical-align: top;
430 }
431 h1.title {
432 }
433 h2.title {
434 border-bottom: solid 2px black;
435 }
436 h3.title {
437 border-bottom: solid 2px black;
438 }
439 --></style>
440 </head>
441 <body>
442 <!--
443 PPD compiler documentation for CUPS.
444
445 Copyright 2007-2012 by Apple Inc.
446 Copyright 1997-2007 by Easy Software Products.
447
448 These coded instructions, statements, and computer programs are the
449 property of Apple Inc. and are protected by Federal copyright
450 law. Distribution and use rights are outlined in the file "LICENSE.txt"
451 which should have been included with this file. If this file is
452 file is missing or damaged, see the license at "http://www.cups.org/".
453 -->
454
455 <h1 class='title'>Introduction to the PPD Compiler</h1>
456
457 <P>This document describes how to use the CUPS PostScript Printer Description
458 (PPD) file compiler. The PPD compiler generates PPD files from simple text files
459 that describe the features and capabilities of one or more printers.</P>
460
461 <BLOCKQUOTE><B>Note:</B>
462
463 <P>The PPD compiler and related tools are deprecated and will be removed in a future release of CUPS.</P>
464
465 </BLOCKQUOTE>
466
467 <div class='summary'><table summary='General Information'>
468 <tbody>
469 <tr>
470 <th>See Also</th>
471 <td>Programming: <a href='raster-driver.html'>Developing Raster Printer Drivers</a><br>
472 Programming: <a href='postscript-driver.html'>Developing PostScript Printer Drivers</a><br>
473 Programming: <a href='api-filter.html'>Filter and Backend Programming</a><br>
474 Programming: <a href='api-raster.html'>Raster API</a><br>
475 References: <a href='ref-ppdcfile.html'>PPD Compiler Driver Information File Reference</a><br>
476 Specifications: <a href='spec-ppd.html'>CUPS PPD Extensions</a></td>
477 </tr>
478 </tbody>
479 </table></div>
480 <div class="contents">
481 <h2 class="title">Contents</h2>
482 <ul class="contents">
483 <li><a href="#BASICS">The Basics</a></li>
484 <li><a href="#DRV">Driver Information Files</a><ul class="subcontents">
485 <li><a href="#SIMPLE">A Simple Example</a></li>
486 <li><a href="#GROUPING">Grouping and Inheritance</a></li>
487 <li><a href="#COLOR">Color Support</a></li>
488 <li><a href="#OPTIONS">Defining Custom Options and Option Groups</a></li>
489 <li><a href="#DEFINE">Defining Constants</a></li>
490 <li><a href="#CONDITIONAL">Conditional Statements</a></li>
491 <li><a href="#CONSTRAINTS">Defining Constraints</a></li>
492 </ul></li>
493 <li><a href="#LOCALIZATION">Localization</a><ul class="subcontents">
494 <li><a href="#PPDPO">The ppdpo Utility</a></li>
495 <li><a href="#PPDC_CATALOG">Using Message Catalogs with the PPD Compiler</a></li>
496 </ul></li>
497 </ul>
498 </div>
499 <div class="body">
500 <h2 class='title'><a name='BASICS'>The Basics</a></h2>
501
502 <P>The PPD compiler, <a href='man-ppdc.html'><code>ppdc(1)</code></a>, is a
503 simple command-line tool that takes a single <I>driver information file</I>,
504 which by convention uses the extension <VAR>.drv</VAR>, and produces one or more
505 PPD files that may be distributed with your printer drivers for use with CUPS.
506 For example, you would run the following command to create the English language
507 PPD files defined by the driver information file <VAR>mydrivers.drv</VAR>:</P>
508
509 <pre class='command'>
510 ppdc mydrivers.drv
511 </pre>
512
513 <P>The PPD files are placed in a subdirectory called
514 <VAR>ppd</VAR>. The <TT>-d</TT> option is used to put the PPD
515 files in a different location, for example:</p>
516
517 <pre class='command'>
518 ppdc -d myppds mydrivers.drv
519 </pre>
520
521 <P>places the PPD files in a subdirectory named
522 <VAR>myppds</VAR>. Finally, use the <TT>-l</TT> option to
523 specify the language localization for the PPD files that are
524 created, for example:</P>
525
526 <pre class='command'>
527 ppdc -d myppds/de -l de mydrivers.drv
528 ppdc -d myppds/en -l en mydrivers.drv
529 ppdc -d myppds/es -l es mydrivers.drv
530 ppdc -d myppds/fr -l fr mydrivers.drv
531 ppdc -d myppds/it -l it mydrivers.drv
532 </pre>
533
534 <P>creates PPD files in German (de), English (en), Spanish (es),
535 French (fr), and Italian (it) in the corresponding
536 subdirectories. Specify multiple languages (separated by commas) to produce
537 "globalized" PPD files:</p>
538
539 <pre class='command'>
540 ppdc -d myppds -l de,en,es,fr,it mydrivers.drv
541 </pre>
542
543
544 <h2 class='title'><a name='DRV'>Driver Information Files</a></h2>
545
546 <P>The driver information files accepted by the PPD compiler are
547 plain text files that define the various attributes and options
548 that are included in the PPD files that are generated. A driver
549 information file can define the information for one or more printers and
550 their corresponding PPD files.</P>
551
552 <p class='example'><a name="LISTING1">Listing 1: "examples/minimum.drv"</a></p>
553
554 <pre class='example'>
555 <I>// Include standard font and media definitions</I>
556 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
557 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
558
559 <I>// List the fonts that are supported, in this case all standard fonts...</I>
560 <a href='ref-ppdcfile.html#Font'>Font</a> *
561
562 <I>// Manufacturer, model name, and version</I>
563 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
564 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
565 <a href='ref-ppdcfile.html#Version'>Version</a> 1.0
566
567 <I>// Each filter provided by the driver...</I>
568 <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo
569
570 <I>// Supported page sizes</I>
571 *<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
572 <a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4
573
574 <I>// Supported resolutions</I>
575 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
576
577 <I>// Specify the name of the PPD file we want to generate...</I>
578 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
579 </pre>
580
581
582 <h3><a name='SIMPLE'>A Simple Example</a></h3>
583
584 <P>The example in <A HREF="#LISTING1">Listing 1</A> shows a driver information
585 file which defines the minimum required attributes to provide a valid PPD file.
586 The first part of the file includes standard definition files for fonts and
587 media sizes:</P>
588
589 <pre class='example'>
590 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
591 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
592 </pre>
593
594 <P>The <TT>#include</TT> directive works just like the C/C++ include directive;
595 files included using the angle brackets (<TT>&lt;filename&gt;</TT>) are found
596 in any of the standard include directories and files included using quotes
597 (<TT>"filename"</TT>) are found in the same directory as the source or include
598 file. The <TT>&lt;font.defs&gt;</TT> include file defines the standard fonts
599 which are included with GPL Ghostscript and the Apple PDF RIP, while the
600 <TT>&lt;media.defs&gt;</TT> include file defines the standard media sizes
601 listed in Appendix B of the Adobe PostScript Printer Description File Format
602 Specification.</P>
603
604 <P>CUPS provides several other standard include files:</P>
605
606 <UL>
607
608 <LI><TT>&lt;epson.h&gt;</TT> - Defines all of the rastertoepson driver
609 constants.</LI>
610
611 <LI><TT>&lt;escp.h&gt;</TT> - Defines all of the rastertoescpx driver
612 constants.</LI>
613
614 <LI><TT>&lt;hp.h&gt;</TT> - Defines all of the rastertohp driver
615 constants.</LI>
616
617 <LI><TT>&lt;label.h&gt;</TT> - Defines all of the rastertolabel driver
618 constants.</LI>
619
620 <LI><TT>&lt;pcl.h&gt;</TT> - Defines all of the rastertopclx driver
621 constants.</LI>
622
623 <LI><TT>&lt;raster.defs&gt;</TT> - Defines all of the CUPS raster format
624 constants.</LI>
625
626 </UL>
627
628 <P>Next we list all of the fonts that are available in the driver; for CUPS
629 raster drivers, the following line is all that is usually supplied:</P>
630
631 <pre class='example'>
632 <a href='ref-ppdcfile.html#Font'>Font</a> *
633 </pre>
634
635 <P>The <TT>Font</TT> directive specifies the name of a single font or the
636 asterisk to specify all fonts. For example, you would use the following line to
637 define an additional bar code font that you are supplying with your printer
638 driver:</P>
639
640 <pre class='example'>
641 <I>// name encoding version charset status</I>
642 <a href='ref-ppdcfile.html#Font'>Font</a> Barcode-Foo Special "(1.0)" Special ROM
643 </pre>
644
645 <P>The name of the font is <TT>Barcode-Foo</TT>. Since it is not a standard
646 text font, the encoding and charset name <TT>Special</TT> is used. The version
647 number is <TT>1.0</TT> and the status (where the font is located) is
648 <TT>ROM</TT> to indicate that the font does not need to be embedded in
649 documents that use the font for this printer.</P>
650
651 <P>Third comes the manufacturer, model name, and version number information
652 strings:</P>
653
654 <pre class='example'>
655 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
656 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
657 <a href='ref-ppdcfile.html#Version'>Version</a> 1.0
658 </pre>
659
660 <P>These strings are used when the user (or auto-configuration program) selects
661 the printer driver for a newly connected device.</p>
662
663 <P>The list of filters comes after the information strings; for the example in
664 <A HREF="#LISTING1">Listing 1</A>, we have a single filter that takes CUPS
665 raster data:</P>
666
667 <pre class='example'>
668 <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo
669 </pre>
670
671 <P>Each filter specified in the driver information file is the equivalent of a
672 printer driver for that format; if a user submits a print job in a different
673 format, CUPS figures out the sequence of commands that will produce a supported
674 format for the least relative cost.</P>
675
676 <P>Once we have defined the driver information we specify the supported options.
677 For the example driver we support a single resolution of 600 dots per inch and
678 two media sizes, A4 and Letter:</P>
679
680 <pre class='example'>
681 *<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
682 <a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4
683
684 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
685 </pre>
686
687 <P>The asterisk in front of the <TT>MediaSize</TT> and <TT>Resolution</TT>
688 directives specify that those option choices are the default. The
689 <TT>MediaSize</TT> directive is followed by a media size name which is normally
690 defined in the <TT>&lt;media.defs&gt;</TT> file and corresponds to a standard
691 Adobe media size name. If the default media size is <TT>Letter</TT>, the PPD
692 compiler will override it to be <TT>A4</TT> for non-English localizations for
693 you automatically.</P>
694
695 <P>The <TT>Resolution</TT> directive accepts several values after it as
696 follows:</P>
697
698 <OL>
699
700 <LI>Colorspace for this resolution, if any. In the example file, the
701 colorspace <TT>k</TT> is used which corresponds to black. For printer
702 drivers that support color printing, this field is usually specified as
703 "-" for "no change".</LI>
704
705 <LI>Bits per color. In the example file, we define 8 bits per color, for
706 a continuous-tone grayscale output. All versions of CUPS support 1 and
707 8 bits per color. CUPS 1.2 and higher (macOS 10.5 and higher) also
708 supports 16 bits per color.</LI>
709
710 <LI>Rows per band. In the example file, we define 0 rows per band to
711 indicate that our printer driver does not process the page in
712 bands.</LI>
713
714 <LI>Row feed. In the example, we define the feed value to be 0 to
715 indicate that our printer driver does not interleave the output.</LI>
716
717 <LI>Row step. In the example, we define the step value to be 0 to
718 indicate that our printer driver does not interleave the output. This
719 value normally indicates the spacing between the nozzles of an inkjet
720 printer - when combined with the previous two values, it informs the
721 driver how to stagger the output on the page to produce interleaved
722 lines on the page for higher-resolution output.</LI>
723
724 <LI>Choice name and text. In the example, we define the choice name and
725 text to be <TT>"600dpi/600 DPI"</TT>. The name and text are separated by
726 slash (<TT>/</TT>) character; if no text is specified, then the name is
727 used as the text. The PPD compiler parses the name to determine the
728 actual resolution; the name can be of the form
729 <TT><I>RESOLUTION</I>dpi</TT> for resolutions that are equal
730 horizontally and vertically or <TT><I>HRES</I>x<I>VRES</I>dpi</TT> for
731 isometric resolutions. Only integer resolution values are supported, so
732 a resolution name of <TT>300dpi</TT> is valid while <TT>300.1dpi</TT> is
733 not.</LI>
734
735 </OL>
736
737 <P>Finally, the <TT>PCFileName</TT> directive specifies that the named PPD file
738 should be written for the current driver definitions:</P>
739
740 <pre class='example'>
741 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
742 </pre>
743
744 <P>The filename follows the directive and <I>must</I> conform to the Adobe
745 filename requirements in the Adobe Postscript Printer Description File Format
746 Specification. Specifically, the filename may not exceed 8 characters followed
747 by the extension <VAR>.ppd</VAR>. The <TT>FileName</TT> directive can be used to
748 specify longer filenames:</P>
749
750 <pre class='example'>
751 <a href='ref-ppdcfile.html#FileName'>FileName</a> "FooJet 2000"
752 </pre>
753
754
755 <h3><a name='GROUPING'>Grouping and Inheritance</a></h3>
756
757 <P>The previous example created a single PPD file. Driver information files can
758 also define multiple printers by using the PPD compiler grouping functionality.
759 Directives are grouped using the curly braces (<TT>{</TT> and <TT>}</TT>) and
760 every group that uses the <TT>PCFileName</TT> or <TT>FileName</TT> directives
761 produces a PPD file with that name. <A HREF="#LISTING2">Listing 2</A> shows a
762 variation of the original example that uses two groups to define two printers
763 that share the same printer driver filter but provide two different resolution
764 options.</P>
765
766 <p class='example'><a name="LISTING2">Listing 2: "examples/grouping.drv"</a></p>
767
768 <pre class='example'>
769
770 <I>// Include standard font and media definitions</I>
771 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
772 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
773
774 <I>// List the fonts that are supported, in this case all standard fonts...</I>
775 <a href='ref-ppdcfile.html#Font'>Font</a> *
776
777 <I>// Manufacturer and version</I>
778 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
779 <a href='ref-ppdcfile.html#Version'>Version</a> 1.0
780
781 <I>// Each filter provided by the driver...</I>
782 <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo
783
784 <I>// Supported page sizes</I>
785 *<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
786 <a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4
787
788 {
789 <I>// Supported resolutions</I>
790 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
791
792 <I>// Specify the model name and filename...</I>
793 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
794 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
795 }
796
797 {
798 <I>// Supported resolutions</I>
799 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "1200dpi/1200 DPI"
800
801 <I>// Specify the model name and filename...</I>
802 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2001"
803 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojt2k1.ppd"
804 }
805 </pre>
806
807 <P>The second example is essentially the same as the first, except that each
808 printer model is defined inside of a pair of curly braces. For example, the
809 first printer is defined using:</P>
810
811 <pre class='example'>
812 {
813 // Supported resolutions
814 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
815
816 // Specify the model name and filename...
817 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
818 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
819 }
820 </pre>
821
822 <P>The printer <I>inherits</I> all of the definitions from the parent group (the
823 top part of the file) and adds the additional definitions inside the curly
824 braces for that printer driver. When we define the second group, it also
825 inherits the same definitions from the parent group but <I>none</I> of the
826 definitions from the first driver. Groups can be nested to any number of levels
827 to support variations of similar models without duplication of information.</P>
828
829
830 <h3><a name='COLOR'>Color Support</a></h3>
831
832 <P>For printer drivers that support color printing, the
833 <TT>ColorDevice</TT> and <TT>ColorModel</TT> directives should be
834 used to tell the printing system that color output is desired
835 and in what formats. <A HREF="#LISTING3">Listing 3</A> shows a
836 variation of the previous example which includes a color printer
837 that supports printing at 300 and 600 DPI.</P>
838
839 <P>The key changes are the addition of the <TT>ColorDevice</TT>
840 directive:</P>
841
842 <pre class='example'>
843 <a href='ref-ppdcfile.html#ColorDevice'>ColorDevice</a> true
844 </pre>
845
846 <P>which tells the printing system that the printer supports
847 color printing, and the <TT>ColorModel</TT> directives:</P>
848
849 <pre class='example'>
850 <a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> Gray/Grayscale w chunky 0
851 *<a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> RGB/Color rgb chunky 0
852 </pre>
853
854 <P>which tell the printing system which colorspaces are supported by the printer
855 driver for color printing. Each of the <TT>ColorModel</TT> directives is
856 followed by the option name and text (<TT>Gray/Grayscale</TT> and
857 <TT>RGB/Color</TT>), the colorspace name (<TT>w</TT> and <TT>rgb</TT>), the
858 color organization (<TT>chunky</TT>), and the compression mode number
859 (<TT>0</TT>) to be passed to the driver. The option name can be any of the
860 standard Adobe <TT>ColorModel</TT> names:</P>
861
862 <UL>
863
864 <LI><TT>Gray</TT> - Grayscale output.
865
866 <LI><TT>RGB</TT> - Color output, typically using the RGB
867 colorspace, but without a separate black channel.
868
869 <LI><TT>CMYK</TT> - Color output with a separate black
870 channel.
871
872 </UL>
873
874 <P>Custom names can be used, however it is recommended that you use your vendor
875 prefix for any custom names, for example "fooName".</P>
876
877 <P>The colorspace name can be any of the following universally supported
878 colorspaces:</P>
879
880 <UL>
881 <LI><TT>w</TT> - Luminance</LI>
882
883 <LI><TT>rgb</TT> - Red, green, blue</LI>
884
885 <LI><TT>k</TT> - Black</LI>
886
887 <LI><TT>cmy</TT> - Cyan, magenta, yellow</LI>
888
889 <LI><TT>cmyk</TT> - Cyan, magenta, yellow, black</LI>
890
891 </UL>
892
893 <P>The color organization can be any of the following values:</P>
894
895 <UL>
896
897 <LI><TT>chunky</TT> - Color values are passed together on a line
898 as RGB RGB RGB RGB</LI>
899
900 <LI><TT>banded</TT> - Color values are passed separately
901 on a line as RRRR GGGG BBBB; not supported by the Apple
902 RIP filters</LI>
903
904 <LI><TT>planar</TT> - Color values are passed separately
905 on a page as RRRR RRRR RRRR ... GGGG GGGG GGGG ... BBBB
906 BBBB BBBB; not supported by the Apple RIP filters</LI>
907
908 </UL>
909
910 <P>The compression mode value is passed to the driver in the
911 <TT>cupsCompression</TT> attribute. It is traditionally used to select an
912 appropriate compression mode for the color model but can be used for any
913 purpose, such as specifying a photo mode vs. standard mode.</P>
914
915 <p class='example'><a name="LISTING3">Listing 3: "examples/color.drv"</a></p>
916
917 <pre class='example'>
918
919 <I>// Include standard font and media definitions</I>
920 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
921 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
922
923 <I>// List the fonts that are supported, in this case all standard fonts...</I>
924 <a href='ref-ppdcfile.html#Font'>Font</a> *
925
926 <I>// Manufacturer and version</I>
927 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
928 <a href='ref-ppdcfile.html#Version'>Version</a> 1.0
929
930 <I>// Each filter provided by the driver...</I>
931 <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo
932
933 <I>// Supported page sizes</I>
934 *<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
935 <a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4
936
937 {
938 <I>// Supported resolutions</I>
939 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
940
941 <I>// Specify the model name and filename...</I>
942 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
943 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
944 }
945
946 {
947 <I>// Supports color printing</I>
948 <a href='ref-ppdcfile.html#ColorDevice'>ColorDevice</a> true
949
950 <I>// Supported colorspaces</I>
951 <a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> Gray/Grayscale w chunky 0
952 *<a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> RGB/Color rgb chunky 0
953
954 <I>// Supported resolutions</I>
955 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> - 8 0 0 0 "300dpi/300 DPI"
956 <a href='ref-ppdcfile.html#Resolution'>Resolution</a> - 8 0 0 0 "600dpi/600 DPI"
957
958 <I>// Specify the model name and filename...</I>
959 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet Color"
960 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojetco.ppd"
961 }
962 </pre>
963
964
965 <h3><a name='OPTIONS'>Defining Custom Options and Option Groups</a></h3>
966
967 <P>The <TT>Group</TT>, <TT>Option</TT>, and <TT>Choice</TT>
968 directives are used to define or select a group, option, or
969 choice. <A HREF="#LISTING4">Listing 4</A> shows a variation of
970 the first example that provides two custom options in a group
971 named "Footasm".</P>
972
973 <p class='example'><a name="LISTING4">Listing 4: "examples/custom.drv"</a></p>
974
975 <pre class='example'>
976
977 <I>// Include standard font and media definitions</I>
978 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
979 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
980
981 <I>// List the fonts that are supported, in this case all standard fonts...</I>
982 <a href='ref-ppdcfile.html#Font'>Font</a> *
983
984 <I>// Manufacturer, model name, and version</I>
985 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
986 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
987 <a href='ref-ppdcfile.html#Version'>Version</a> 1.0
988
989 <I>// Each filter provided by the driver...</I>
990 <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo
991
992 <I>// Supported page sizes</I>
993 *<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
994 <a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4
995
996 <I>// Supported resolutions</I>
997 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
998
999 <I>// Option Group</I>
1000 <a href='ref-ppdcfile.html#Group'>Group</a> "Footasm"
1001
1002 <I>// Boolean option</I>
1003 <a href='ref-ppdcfile.html#Option'>Option</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup 10
1004 *<a href='ref-ppdcfile.html#Choice'>Choice</a> True/Yes "&lt;&lt;/cupsCompression 1&gt;&gt;setpagedevice"
1005 <a href='ref-ppdcfile.html#Choice'>Choice</a> False/No "&lt;&lt;/cupsCompression 0&gt;&gt;setpagedevice"
1006
1007 <I>// Multiple choice option</I>
1008 <a href='ref-ppdcfile.html#Option'>Option</a> "fooOutputType/Output Quality" PickOne AnySetup 10
1009 *<a href='ref-ppdcfile.html#Choice'>Choice</a> "Auto/Automatic Selection"
1010 "&lt;&lt;/OutputType(Auto)&gt;&gt;setpagedevice""
1011 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Text/Optimize for Text"
1012 "&lt;&lt;/OutputType(Text)&gt;&gt;setpagedevice""
1013 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Graph/Optimize for Graphics"
1014 "&lt;&lt;/OutputType(Graph)&gt;&gt;setpagedevice""
1015 <a href='ref-ppdcfile.html#Choice'>Choice</a> "Photo/Optimize for Photos"
1016 "&lt;&lt;/OutputType(Photo)&gt;&gt;setpagedevice""
1017
1018 <I>// Specify the name of the PPD file we want to generate...</I>
1019 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
1020 </pre>
1021
1022 <P>The custom group is introduced by the <TT>Group</TT>
1023 directive which is followed by the name and optionally text for
1024 the user:</P>
1025
1026 <pre class='example'>
1027 <a href='ref-ppdcfile.html#Group'>Group</a> "Footasm/Footastic Options"
1028 </pre>
1029
1030 <P>The group name must conform to the PPD specification and
1031 cannot exceed 40 characters in length. If you specify user text,
1032 it cannot exceed 80 characters in length. The groups
1033 <TT>General</TT>, <TT>Extra</TT>, and
1034 <TT>InstallableOptions</TT> are predefined by CUPS; the general
1035 and extra groups are filled by the UI options defined by the PPD
1036 specification. The <TT>InstallableOptions</TT> group is reserved
1037 for options that define whether accessories for the printer
1038 (duplexer unit, finisher, stapler, etc.) are installed.</P>
1039
1040 <P>Once the group is specified, the <TT>Option</TT> directive is
1041 used to introduce a new option:</P>
1042
1043 <pre class='example'>
1044 <a href='ref-ppdcfile.html#Option'>Option</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup 10
1045 </pre>
1046
1047 <P>The directive is followed by the name of the option and any
1048 optional user text, the option type, the PostScript document group, and
1049 the sort order number. The option name must conform to the PPD specification
1050 and cannot exceed 40 characters in length. If you specify user text, it
1051 cannot exceed 80 characters in length.</P>
1052
1053 <P>The option type can be <TT>Boolean</TT> for true/false
1054 selections, <TT>PickOne</TT> for picking one of many choices, or
1055 <TT>PickMany</TT> for picking zero or more choices. Boolean
1056 options can have at most two choices with the names
1057 <TT>False</TT> and <TT>True</TT>. Pick options can have any
1058 number of choices, although for Windows compatibility reasons
1059 the number of choices should not exceed 255.</P>
1060
1061 <P>The PostScript document group is typically <TT>AnySetup</TT>,
1062 meaning that the option can be introduced at any point in the
1063 PostScript document. Other values include <TT>PageSetup</TT> to
1064 include the option before each page and <TT>DocumentSetup</TT>
1065 to include the option once at the beginning of the document.</P>
1066
1067 <P>The sort order number is used to sort the printer commands
1068 associated with each option choice within the PostScript
1069 document. This allows you to setup certain options before others
1070 as required by the printer. For most CUPS raster printer
1071 drivers, the value <TT>10</TT> can be used for all options.</P>
1072
1073 <P>Once the option is specified, each option choice can be
1074 listed using the <TT>Choice</TT> directive:</P>
1075
1076 <pre class='example'>
1077 *<a href='ref-ppdcfile.html#Choice'>Choice</a> True/Yes "&lt;&lt;/cupsCompression 1&gt;&gt;setpagedevice"
1078 <a href='ref-ppdcfile.html#Choice'>Choice</a> False/No "&lt;&lt;/cupsCompression 0&gt;&gt;setpagedevice"
1079 </pre>
1080
1081 <P>The directive is followed by the choice name and optionally
1082 user text, and the PostScript commands that should be inserted
1083 when printing a file to this printer. The option name must
1084 conform to the PPD specification and cannot exceed 40 characters
1085 in length. If you specify user text, it cannot exceed 80
1086 characters in length.</P>
1087
1088 <P>The PostScript commands are also interpreted by any RIP
1089 filters, so these commands typically must be present for all
1090 option choices. Most commands take the form:</P>
1091
1092 <pre class='example'>
1093 &lt;&lt;/name value&gt;&gt;setpagedevice
1094 </pre>
1095
1096 <P>where <TT>name</TT> is the name of the PostScript page device
1097 attribute and <TT>value</TT> is the numeric or string value for
1098 that attribute.</P>
1099
1100
1101 <h3><a name='DEFINE'>Defining Constants</a></h3>
1102
1103 <P>Sometimes you will want to define constants for your drivers
1104 so that you can share values in different groups within the same
1105 driver information file, or to share values between different
1106 driver information files using the <TT>#include</TT> directive.
1107 The <TT>#define</TT> directive is used to define constants for
1108 use in your printer definitions:</P>
1109
1110 <pre class='example'>
1111 <a href='ref-ppdcfile.html#_define'>#define</a> NAME value
1112 </pre>
1113
1114 <P>The <TT>NAME</TT> is any sequence of letters, numbers, and
1115 the underscore. The <TT>value</TT> is a number or string; if the
1116 value contains spaces you must put double quotes around it, for
1117 example:</P>
1118
1119 <pre class='example'>
1120 <a href='ref-ppdcfile.html#_define'>#define</a> FOO "My String Value"
1121 </pre>
1122
1123 <P>Constants can also be defined on the command-line using the <tt>-D</tt>
1124 option:</P>
1125
1126 <pre class='command'>
1127 ppdc -DNAME="value" filename.drv
1128 </pre>
1129
1130 <P>Once defined, you use the notation <TT>$NAME</TT> to substitute the value of
1131 the constant in the file, for example:</P>
1132
1133 <pre class='example'>
1134 <a href='ref-ppdcfile.html#_define'>#define</a> MANUFACTURER "Foo"
1135 <a href='ref-ppdcfile.html#_define'>#define</a> FOO_600 0
1136 <a href='ref-ppdcfile.html#_define'>#define</a> FOO_1200 1
1137
1138 {
1139 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "$MANUFACTURER"
1140 <a href='ref-ppdcfile.html#ModelNumber'>ModelNumber</a> $FOO_600
1141 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
1142 ...
1143 }
1144
1145 {
1146 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "$MANUFACTURER"
1147 <a href='ref-ppdcfile.html#ModelNumber'>ModelNumber</a> $FOO_1200
1148 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2001"
1149 ...
1150 }
1151 </pre>
1152
1153 <P>Numeric constants can be bitwise OR'd together by placing the constants
1154 inside parenthesis, for example:</P>
1155
1156 <pre class='example'>
1157 <I>// ModelNumber capability bits</I>
1158 <a href='ref-ppdcfile.html#_define'>#define</a> DUPLEX 1
1159 <a href='ref-ppdcfile.html#_define'>#define</a> COLOR 2
1160
1161 ...
1162
1163 {
1164 <I>// Define a model number specifying the capabilities of the printer...</I>
1165 <a href='ref-ppdcfile.html#ModelNumber'>ModelNumber</a> ($DUPLEX $COLOR)
1166 ...
1167 }
1168 </pre>
1169
1170
1171 <h3><a name='CONDITIONAL'>Conditional Statements</a></h3>
1172
1173 <p>The PPD compiler supports conditional compilation using the <tt>#if</tt>,
1174 <tt>#elif</tt>, <tt>#else</tt>, and <tt>#endif</tt> directives. The <tt>#if</tt>
1175 and <tt>#elif</tt> directives are followed by a constant name or an expression.
1176 For example, to include a group of options when "ADVANCED" is defined:</p>
1177
1178 <pre class='example'>
1179 <a href='ref-ppdcfile.html#_if'>#if</a> ADVANCED
1180 <a href='ref-ppdcfile.html#Group'>Group</a> "Advanced/Advanced Options"
1181 <a href='ref-ppdcfile.html#Option'>Option</a> "fooCyanAdjust/Cyan Adjustment"
1182 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
1183 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
1184 *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
1185 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
1186 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
1187 <a href='ref-ppdcfile.html#Option'>Option</a> "fooMagentaAdjust/Magenta Adjustment"
1188 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
1189 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
1190 *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
1191 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
1192 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
1193 <a href='ref-ppdcfile.html#Option'>Option</a> "fooYellowAdjust/Yellow Adjustment"
1194 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
1195 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
1196 *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
1197 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
1198 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
1199 <a href='ref-ppdcfile.html#Option'>Option</a> "fooBlackAdjust/Black Adjustment"
1200 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
1201 <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
1202 *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
1203 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
1204 <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
1205 <a href='ref-ppdcfile.html#_endif'>#endif</a>
1206 </pre>
1207
1208
1209 <h3><a name='CONSTRAINTS'>Defining Constraints</a></h3>
1210
1211 <P>Constraints are strings that are used to specify that one or more option
1212 choices are incompatible, for example two-sided printing on transparency media.
1213 Constraints are also used to prevent the use of uninstalled features such as the
1214 duplexer unit, additional media trays, and so forth.</P>
1215
1216 <P>The <TT>UIConstraints</TT> directive is used to specify a constraint that is
1217 placed in the PPD file. The directive is followed by a string using one of the
1218 following formats:</P>
1219
1220 <pre class='example'>
1221 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 *Option2"
1222 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 Choice1 *Option2"
1223 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 *Option2 Choice2"
1224 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 Choice1 *Option2 Choice2"
1225 </pre>
1226
1227 <P>Each option name is preceded by the asterisk (<TT>*</TT>). If no choice is
1228 given for an option, then all choices <I>except</I> <TT>False</TT> and
1229 <TT>None</TT> will conflict with the other option and choice(s). Since the PPD
1230 compiler automatically adds reciprocal constraints (option A conflicts with
1231 option B, so therefore option B conflicts with option A), you need only specify
1232 the constraint once.</P>
1233
1234 <p class='example'><a name="LISTING5">Listing 5: "examples/constraint.drv"</a></p>
1235
1236 <pre class='example'>
1237
1238 <I>// Include standard font and media definitions</I>
1239 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
1240 <a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
1241
1242 <I>// List the fonts that are supported, in this case all standard fonts...</I>
1243 <a href='ref-ppdcfile.html#Font'>Font</a> *
1244
1245 <I>// Manufacturer, model name, and version</I>
1246 <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
1247 <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
1248 <a href='ref-ppdcfile.html#Version'>Version</a> 1.0
1249
1250 <I>// Each filter provided by the driver...</I>
1251 <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo
1252
1253 <I>// Supported page sizes</I>
1254 *<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
1255 <a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4
1256
1257 <I>// Supported resolutions</I>
1258 *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
1259
1260 <I>// Installable Option Group</I>
1261 <a href='ref-ppdcfile.html#Group'>Group</a> "InstallableOptions/Options Installed"
1262
1263 <I>// Duplexing unit option</I>
1264 <a href='ref-ppdcfile.html#Option'>Option</a> "OptionDuplexer/Duplexing Unit" Boolean AnySetup 10
1265 <a href='ref-ppdcfile.html#Choice'>Choice</a> True/Installed ""
1266 *<a href='ref-ppdcfile.html#Choice'>Choice</a> "False/Not Installed" ""
1267
1268 <I>// General Option Group</I>
1269 <a href='ref-ppdcfile.html#Group'>Group</a> General
1270
1271 <I>// Duplexing option</I>
1272 <a href='ref-ppdcfile.html#Option'>Option</a> "Duplex/Two-Sided Printing" PickOne AnySetup 10
1273 *<a href='ref-ppdcfile.html#Choice'>Choice</a> "None/No" "&lt;&lt;/Duplex false&gt;&gt;setpagedevice""
1274 <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexNoTumble/Long Edge Binding"
1275 "&lt;&lt;/Duplex true/Tumble false&gt;&gt;setpagedevice""
1276 <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexTumble/Short Edge Binding"
1277 "&lt;&lt;/Duplex true/Tumble true&gt;&gt;setpagedevice""
1278
1279 <I>// Only allow duplexing if the duplexer is installed</I>
1280 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False"
1281
1282 <I>// Specify the name of the PPD file we want to generate...</I>
1283 <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
1284 </pre>
1285
1286 <P><A HREF="#LISTING5">Listing 5</A> shows a variation of the first example with
1287 an added <TT>Duplex</TT> option and installable option for the duplexer,
1288 <TT>OptionDuplex</TT>. A constraint is added at the end to specify that any
1289 choice of the <TT>Duplex</TT> option that is not <TT>None</TT> is incompatible
1290 with the "Duplexer Installed" option set to "Not Installed"
1291 (<TT>False</TT>):</P>
1292
1293 <pre class='example'>
1294 <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False"
1295 </pre>
1296
1297 <h4>Enhanced Constraints</h4>
1298
1299 <p>CUPS 1.4 supports constraints between 2 or more options using the
1300 <TT>Attribute</TT> directive. <TT>cupsUIConstraints</TT> attributes define
1301 the constraints, while <TT>cupsUIResolver</TT> attributes define option changes
1302 to resolve constraints. For example, we can specify the previous duplex
1303 constraint with a resolver that turns off duplexing with the following two
1304 lines:</p>
1305
1306 <pre class='example'>
1307 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIConstraints DuplexOff "*Duplex *OptionDuplexer False"
1308 <a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIResolver DuplexOff "*Duplex None"
1309 </pre>
1310
1311 <h2 class='title'><a name='LOCALIZATION'>Localization</a></h2>
1312
1313 <p>The PPD compiler provides localization of PPD files in different languages
1314 through <i>message catalog</i> files in the GNU gettext or Apple .strings
1315 formats. Each user text string and several key PPD attribute values such as
1316 <tt>LanguageVersion</tt> and <tt>LanguageEncoding</tt> are looked up in the
1317 corresponding message catalog and the translated text is substituted in the
1318 generated PPD files. One message catalog file can be used by multiple driver
1319 information files, and each file contains a single language translation.</p>
1320
1321 <h3><a name='PPDPO'>The ppdpo Utility</a></h3>
1322
1323 <p>While CUPS includes localizations of all standard media sizes and options in
1324 several languages, your driver information files may provide their own media
1325 sizes and options that need to be localized. CUPS provides a utility program to
1326 aid in the localization of drivers called <a
1327 href='man-ppdpo.html'><tt>ppdpo(1)</tt></a>. The <tt>ppdpo</tt> program creates
1328 or updates a message catalog file based upon one or more driver information
1329 files. New messages are added with the word "TRANSLATE" added to the front of
1330 the translation string to make locating new strings for translation easier. The
1331 program accepts the message catalog filename and one or more driver information
1332 files.</p>
1333
1334 <p>For example, run the following command to create a new German message catalog
1335 called <var>de.po</var> for all of the driver information files in the current
1336 directory:</p>
1337
1338 <pre class='command'>
1339 ppdpo -o de.po *.drv
1340 </pre>
1341
1342 <p>If the file <var>de.po</var> already exists, <tt>ppdpo</tt> will update the
1343 contents of the file with any new messages that need to be translated. To create
1344 an Apple .strings file instead, specify the output filename with a .strings
1345 extension, for example:</p>
1346
1347 <pre class='command'>
1348 ppdpo -o de.strings *.drv
1349 </pre>
1350
1351 <h3><a name='PPDC_CATALOG'>Using Message Catalogs with the PPD Compiler</a></h3>
1352
1353 <p>Once you have created a message catalog, use the <a
1354 href='ref-ppdcfile.html#_po'><tt>#po</tt></a> directive to declare it in each
1355 driver information file. For example, to declare the German message catalog for
1356 a driver use:</p>
1357
1358 <pre class='example'>
1359 <a href='ref-ppdcfile.html#_po'>#po</a> de "de.po" // German
1360 </pre>
1361
1362 <p>In fact, you can use the <tt>#po</tt> directive as many times as needed:</p>
1363
1364 <pre class='example'>
1365 <a href='ref-ppdcfile.html#_po'>#po</a> de "de.po" // German
1366 <a href='ref-ppdcfile.html#_po'>#po</a> es "es.po" // Spanish
1367 <a href='ref-ppdcfile.html#_po'>#po</a> fr "fr.po" // French
1368 <a href='ref-ppdcfile.html#_po'>#po</a> it "it.po" // Italian
1369 <a href='ref-ppdcfile.html#_po'>#po</a> ja "ja.po" // Japanese
1370 </pre>
1371
1372 <p>The filename ("de.po", etc.) can be relative to the location of the driver
1373 information file or an absolute path. Once defined, the PPD compiler will
1374 automatically generate a globalized PPD for every language declared in your
1375 driver information file. To generate a single-language PPD file, simply use the
1376 <tt>-l</tt> option to list the corresponding locale, for example:</p>
1377
1378 <pre class='command'>
1379 ppdc -l de -d ppd/de mydrivers.drv
1380 </pre>
1381
1382 <p>to generate German PPD files.</p>
1383 </div>
1384 </body>
1385 </html>