File: ppd-compiler.shtml

package info (click to toggle)
cups 1.4.4-7+squeeze10
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 25,548 kB
  • ctags: 9,583
  • sloc: ansic: 138,214; sh: 37,926; cpp: 25,469; makefile: 3,285; perl: 190; python: 127; php: 28
file content (883 lines) | stat: -rw-r--r-- 36,689 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
<h2 class='title'><a name='BASICS'>The Basics</a></h2>

<P>The PPD compiler, <a href='man-ppdc.html'><code>ppdc(1)</code></a>, is a
simple command-line tool that takes a single <I>driver information file</I>,
which by convention uses the extension <VAR>.drv</VAR>, and produces one or more
PPD files that may be distributed with your printer drivers for use with CUPS.
For example, you would run the following command to create the English language
PPD files defined by the driver information file <VAR>mydrivers.drv</VAR>:</P>

<pre class='command'>
ppdc mydrivers.drv
</pre>

<P>The PPD files are placed in a subdirectory called
<VAR>ppd</VAR>. The <TT>-d</TT> option is used to put the PPD
files in a different location, for example:</p>

<pre class='command'>
ppdc -d myppds mydrivers.drv
</pre>

<P>places the PPD files in a subdirectory named
<VAR>myppds</VAR>. Finally, use the <TT>-l</TT> option to
specify the language localization for the PPD files that are
created, for example:</P>

<pre class='command'>
ppdc -d myppds/de -l de mydrivers.drv
ppdc -d myppds/en -l en mydrivers.drv
ppdc -d myppds/es -l es mydrivers.drv
ppdc -d myppds/fr -l fr mydrivers.drv
ppdc -d myppds/it -l it mydrivers.drv
</pre>

<P>creates PPD files in German (de), English (en), Spanish (es),
French (fr), and Italian (it) in the corresponding
subdirectories. Specify multiple languages (separated by commas) to produce
"globalized" PPD files:</p>

<pre class='command'>
ppdc -d myppds -l de,en,es,fr,it mydrivers.drv
</pre>


<h2 class='title'><a name='DRV'>Driver Information Files</a></h2>

<P>The driver information files accepted by the PPD compiler are
plain text files that define the various attributes and options
that are included in the PPD files that are generated. A driver
information file can define the information for one or more printers and
their corresponding PPD files.</P>

<p class='example'><a name="LISTING1">Listing 1: "examples/minimum.drv"</a></p>

<pre class='example'>
<I>// Include standard font and media definitions</I>
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard fonts...</I>
<a href='ref-ppdcfile.html#Font'>Font</a> *

<I>// Manufacturer, model name, and version</I>
<a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
<a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
<a href='ref-ppdcfile.html#Version'>Version</a> 1.0

<I>// Each filter provided by the driver...</I>
<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4

<I>// Supported resolutions</I>
*<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"

<I>// Specify the name of the PPD file we want to generate...</I>
<a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
</pre>


<h3><a name='SIMPLE'>A Simple Example</a></h3>

<P>The example in <A HREF="#LISTING1">Listing 1</A> shows a driver information
file which defines the minimum required attributes to provide a valid PPD file.
The first part of the file includes standard definition files for fonts and
media sizes:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
</pre>

<P>The <TT>#include</TT> directive works just like the C/C++ include directive;
files included using the angle brackets (<TT>&lt;filename&gt;</TT>) are found
in any of the standard include directories and files included using quotes
(<TT>"filename"</TT>) are found in the same directory as the source or include
file. The <TT>&lt;font.defs&gt;</TT> include file defines the standard fonts
which are included with GPL Ghostscript and the Apple PDF RIP, while the
<TT>&lt;media.defs&gt;</TT> include file defines the standard media sizes
listed in Appendix B of the Adobe PostScript Printer Description File Format
Specification.</P>

<P>CUPS provides several other standard include files:</P>

<UL>

	<LI><TT>&lt;epson.h&gt;</TT> - Defines all of the rastertoepson driver
	constants.</LI>

	<LI><TT>&lt;escp.h&gt;</TT> - Defines all of the rastertoescpx driver
	constants.</LI>

	<LI><TT>&lt;hp.h&gt;</TT> - Defines all of the rastertohp driver
	constants.</LI>

	<LI><TT>&lt;label.h&gt;</TT> - Defines all of the rastertolabel driver
	constants.</LI>

	<LI><TT>&lt;pcl.h&gt;</TT> - Defines all of the rastertopclx driver
	constants.</LI>

	<LI><TT>&lt;raster.defs&gt;</TT> - Defines all of the CUPS raster format
	constants.</LI>

</UL>

<P>Next we list all of the fonts that are available in the driver; for CUPS
raster drivers, the following line is all that is usually supplied:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#Font'>Font</a> *
</pre>

<P>The <TT>Font</TT> directive specifies the name of a single font or the
asterisk to specify all fonts. For example, you would use the following line to
define an additional bar code font that you are supplying with your printer
driver:</P>

<pre class='example'>
<I>//   name         encoding  version  charset  status</I>
<a href='ref-ppdcfile.html#Font'>Font</a> Barcode-Foo  Special   "(1.0)"  Special  ROM
</pre>

<P>The name of the font is <TT>Barcode-Foo</TT>. Since it is not a standard
text font, the encoding and charset name <TT>Special</TT> is used. The version
number is <TT>1.0</TT> and the status (where the font is located) is
<TT>ROM</TT> to indicate that the font does not need to be embedded in
documents that use the font for this printer.</P>

<P>Third comes the manufacturer, model name, and version number information
strings:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
<a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
<a href='ref-ppdcfile.html#Version'>Version</a> 1.0
</pre>

<P>These strings are used when the user (or auto-configuration program) selects
the printer driver for a newly connected device.</p>

<P>The list of filters comes after the information strings; for the example in
<A HREF="#LISTING1">Listing 1</A>, we have a single filter that takes CUPS
raster data:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo
</pre>

<P>Each filter specified in the driver information file is the equivalent of a
printer driver for that format; if a user submits a print job in a different
format, CUPS figures out the sequence of commands that will produce a supported
format for the least relative cost.</P>

<P>Once we have defined the driver information we specify the supported options.
For the example driver we support a single resolution of 600 dots per inch and
two media sizes, A4 and Letter:</P>

<pre class='example'>
*<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4

*<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"
</pre>

<P>The asterisk in front of the <TT>MediaSize</TT> and <TT>Resolution</TT>
directives specify that those option choices are the default. The
<TT>MediaSize</TT> directive is followed by a media size name which is normally
defined in the <TT>&lt;media.defs&gt;</TT> file and corresponds to a standard
Adobe media size name. If the default media size is <TT>Letter</TT>, the PPD
compiler will override it to be <TT>A4</TT> for non-English localizations for
you automatically.</P>

<P>The <TT>Resolution</TT> directive accepts several values after it as
follows:</P>

<OL>

	<LI>Colorspace for this resolution, if any. In the example file, the
	colorspace <TT>k</TT> is used which corresponds to black. For printer
	drivers that support color printing, this field is usually specified as
	"-" for "no change".</LI>

	<LI>Bits per color. In the example file, we define 8 bits per color, for
	a continuous-tone grayscale output. All versions of CUPS support 1 and
	8 bits per color.  CUPS 1.2 and higher (Mac OS X 10.5 and higher) also
	supports 16 bits per color.</LI>

	<LI>Rows per band. In the example file, we define 0 rows per band to
	indicate that our printer driver does not process the page in
	bands.</LI>

	<LI>Row feed. In the example, we define the feed value to be 0 to
	indicate that our printer driver does not interleave the output.</LI>

	<LI>Row step. In the example, we define the step value to be 0 to
	indicate that our printer driver does not interleave the output. This
	value normally indicates the spacing between the nozzles of an inkjet
	printer - when combined with the previous two values, it informs the
	driver how to stagger the output on the page to produce interleaved
	lines on the page for higher-resolution output.</LI>

	<LI>Choice name and text. In the example, we define the choice name and
	text to be <TT>"600dpi/600 DPI"</TT>. The name and text are separated by
	slash (<TT>/</TT>) character; if no text is specified, then the name is
	used as the text. The PPD compiler parses the name to determine the
	actual resolution; the name can be of the form
	<TT><I>RESOLUTION</I>dpi</TT> for resolutions that are equal
	horizontally and vertically or <TT><I>HRES</I>x<I>VRES</I>dpi</TT> for
	isometric resolutions. Only integer resolution values are supported, so
	a resolution name of <TT>300dpi</TT> is valid while <TT>300.1dpi</TT> is
	not.</LI>

</OL>

<P>Finally, the <TT>PCFileName</TT> directive specifies that the named PPD file
should be written for the current driver definitions:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
</pre>

<P>The filename follows the directive and <I>must</I> conform to the Adobe
filename requirements in the Adobe Postscript Printer Description File Format
Specification. Specifically, the filename may not exceed 8 characters followed
by the extension <VAR>.ppd</VAR>. The <TT>FileName</TT> directive can be used to
specify longer filenames:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#FileName'>FileName</a> "FooJet 2000"
</pre>


<h3><a name='GROUPING'>Grouping and Inheritance</a></h3>

<P>The previous example created a single PPD file. Driver information files can
also define multiple printers by using the PPD compiler grouping functionality.
Directives are grouped using the curly braces (<TT>{</TT> and <TT>}</TT>) and
every group that uses the <TT>PCFileName</TT> or <TT>FileName</TT> directives
produces a PPD file with that name. <A HREF="#LISTING2">Listing 2</A> shows a
variation of the original example that uses two groups to define two printers
that share the same printer driver filter but provide two different resolution
options.</P>

<p class='example'><a name="LISTING2">Listing 2: "examples/grouping.drv"</a></p>

<pre class='example'>

<I>// Include standard font and media definitions</I>
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard fonts...</I>
<a href='ref-ppdcfile.html#Font'>Font</a> *

<I>// Manufacturer and version</I>
<a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
<a href='ref-ppdcfile.html#Version'>Version</a> 1.0

<I>// Each filter provided by the driver...</I>
<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4

{
  <I>// Supported resolutions</I>
  *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"

  <I>// Specify the model name and filename...</I>
  <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
  <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
}

{
  <I>// Supported resolutions</I>
  *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "1200dpi/1200 DPI"

  <I>// Specify the model name and filename...</I>
  <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2001"
  <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojt2k1.ppd"
}
</pre>

<P>The second example is essentially the same as the first, except that each
printer model is defined inside of a pair of curly braces. For example, the
first printer is defined using:</P>

<pre class='example'>
{
  // Supported resolutions
  *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"

  // Specify the model name and filename...
  <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
  <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
}
</pre>

<P>The printer <I>inherits</I> all of the definitions from the parent group (the
top part of the file) and adds the additional definitions inside the curly
braces for that printer driver. When we define the second group, it also
inherits the same definitions from the parent group but <I>none</I> of the
definitions from the first driver. Groups can be nested to any number of levels
to support variations of similar models without duplication of information.</P>


<h3><a name='COLOR'>Color Support</a></h3>

<P>For printer drivers that support color printing, the
<TT>ColorDevice</TT> and <TT>ColorModel</TT> directives should be
used to tell the printing system that color output is desired
and in what formats. <A HREF="#LISTING3">Listing 3</A> shows a
variation of the previous example which includes a color printer
that supports printing at 300 and 600 DPI.</P>

<P>The key changes are the addition of the <TT>ColorDevice</TT>
directive:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#ColorDevice'>ColorDevice</a> true
</pre>

<P>which tells the printing system that the printer supports
color printing, and the <TT>ColorModel</TT> directives:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> Gray/Grayscale w chunky 0
*<a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> RGB/Color rgb chunky 0
</pre>

<P>which tell the printing system which colorspaces are supported by the printer
driver for color printing. Each of the <TT>ColorModel</TT> directives is
followed by the option name and text (<TT>Gray/Grayscale</TT> and
<TT>RGB/Color</TT>), the colorspace name (<TT>w</TT> and <TT>rgb</TT>), the
color organization (<TT>chunky</TT>), and the compression mode number
(<TT>0</TT>) to be passed to the driver. The option name can be any of the
standard Adobe <TT>ColorModel</TT> names:</P>

<UL>

	<LI><TT>Gray</TT> - Grayscale output.

	<LI><TT>RGB</TT> - Color output, typically using the RGB
	colorspace, but without a separate black channel.

	<LI><TT>CMYK</TT> - Color output with a separate black
	channel.

</UL>

<P>Custom names can be used, however it is recommended that you use your vendor
prefix for any custom names, for example "fooName".</P>

<P>The colorspace name can be any of the following universally supported
colorspaces:</P>

<UL>
	<LI><TT>w</TT> - Luminance</LI>

	<LI><TT>rgb</TT> - Red, green, blue</LI>

	<LI><TT>k</TT> - Black</LI>

	<LI><TT>cmy</TT> - Cyan, magenta, yellow</LI>

	<LI><TT>cmyk</TT> - Cyan, magenta, yellow, black</LI>

</UL>

<P>The color organization can be any of the following values:</P>

<UL>

	<LI><TT>chunky</TT> - Color values are passed together on a line
	as RGB RGB RGB RGB</LI>

	<LI><TT>banded</TT> - Color values are passed separately
	on a line as RRRR GGGG BBBB; not supported by the Apple
	RIP filters</LI>

	<LI><TT>planar</TT> - Color values are passed separately
	on a page as RRRR RRRR RRRR ... GGGG GGGG GGGG ... BBBB
	BBBB BBBB; not supported by the Apple RIP filters</LI>

</UL>

<P>The compression mode value is passed to the driver in the
<TT>cupsCompression</TT> attribute. It is traditionally used to select an
appropriate compression mode for the color model but can be used for any
purpose, such as specifying a photo mode vs. standard mode.</P>

<p class='example'><a name="LISTING3">Listing 3: "examples/color.drv"</a></p>

<pre class='example'>

<I>// Include standard font and media definitions</I>
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard fonts...</I>
<a href='ref-ppdcfile.html#Font'>Font</a> *

<I>// Manufacturer and version</I>
<a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
<a href='ref-ppdcfile.html#Version'>Version</a> 1.0

<I>// Each filter provided by the driver...</I>
<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4

{
  <I>// Supported resolutions</I>
  *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"

  <I>// Specify the model name and filename...</I>
  <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
  <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
}

{
  <I>// Supports color printing</I>
  <a href='ref-ppdcfile.html#ColorDevice'>ColorDevice</a> true

  <I>// Supported colorspaces</I>
  <a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> Gray/Grayscale w chunky 0
  *<a href='ref-ppdcfile.html#ColorModel'>ColorModel</a> RGB/Color rgb chunky 0

  <I>// Supported resolutions</I>
  *<a href='ref-ppdcfile.html#Resolution'>Resolution</a> - 8 0 0 0 "300dpi/300 DPI"
  <a href='ref-ppdcfile.html#Resolution'>Resolution</a> - 8 0 0 0 "600dpi/600 DPI"

  <I>// Specify the model name and filename...</I>
  <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet Color"
  <a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojetco.ppd"
}
</pre>


<h3><a name='OPTIONS'>Defining Custom Options and Option Groups</a></h3>

<P>The <TT>Group</TT>, <TT>Option</TT>, and <TT>Choice</TT>
directives are used to define or select a group, option, or
choice. <A HREF="#LISTING4">Listing 4</A> shows a variation of
the first example that provides two custom options in a group
named "Footasm".</P>

<p class='example'><a name="LISTING4">Listing 4: "examples/custom.drv"</a></p>

<pre class='example'>

<I>// Include standard font and media definitions</I>
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard fonts...</I>
<a href='ref-ppdcfile.html#Font'>Font</a> *

<I>// Manufacturer, model name, and version</I>
<a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
<a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
<a href='ref-ppdcfile.html#Version'>Version</a> 1.0

<I>// Each filter provided by the driver...</I>
<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4

<I>// Supported resolutions</I>
*<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"

<I>// Option Group</I>
<a href='ref-ppdcfile.html#Group'>Group</a> "Footasm"

  <I>// Boolean option</I>
  <a href='ref-ppdcfile.html#Option'>Option</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup 10
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> True/Yes "&lt;&lt;/cupsCompression 1&gt;&gt;setpagedevice"
    <a href='ref-ppdcfile.html#Choice'>Choice</a> False/No "&lt;&lt;/cupsCompression 0&gt;&gt;setpagedevice"

  <I>// Multiple choice option</I>
  <a href='ref-ppdcfile.html#Option'>Option</a> "fooOutputType/Output Quality" PickOne AnySetup 10
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> "Auto/Automatic Selection"
            "&lt;&lt;/OutputType(Auto)&gt;&gt;setpagedevice""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "Text/Optimize for Text"
            "&lt;&lt;/OutputType(Text)&gt;&gt;setpagedevice""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "Graph/Optimize for Graphics"
            "&lt;&lt;/OutputType(Graph)&gt;&gt;setpagedevice""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "Photo/Optimize for Photos"
            "&lt;&lt;/OutputType(Photo)&gt;&gt;setpagedevice""

<I>// Specify the name of the PPD file we want to generate...</I>
<a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
</pre>

<P>The custom group is introduced by the <TT>Group</TT>
directive which is followed by the name and optionally text for
the user:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#Group'>Group</a> "Footasm/Footastic Options"
</pre>

<P>The group name must conform to the PPD specification and
cannot exceed 40 characters in length. If you specify user text,
it cannot exceed 80 characters in length. The groups
<TT>General</TT>, <TT>Extra</TT>, and
<TT>InstallableOptions</TT> are predefined by CUPS; the general
and extra groups are filled by the UI options defined by the PPD
specification. The <TT>InstallableOptions</TT> group is reserved
for options that define whether accessories for the printer
(duplexer unit, finisher, stapler, etc.) are installed.</P>

<P>Once the group is specified, the <TT>Option</TT> directive is
used to introduce a new option:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#Option'>Option</a> "fooEnhance/Resolution Enhancement" Boolean AnySetup 10
</pre>

<P>The directive is followed by the name of the option and any
optional user text, the option type, the PostScript document group, and
the sort order number. The option name must conform to the PPD specification
and cannot exceed 40 characters in length. If you specify user text, it
cannot exceed 80 characters in length.</P>

<P>The option type can be <TT>Boolean</TT> for true/false
selections, <TT>PickOne</TT> for picking one of many choices, or
<TT>PickMany</TT> for picking zero or more choices. Boolean
options can have at most two choices with the names
<TT>False</TT> and <TT>True</TT>. Pick options can have any
number of choices, although for Windows compatibility reasons
the number of choices should not exceed 255.</P>

<P>The PostScript document group is typically <TT>AnySetup</TT>,
meaning that the option can be introduced at any point in the
PostScript document. Other values include <TT>PageSetup</TT> to
include the option before each page and <TT>DocumentSetup</TT>
to include the option once at the beginning of the document.</P>

<P>The sort order number is used to sort the printer commands
associated with each option choice within the PostScript
document. This allows you to setup certain options before others
as required by the printer. For most CUPS raster printer
drivers, the value <TT>10</TT> can be used for all options.</P>

<P>Once the option is specified, each option choice can be
listed using the <TT>Choice</TT> directive:</P>

<pre class='example'>
*<a href='ref-ppdcfile.html#Choice'>Choice</a> True/Yes "&lt;&lt;/cupsCompression 1&gt;&gt;setpagedevice"
<a href='ref-ppdcfile.html#Choice'>Choice</a> False/No "&lt;&lt;/cupsCompression 0&gt;&gt;setpagedevice"
</pre>

<P>The directive is followed by the choice name and optionally
user text, and the PostScript commands that should be inserted
when printing a file to this printer. The option name must
conform to the PPD specification and cannot exceed 40 characters
in length. If you specify user text, it cannot exceed 80
characters in length.</P>

<P>The PostScript commands are also interpreted by any RIP
filters, so these commands typically must be present for all
option choices. Most commands take the form:</P>

<pre class='example'>
&lt;&lt;/name value&gt;&gt;setpagedevice
</pre>

<P>where <TT>name</TT> is the name of the PostScript page device
attribute and <TT>value</TT> is the numeric or string value for
that attribute.</P>


<h3><a name='DEFINE'>Defining Constants</a></h3>

<P>Sometimes you will want to define constants for your drivers
so that you can share values in different groups within the same
driver information file, or to share values between different
driver information files using the <TT>#include</TT> directive.
The <TT>#define</TT> directive is used to define constants for
use in your printer definitions:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#_define'>#define</a> NAME value
</pre>

<P>The <TT>NAME</TT> is any sequence of letters, numbers, and
the underscore. The <TT>value</TT> is a number or string; if the
value contains spaces you must put double quotes around it, for
example:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#_define'>#define</a> FOO "My String Value"
</pre>

<P>Constants can also be defined on the command-line using the <tt>-D</tt>
option:</P>

<pre class='command'>
ppdc -DNAME="value" filename.drv
</pre>

<P>Once defined, you use the notation <TT>$NAME</TT> to substitute the value of
the constant in the file, for example:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#_define'>#define</a> MANUFACTURER "Foo"
<a href='ref-ppdcfile.html#_define'>#define</a> FOO_600      0
<a href='ref-ppdcfile.html#_define'>#define</a> FOO_1200     1

{
  <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "$MANUFACTURER"
  <a href='ref-ppdcfile.html#ModelNumber'>ModelNumber</a> $FOO_600
  <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
  ...
}

{
  <a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "$MANUFACTURER"
  <a href='ref-ppdcfile.html#ModelNumber'>ModelNumber</a> $FOO_1200
  <a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2001"
  ...
}
</pre>

<P>Numeric constants can be bitwise OR'd together by placing the constants
inside parenthesis, for example:</P>

<pre class='example'>
<I>// ModelNumber capability bits</I>
<a href='ref-ppdcfile.html#_define'>#define</a> DUPLEX 1
<a href='ref-ppdcfile.html#_define'>#define</a> COLOR  2

...

{
  <I>// Define a model number specifying the capabilities of the printer...</I>
  <a href='ref-ppdcfile.html#ModelNumber'>ModelNumber</a> ($DUPLEX $COLOR)
  ...
}
</pre>


<h3><a name='CONDITIONAL'>Conditional Statements</a></h3>

<p>The PPD compiler supports conditional compilation using the <tt>#if</tt>,
<tt>#elif</tt>, <tt>#else</tt>, and <tt>#endif</tt> directives. The <tt>#if</tt>
and <tt>#elif</tt> directives are followed by a constant name or an expression.
For example, to include a group of options when "ADVANCED" is defined:</p>

<pre class='example'>
<a href='ref-ppdcfile.html#_if'>#if</a> ADVANCED
<a href='ref-ppdcfile.html#Group'>Group</a> "Advanced/Advanced Options"
  <a href='ref-ppdcfile.html#Option'>Option</a> "fooCyanAdjust/Cyan Adjustment"
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
  <a href='ref-ppdcfile.html#Option'>Option</a> "fooMagentaAdjust/Magenta Adjustment"
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
  <a href='ref-ppdcfile.html#Option'>Option</a> "fooYellowAdjust/Yellow Adjustment"
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
  <a href='ref-ppdcfile.html#Option'>Option</a> "fooBlackAdjust/Black Adjustment"
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus10/+10%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "plus5/+5%" ""
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> "none/No Adjustment" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus5/-5%" ""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "minus10/-10%" ""
<a href='ref-ppdcfile.html#_endif'>#endif</a>
</pre>


<h3><a name='CONSTRAINTS'>Defining Constraints</a></h3>

<P>Constraints are strings that are used to specify that one or more option
choices are incompatible, for example two-sided printing on transparency media.
Constraints are also used to prevent the use of uninstalled features such as the
duplexer unit, additional media trays, and so forth.</P>

<P>The <TT>UIConstraints</TT> directive is used to specify a constraint that is
placed in the PPD file. The directive is followed by a string using one of the
following formats:</P>

<pre class='example'>
<a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 *Option2"
<a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 Choice1 *Option2"
<a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 *Option2 Choice2"
<a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Option1 Choice1 *Option2 Choice2"
</pre>

<P>Each option name is preceded by the asterisk (<TT>*</TT>). If no choice is
given for an option, then all choices <I>except</I> <TT>False</TT> and
<TT>None</TT> will conflict with the other option and choice(s). Since the PPD
compiler automatically adds reciprocal constraints (option A conflicts with
option B, so therefore option B conflicts with option A), you need only specify
the constraint once.</P>

<p class='example'><a name="LISTING5">Listing 5: "examples/constraint.drv"</a></p>

<pre class='example'>

<I>// Include standard font and media definitions</I>
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
<a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard fonts...</I>
<a href='ref-ppdcfile.html#Font'>Font</a> *

<I>// Manufacturer, model name, and version</I>
<a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
<a href='ref-ppdcfile.html#ModelName'>ModelName</a> "FooJet 2000"
<a href='ref-ppdcfile.html#Version'>Version</a> 1.0

<I>// Each filter provided by the driver...</I>
<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4

<I>// Supported resolutions</I>
*<a href='ref-ppdcfile.html#Resolution'>Resolution</a> k 8 0 0 0 "600dpi/600 DPI"

<I>// Installable Option Group</I>
<a href='ref-ppdcfile.html#Group'>Group</a> "InstallableOptions/Options Installed"

  <I>// Duplexing unit option</I>
  <a href='ref-ppdcfile.html#Option'>Option</a> "OptionDuplexer/Duplexing Unit" Boolean AnySetup 10
    <a href='ref-ppdcfile.html#Choice'>Choice</a> True/Installed ""
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> "False/Not Installed" ""

<I>// General Option Group</I>
<a href='ref-ppdcfile.html#Group'>Group</a> General

  <I>// Duplexing option</I>
  <a href='ref-ppdcfile.html#Option'>Option</a> "Duplex/Two-Sided Printing" PickOne AnySetup 10
    *<a href='ref-ppdcfile.html#Choice'>Choice</a> "None/No" "&lt;&lt;/Duplex false&gt;&gt;setpagedevice""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexNoTumble/Long Edge Binding"
           "&lt;&lt;/Duplex true/Tumble false&gt;&gt;setpagedevice""
    <a href='ref-ppdcfile.html#Choice'>Choice</a> "DuplexTumble/Short Edge Binding"
           "&lt;&lt;/Duplex true/Tumble true&gt;&gt;setpagedevice""

<I>// Only allow duplexing if the duplexer is installed</I>
<a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False"

<I>// Specify the name of the PPD file we want to generate...</I>
<a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "foojet2k.ppd"
</pre>

<P><A HREF="#LISTING5">Listing 5</A> shows a variation of the first example with
an added <TT>Duplex</TT> option and installable option for the duplexer,
<TT>OptionDuplex</TT>. A constraint is added at the end to specify that any
choice of the <TT>Duplex</TT> option that is not <TT>None</TT> is incompatible
with the "Duplexer Installed" option set to "Not Installed"
(<TT>False</TT>):</P>

<pre class='example'>
<a href='ref-ppdcfile.html#UIConstraints'>UIConstraints</a> "*Duplex *OptionDuplexer False"
</pre>

<h4>Enhanced Constraints</h4>

<p>CUPS 1.4 supports constraints between 2 or more options using the
<TT>Attribute</TT> directive. <TT>cupsUIConstraints</TT> attributes define
the constraints, while <TT>cupsUIResolver</TT> attributes define option changes
to resolve constraints. For example, we can specify the previous duplex
constraint with a resolver that turns off duplexing with the following two
lines:</p>

<pre class='example'>
<a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIConstraints DuplexOff "*Duplex *OptionDuplexer False"
<a href='ref-ppdcfile.html#Attribute'>Attribute</a> cupsUIResolver DuplexOff "*Duplex None"
</pre>

<h2 class='title'><a name='LOCALIZATION'>Localization</a></h2>

<p>The PPD compiler provides localization of PPD files in different languages
through <i>message catalog</i> files in the GNU gettext or Apple .strings
formats. Each user text string and several key PPD attribute values such as
<tt>LanguageVersion</tt> and <tt>LanguageEncoding</tt> are looked up in the
corresponding message catalog and the translated text is substituted in the
generated PPD files. One message catalog file can be used by multiple driver
information files, and each file contains a single language translation.</p>

<h3><a name='PPDPO'>The ppdpo Utility</a></h3>

<p>While CUPS includes localizations of all standard media sizes and options in
several languages, your driver information files may provide their own media
sizes and options that need to be localized. CUPS provides a utility program to
aid in the localization of drivers called <a
href='man-ppdpo.html'><tt>ppdpo(1)</tt></a>. The <tt>ppdpo</tt> program creates
or updates a message catalog file based upon one or more driver information
files. New messages are added with the word "TRANSLATE" added to the front of
the translation string to make locating new strings for translation easier. The
program accepts the message catalog filename and one or more driver information
files.</p>

<p>For example, run the following command to create a new German message catalog
called <var>de.po</var> for all of the driver information files in the current
directory:</p>

<pre class='command'>
ppdpo -o de.po *.drv
</pre>

<p>If the file <var>de.po</var> already exists, <tt>ppdpo</tt> will update the
contents of the file with any new messages that need to be translated. To create
an Apple .strings file instead, specify the output filename with a .strings
extension, for example:</p>

<pre class='command'>
ppdpo -o de.strings *.drv
</pre>

<h3><a name='PPDC_CATALOG'>Using Message Catalogs with the PPD Compiler</a></h3>

<p>Once you have created a message catalog, use the <a
href='ref-ppdcfile.html#_po'><tt>#po</tt></a> directive to declare it in each
driver information file. For example, to declare the German message catalog for
a driver use:</p>

<pre class='example'>
<a href='ref-ppdcfile.html#_po'>#po</a> de "de.po"  // German
</pre>

<p>In fact, you can use the <tt>#po</tt> directive as many times as needed:</p>

<pre class='example'>
<a href='ref-ppdcfile.html#_po'>#po</a> de "de.po"  // German
<a href='ref-ppdcfile.html#_po'>#po</a> es "es.po"  // Spanish
<a href='ref-ppdcfile.html#_po'>#po</a> fr "fr.po"  // French
<a href='ref-ppdcfile.html#_po'>#po</a> it "it.po"  // Italian
<a href='ref-ppdcfile.html#_po'>#po</a> ja "ja.po"  // Japanese
</pre>

<p>The filename ("de.po", etc.) can be relative to the location of the driver
information file or an absolute path. Once defined, the PPD compiler will
automatically generate a globalized PPD for every language declared in your
driver information file. To generate a single-language PPD file, simply use the
<tt>-l</tt> option to list the corresponding locale, for example:</p>

<pre class='command'>
ppdc -l de -d ppd/de mydrivers.drv
</pre>

<p>to generate German PPD files.</p>