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