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