]>
Commit | Line | Data |
---|---|---|
745129be | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
8b450588 | 2 | <html> |
28b9d139 | 3 | <!-- SECTION: Programming --> |
8b450588 MS |
4 | <head> |
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"><!-- | |
9 | BODY { | |
10 | font-family: lucida grande, geneva, helvetica, arial, sans-serif; | |
11 | } | |
12 | ||
13 | H1, H2, H3, H4, H5, H6, P, TD, TH { | |
14 | font-family: lucida grande, geneva, helvetica, arial, sans-serif; | |
15 | } | |
16 | ||
17 | KBD { | |
18 | font-family: monaco, courier, monospace; | |
19 | font-weight: bold; | |
20 | } | |
21 | ||
22 | PRE { | |
23 | font-family: monaco, courier, monospace; | |
24 | } | |
25 | ||
26 | PRE.command { | |
27 | margin-left: 36pt; | |
28 | } | |
29 | ||
30 | P.example { | |
31 | font-style: italic; | |
32 | margin-left: 36pt; | |
33 | } | |
34 | ||
35 | PRE.example { | |
36 | background: #eeeeee; | |
37 | border: dotted thin #999999; | |
38 | margin-left: 36pt; | |
39 | padding: 10px; | |
40 | } | |
41 | ||
42 | PRE.command EM, PRE.example EM { | |
43 | font-family: lucida grande, geneva, helvetica, arial, sans-serif; | |
44 | } | |
45 | ||
46 | P.command { | |
47 | font-family: monaco, courier, monospace; | |
48 | margin-left: 36pt; | |
49 | } | |
50 | ||
51 | P.formula { | |
52 | font-style: italic; | |
53 | margin-left: 36pt; | |
54 | } | |
55 | ||
56 | BLOCKQUOTE { | |
57 | background: #cccccc; | |
58 | border: solid thin #999999; | |
59 | padding: 10pt; | |
60 | } | |
61 | ||
62 | A IMG { | |
63 | border: none; | |
64 | } | |
65 | ||
66 | A:link:hover IMG { | |
67 | background: #f0f0f0; | |
68 | border-radius: 10px; | |
69 | -moz-border-radius: 10px; | |
70 | } | |
71 | ||
72 | A:link, A:visited { | |
73 | font-weight: normal; | |
74 | text-decoration: none; | |
75 | } | |
76 | ||
77 | A:link:hover, A:visited:hover, A:active { | |
78 | text-decoration: underline; | |
79 | } | |
80 | ||
81 | SUB, SUP { | |
82 | font-size: 50%; | |
83 | } | |
84 | ||
85 | TR.data, TD.data, TR.data TD { | |
86 | margin-top: 10pt; | |
87 | padding: 5pt; | |
88 | border-bottom: solid 1pt #999999; | |
89 | } | |
90 | ||
91 | TR.data TH { | |
92 | border-bottom: solid 1pt #999999; | |
93 | padding-top: 10pt; | |
94 | padding-left: 5pt; | |
95 | text-align: left; | |
96 | } | |
97 | ||
98 | DIV.table TABLE { | |
99 | border: solid thin #999999; | |
100 | border-collapse: collapse; | |
101 | border-spacing: 0; | |
102 | margin-left: auto; | |
103 | margin-right: auto; | |
104 | } | |
105 | ||
106 | DIV.table CAPTION { | |
107 | caption-side: top; | |
108 | font-size: 120%; | |
109 | font-style: italic; | |
110 | font-weight: bold; | |
111 | margin-left: auto; | |
112 | margin-right: auto; | |
113 | } | |
114 | ||
115 | DIV.table TABLE TD { | |
116 | border: solid thin #cccccc; | |
117 | padding-top: 5pt; | |
118 | } | |
119 | ||
120 | DIV.table TABLE TH { | |
121 | background: #cccccc; | |
122 | border: none; | |
123 | border-bottom: solid thin #999999; | |
124 | } | |
125 | ||
126 | DIV.figure TABLE { | |
127 | margin-left: auto; | |
128 | margin-right: auto; | |
129 | } | |
130 | ||
131 | DIV.figure CAPTION { | |
132 | caption-side: bottom; | |
133 | font-size: 120%; | |
134 | font-style: italic; | |
135 | font-weight: bold; | |
136 | margin-left: auto; | |
137 | margin-right: auto; | |
138 | } | |
139 | ||
140 | TH.label { | |
141 | text-align: right; | |
142 | vertical-align: top; | |
143 | } | |
144 | ||
145 | TH.sublabel { | |
146 | text-align: right; | |
147 | font-weight: normal; | |
148 | } | |
149 | ||
150 | HR { | |
151 | border: solid thin; | |
152 | } | |
153 | ||
154 | SPAN.info { | |
155 | background: black; | |
156 | border: thin solid black; | |
157 | color: white; | |
158 | font-size: 80%; | |
159 | font-style: italic; | |
160 | font-weight: bold; | |
161 | white-space: nowrap; | |
162 | } | |
163 | ||
164 | H2 SPAN.info, H3 SPAN.info, H4 SPAN.info { | |
165 | float: right; | |
166 | font-size: 100%; | |
167 | } | |
28b9d139 | 168 | |
8b450588 MS |
169 | H2.title, H3.title { |
170 | border-bottom: solid 2pt #000000; | |
171 | } | |
172 | ||
173 | DIV.indent, TABLE.indent { | |
174 | margin-top: 2em; | |
175 | margin-left: auto; | |
176 | margin-right: auto; | |
177 | width: 90%; | |
178 | } | |
179 | ||
180 | TABLE.indent { | |
181 | border-collapse: collapse; | |
182 | } | |
183 | ||
184 | TABLE.indent TD, TABLE.indent TH { | |
185 | padding: 0; | |
186 | } | |
187 | ||
188 | TABLE.list { | |
189 | border-collapse: collapse; | |
190 | margin-left: auto; | |
191 | margin-right: auto; | |
192 | width: 90%; | |
193 | } | |
194 | ||
195 | TABLE.list TH { | |
196 | background: white; | |
197 | border-bottom: solid thin #cccccc; | |
198 | color: #444444; | |
199 | padding-top: 10pt; | |
200 | padding-left: 5pt; | |
201 | text-align: left; | |
202 | vertical-align: bottom; | |
203 | white-space: nowrap; | |
204 | } | |
205 | ||
206 | TABLE.list TH A { | |
207 | color: #4444cc; | |
208 | } | |
209 | ||
210 | TABLE.list TD { | |
211 | border-bottom: solid thin #eeeeee; | |
212 | padding-top: 5pt; | |
213 | padding-left: 5pt; | |
214 | } | |
215 | ||
216 | TABLE.list TR:nth-child(even) { | |
217 | background: #f8f8f8; | |
218 | } | |
219 | ||
220 | TABLE.list TR:nth-child(odd) { | |
221 | background: #f4f4f4; | |
222 | } | |
223 | ||
224 | DT { | |
225 | margin-left: 36pt; | |
226 | margin-top: 12pt; | |
227 | } | |
228 | ||
229 | DD { | |
230 | margin-left: 54pt; | |
231 | } | |
232 | ||
233 | DL.category DT { | |
234 | font-weight: bold; | |
235 | } | |
236 | ||
237 | P.summary { | |
238 | margin-left: 36pt; | |
239 | font-family: monaco, courier, monospace; | |
240 | } | |
241 | ||
242 | DIV.summary TABLE { | |
243 | border: solid thin #999999; | |
244 | border-collapse: collapse; | |
245 | border-spacing: 0; | |
246 | margin: 10px; | |
247 | } | |
248 | ||
249 | DIV.summary TABLE TD, DIV.summary TABLE TH { | |
250 | border: solid thin #999999; | |
251 | padding: 5px; | |
252 | text-align: left; | |
253 | vertical-align: top; | |
254 | } | |
255 | ||
256 | DIV.summary TABLE THEAD TH { | |
257 | background: #eeeeee; | |
258 | } | |
259 | ||
260 | /* API documentation styles... */ | |
261 | div.body h1 { | |
262 | margin: 0; | |
263 | } | |
264 | div.body h2 { | |
265 | margin-top: 1.5em; | |
266 | } | |
267 | div.body h3, div.body h4, div.body h5 { | |
268 | margin-bottom: 0.5em; | |
269 | margin-top: 1.5em; | |
270 | } | |
271 | .class, .enumeration, .function, .struct, .typedef, .union { | |
272 | border-bottom: solid thin #999999; | |
273 | margin-bottom: 0; | |
274 | margin-top: 2em; | |
275 | } | |
276 | .description { | |
277 | margin-top: 0.5em; | |
278 | } | |
279 | code, p.code, pre, ul.code li { | |
280 | font-family: monaco, courier, monospace; | |
281 | font-size: 90%; | |
282 | } | |
283 | ul.code, ul.contents, ul.subcontents { | |
284 | list-style-type: none; | |
285 | margin: 0; | |
286 | padding-left: 0; | |
287 | } | |
288 | ul.code li { | |
289 | margin: 0; | |
290 | } | |
291 | ul.contents > li { | |
292 | margin-top: 1em; | |
293 | } | |
294 | ul.contents li ul.code, ul.contents li ul.subcontents { | |
295 | padding-left: 2em; | |
296 | } | |
297 | div.body dl { | |
298 | margin-left: 0; | |
299 | margin-top: 0; | |
300 | } | |
301 | div.body dt { | |
302 | font-style: italic; | |
303 | margin-left: 0; | |
304 | margin-top: 0; | |
305 | } | |
306 | div.body dd { | |
307 | margin-bottom: 0.5em; | |
308 | } | |
309 | ||
310 | /* This is just for the HTML files generated with the framedhelp target */ | |
311 | div.contents { | |
312 | background: #e8e8e8; | |
313 | border: solid thin black; | |
314 | padding: 10px; | |
315 | } | |
316 | div.contents h1 { | |
317 | font-size: 110%; | |
318 | } | |
319 | div.contents h2 { | |
320 | font-size: 100%; | |
321 | } | |
322 | div.contents ul.contents { | |
323 | font-size: 80%; | |
324 | } | |
325 | div.contents ul.subcontents li { | |
326 | margin-left: 1em; | |
327 | text-indent: -1em; | |
328 | } | |
329 | --></style> | |
330 | </head> | |
331 | <body> | |
332 | <div class='body'> | |
28b9d139 MS |
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> | |
336 | ||
337 | <div class='summary'><table summary='General Information'> | |
338 | <tbody> | |
339 | <tr> | |
340 | <th>See Also</th> | |
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> | |
347 | </tr> | |
348 | </tbody> | |
349 | </table></div> | |
8b450588 MS |
350 | <h2 class="title">Contents</h2> |
351 | <ul class="contents"> | |
426c6a59 | 352 | <ul class="subcontents"> |
8b450588 MS |
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> | |
362 | </ul></li> | |
28b9d139 MS |
363 | <h2 class='title'><a name='BASICS'>The Basics</a></h2> |
364 | ||
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> | |
371 | ||
372 | <pre class='command'> | |
373 | ppdc mydrivers.drv | |
374 | </pre> | |
375 | ||
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> | |
379 | ||
380 | <pre class='command'> | |
381 | ppdc -d myppds mydrivers.drv | |
382 | </pre> | |
383 | ||
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> | |
388 | ||
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 | |
395 | </pre> | |
396 | ||
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> | |
401 | ||
402 | <pre class='command'> | |
403 | ppdc -d myppds -l de,en,es,fr,it mydrivers.drv | |
404 | </pre> | |
405 | ||
406 | ||
407 | <h2 class='title'><a name='DRV'>Driver Information Files</a></h2> | |
408 | ||
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> | |
414 | ||
415 | <p class='example'><a name="LISTING1">Listing 1: "examples/minimum.drv"</a></p> | |
416 | ||
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> | |
421 | ||
422 | <I>// List the fonts that are supported, in this case all standard fonts...</I> | |
423 | <a href='ref-ppdcfile.html#Font'>Font</a> * | |
424 | ||
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 | |
429 | ||
430 | <I>// Each filter provided by the driver...</I> | |
431 | <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo | |
432 | ||
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 | |
436 | ||
437 | <I>// Supported resolutions</I> | |
438 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI" | |
439 | ||
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" | |
442 | </pre> | |
443 | ||
444 | ||
445 | <h3><a name='SIMPLE'>A Simple Example</a></h3> | |
446 | ||
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 | |
450 | media sizes:</P> | |
451 | ||
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> | |
455 | </pre> | |
456 | ||
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 | |
465 | Specification.</P> | |
466 | ||
467 | <P>CUPS provides several other standard include files:</P> | |
468 | ||
469 | <UL> | |
470 | ||
471 | <LI><TT><epson.h></TT> - Defines all of the rastertoepson driver | |
472 | constants.</LI> | |
473 | ||
474 | <LI><TT><escp.h></TT> - Defines all of the rastertoescpx driver | |
475 | constants.</LI> | |
476 | ||
477 | <LI><TT><hp.h></TT> - Defines all of the rastertohp driver | |
478 | constants.</LI> | |
479 | ||
480 | <LI><TT><label.h></TT> - Defines all of the rastertolabel driver | |
481 | constants.</LI> | |
482 | ||
483 | <LI><TT><pcl.h></TT> - Defines all of the rastertopclx driver | |
484 | constants.</LI> | |
485 | ||
486 | <LI><TT><raster.defs></TT> - Defines all of the CUPS raster format | |
487 | constants.</LI> | |
488 | ||
489 | </UL> | |
490 | ||
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> | |
493 | ||
494 | <pre class='example'> | |
495 | <a href='ref-ppdcfile.html#Font'>Font</a> * | |
496 | </pre> | |
497 | ||
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 | |
501 | driver:</P> | |
502 | ||
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 | |
506 | </pre> | |
507 | ||
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> | |
513 | ||
514 | <P>Third comes the manufacturer, model name, and version number information | |
515 | strings:</P> | |
516 | ||
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 | |
521 | </pre> | |
522 | ||
523 | <P>These strings are used when the user (or auto-configuration program) selects | |
524 | the printer driver for a newly connected device.</p> | |
525 | ||
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 | |
528 | raster data:</P> | |
529 | ||
530 | <pre class='example'> | |
531 | <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo | |
532 | </pre> | |
533 | ||
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> | |
538 | ||
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> | |
542 | ||
543 | <pre class='example'> | |
544 | *<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter | |
545 | <a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4 | |
546 | ||
547 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI" | |
548 | </pre> | |
549 | ||
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> | |
557 | ||
558 | <P>The <TT>Resolution</TT> directive accepts several values after it as | |
559 | follows:</P> | |
560 | ||
561 | <OL> | |
562 | ||
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> | |
567 | ||
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> | |
572 | ||
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 | |
575 | bands.</LI> | |
576 | ||
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> | |
579 | ||
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> | |
586 | ||
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 | |
596 | not.</LI> | |
597 | ||
598 | </OL> | |
599 | ||
600 | <P>Finally, the <TT>PCFileName</TT> directive specifies that the named PPD file | |
601 | should be written for the current driver definitions:</P> | |
602 | ||
603 | <pre class='example'> | |
604 | <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd" | |
605 | </pre> | |
606 | ||
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> | |
612 | ||
613 | <pre class='example'> | |
614 | <a href='ref-ppdcfile.html#FileName'>FileName</a> "FooJet 2000" | |
615 | </pre> | |
616 | ||
617 | ||
618 | <h3><a name='GROUPING'>Grouping and Inheritance</a></h3> | |
619 | ||
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 | |
627 | options.</P> | |
628 | ||
629 | <p class='example'><a name="LISTING2">Listing 2: "examples/grouping.drv"</a></p> | |
630 | ||
631 | <pre class='example'> | |
632 | ||
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> | |
636 | ||
637 | <I>// List the fonts that are supported, in this case all standard fonts...</I> | |
638 | <a href='ref-ppdcfile.html#Font'>Font</a> * | |
639 | ||
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 | |
643 | ||
644 | <I>// Each filter provided by the driver...</I> | |
645 | <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo | |
646 | ||
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 | |
650 | ||
651 | { | |
652 | <I>// Supported resolutions</I> | |
653 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI" | |
654 | ||
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" | |
658 | } | |
659 | ||
660 | { | |
661 | <I>// Supported resolutions</I> | |
662 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "1200dpi/1200 DPI" | |
663 | ||
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" | |
667 | } | |
668 | </pre> | |
669 | ||
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> | |
673 | ||
674 | <pre class='example'> | |
675 | { | |
676 | // Supported resolutions | |
677 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI" | |
678 | ||
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" | |
682 | } | |
683 | </pre> | |
684 | ||
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> | |
691 | ||
692 | ||
693 | <h3><a name='COLOR'>Color Support</a></h3> | |
694 | ||
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> | |
701 | ||
702 | <P>The key changes are the addition of the <TT>ColorDevice</TT> | |
703 | directive:</P> | |
704 | ||
705 | <pre class='example'> | |
706 | <a href='ref-ppdcfile.html#ColorDevice'>ColorDevice</a> true | |
707 | </pre> | |
708 | ||
709 | <P>which tells the printing system that the printer supports | |
710 | color printing, and the <TT>ColorModel</TT> directives:</P> | |
711 | ||
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 | |
715 | </pre> | |
716 | ||
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> | |
724 | ||
725 | <UL> | |
726 | ||
727 | <LI><TT>Gray</TT> - Grayscale output. | |
728 | ||
729 | <LI><TT>RGB</TT> - Color output, typically using the RGB | |
730 | colorspace, but without a separate black channel. | |
731 | ||
732 | <LI><TT>CMYK</TT> - Color output with a separate black | |
733 | channel. | |
734 | ||
735 | </UL> | |
736 | ||
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> | |
739 | ||
740 | <P>The colorspace name can be any of the following universally supported | |
741 | colorspaces:</P> | |
742 | ||
743 | <UL> | |
744 | <LI><TT>w</TT> - Luminance</LI> | |
745 | ||
746 | <LI><TT>rgb</TT> - Red, green, blue</LI> | |
747 | ||
748 | <LI><TT>k</TT> - Black</LI> | |
749 | ||
750 | <LI><TT>cmy</TT> - Cyan, magenta, yellow</LI> | |
751 | ||
752 | <LI><TT>cmyk</TT> - Cyan, magenta, yellow, black</LI> | |
753 | ||
754 | </UL> | |
755 | ||
756 | <P>The color organization can be any of the following values:</P> | |
757 | ||
758 | <UL> | |
759 | ||
760 | <LI><TT>chunky</TT> - Color values are passed together on a line | |
761 | as RGB RGB RGB RGB</LI> | |
762 | ||
763 | <LI><TT>banded</TT> - Color values are passed separately | |
764 | on a line as RRRR GGGG BBBB; not supported by the Apple | |
765 | RIP filters</LI> | |
766 | ||
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> | |
770 | ||
771 | </UL> | |
772 | ||
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> | |
777 | ||
778 | <p class='example'><a name="LISTING3">Listing 3: "examples/color.drv"</a></p> | |
779 | ||
780 | <pre class='example'> | |
781 | ||
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> | |
785 | ||
786 | <I>// List the fonts that are supported, in this case all standard fonts...</I> | |
787 | <a href='ref-ppdcfile.html#Font'>Font</a> * | |
788 | ||
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 | |
792 | ||
793 | <I>// Each filter provided by the driver...</I> | |
794 | <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo | |
795 | ||
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 | |
799 | ||
800 | { | |
801 | <I>// Supported resolutions</I> | |
802 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI" | |
803 | ||
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" | |
807 | } | |
808 | ||
809 | { | |
810 | <I>// Supports color printing</I> | |
811 | <a href='ref-ppdcfile.html#ColorDevice'>ColorDevice</a> true | |
812 | ||
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 | |
816 | ||
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" | |
820 | ||
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" | |
824 | } | |
825 | </pre> | |
826 | ||
827 | ||
828 | <h3><a name='OPTIONS'>Defining Custom Options and Option Groups</a></h3> | |
829 | ||
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 | |
834 | named "Footasm".</P> | |
835 | ||
836 | <p class='example'><a name="LISTING4">Listing 4: "examples/custom.drv"</a></p> | |
837 | ||
838 | <pre class='example'> | |
839 | ||
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> | |
843 | ||
844 | <I>// List the fonts that are supported, in this case all standard fonts...</I> | |
845 | <a href='ref-ppdcfile.html#Font'>Font</a> * | |
846 | ||
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 | |
851 | ||
852 | <I>// Each filter provided by the driver...</I> | |
853 | <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo | |
854 | ||
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 | |
858 | ||
859 | <I>// Supported resolutions</I> | |
860 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI" | |
861 | ||
862 | <I>// Option Group</I> | |
863 | <a href='ref-ppdcfile.html#Group'>Group</a> "Footasm" | |
864 | ||
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" | |
869 | ||
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"" | |
880 | ||
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" | |
883 | </pre> | |
884 | ||
885 | <P>The custom group is introduced by the <TT>Group</TT> | |
886 | directive which is followed by the name and optionally text for | |
887 | the user:</P> | |
888 | ||
889 | <pre class='example'> | |
890 | <a href='ref-ppdcfile.html#Group'>Group</a> "Footasm/Footastic Options" | |
891 | </pre> | |
892 | ||
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> | |
902 | ||
903 | <P>Once the group is specified, the <TT>Option</TT> directive is | |
904 | used to introduce a new option:</P> | |
905 | ||
906 | <pre class='example'> | |
907 | <a href='ref-ppdcfile.html#Option'>Option</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup 10 | |
908 | </pre> | |
909 | ||
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> | |
915 | ||
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> | |
923 | ||
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> | |
929 | ||
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> | |
935 | ||
936 | <P>Once the option is specified, each option choice can be | |
937 | listed using the <TT>Choice</TT> directive:</P> | |
938 | ||
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" | |
942 | </pre> | |
943 | ||
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> | |
950 | ||
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> | |
954 | ||
955 | <pre class='example'> | |
956 | <</name value>>setpagedevice | |
957 | </pre> | |
958 | ||
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 | |
961 | that attribute.</P> | |
962 | ||
963 | ||
964 | <h3><a name='DEFINE'>Defining Constants</a></h3> | |
965 | ||
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> | |
972 | ||
973 | <pre class='example'> | |
974 | <a href='ref-ppdcfile.html#_define'>#define</a> NAME value | |
975 | </pre> | |
976 | ||
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 | |
980 | example:</P> | |
981 | ||
982 | <pre class='example'> | |
983 | <a href='ref-ppdcfile.html#_define'>#define</a> FOO "My String Value" | |
984 | </pre> | |
985 | ||
986 | <P>Constants can also be defined on the command-line using the <tt>-D</tt> | |
987 | option:</P> | |
988 | ||
989 | <pre class='command'> | |
990 | ppdc -DNAME="value" filename.drv | |
991 | </pre> | |
992 | ||
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> | |
995 | ||
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 | |
1000 | ||
1001 | { | |
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" | |
1005 | ... | |
1006 | } | |
1007 | ||
1008 | { | |
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" | |
1012 | ... | |
1013 | } | |
1014 | </pre> | |
1015 | ||
1016 | <P>Numeric constants can be bitwise OR'd together by placing the constants | |
1017 | inside parenthesis, for example:</P> | |
1018 | ||
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 | |
1023 | ||
1024 | ... | |
1025 | ||
1026 | { | |
1027 | <I>// Define a model number specifying the capabilities of the printer...</I> | |
1028 | <a href='ref-ppdcfile.html#ModelNumber'>ModelNumber</a> ($DUPLEX $COLOR) | |
1029 | ... | |
1030 | } | |
1031 | </pre> | |
1032 | ||
1033 | ||
1034 | <h3><a name='CONDITIONAL'>Conditional Statements</a></h3> | |
1035 | ||
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> | |
1040 | ||
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> | |
1069 | </pre> | |
1070 | ||
1071 | ||
1072 | <h3><a name='CONSTRAINTS'>Defining Constraints</a></h3> | |
1073 | ||
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> | |
1078 | ||
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> | |
1082 | ||
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" | |
1088 | </pre> | |
1089 | ||
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> | |
1096 | ||
1097 | <p class='example'><a name="LISTING5">Listing 5: "examples/constraint.drv"</a></p> | |
1098 | ||
1099 | <pre class='example'> | |
1100 | ||
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> | |
1104 | ||
1105 | <I>// List the fonts that are supported, in this case all standard fonts...</I> | |
1106 | <a href='ref-ppdcfile.html#Font'>Font</a> * | |
1107 | ||
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 | |
1112 | ||
1113 | <I>// Each filter provided by the driver...</I> | |
1114 | <a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo | |
1115 | ||
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 | |
1119 | ||
1120 | <I>// Supported resolutions</I> | |
1121 | *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI" | |
1122 | ||
1123 | <I>// Installable Option Group</I> | |
1124 | <a href='ref-ppdcfile.html#Group'>Group</a> "InstallableOptions/Options Installed" | |
1125 | ||
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" "" | |
1130 | ||
1131 | <I>// General Option Group</I> | |
1132 | <a href='ref-ppdcfile.html#Group'>Group</a> General | |
1133 | ||
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"" | |
1141 | ||
1142 | <I>// Only allow duplexing if the duplexer is installed</I> | |
1143 | <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False" | |
1144 | ||
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" | |
1147 | </pre> | |
1148 | ||
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> | |
1155 | ||
1156 | <pre class='example'> | |
1157 | <a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False" | |
1158 | </pre> | |
1159 | ||
1160 | <h4>Enhanced Constraints</h4> | |
1161 | ||
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 | |
1167 | lines:</p> | |
1168 | ||
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" | |
1172 | </pre> | |
8b450588 MS |
1173 | </div> |
1174 | </body> | |
1175 | </html> |