File: basics.html

package info (click to toggle)
cupsddk 1.2.3-5
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,488 kB
  • ctags: 1,125
  • sloc: ansic: 7,074; cpp: 5,423; makefile: 526; xml: 227; sh: 153
file content (874 lines) | stat: -rw-r--r-- 29,168 bytes parent folder | download
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
<HTML>
<BODY>

<DIV ALIGN='JUSTIFY'>

<H1 ALIGN="RIGHT"><A NAME="BASICS">2 - Getting Started with the CUPS DDK</A></H1>

<P>This chapter describes how to use the CUPS DDK and write
PPD compiler source files.</P>

<H2>The Basics</H2>

<P>The DDK provides the basis for creating printer drivers
that work within the architecture defined by the Common UNIX
Printing System. The DDK includes a PostScript Printer
Description ("PPD") file compiler, two general-purpose raster
printer drivers for printers that understand the Hewlett-Packard
Page Control Language ("HP-PCL") or Epson Standard Code for
Printers ("ESC/P") languages, and a raster printer driver
library that provides general-purpose dithering and color
management/separation functions.</P>

<P>All of the tools in the DDK are currently command-line only,
however future releases of the DDK will include an integrated
development environment which provides an intuitive GUI for
creating and testing printer drivers.</P>

<P>Aside from this manual, the DDK also includes several man pages that can be used as a quick reference when developing your printer drivers. These pages are also available via the CUPS on-line help system and the <TT>man(1)</TT> command. For example, type the following command to display the man page for the <TT>ppdc(1)</TT> command:</P>

<PRE>
    <KBD>man ppdc ENTER</KBD>
</PRE>

<H2>Using the PPD Compiler</H2>

<P>The PPD compiler, <TT>ppdc</TT>, 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>
    <KBD>ppdc mydrivers.drv ENTER</KBD>
</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>
    <KBD>ppdc -d myppds mydrivers.drv ENTER</KBD>
</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>
    <KBD>ppdc -d myppds/de -l de mydrivers.drv ENTER</KBD>
    <KBD>ppdc -d myppds/en -l en mydrivers.drv ENTER</KBD>
    <KBD>ppdc -d myppds/es -l es mydrivers.drv ENTER</KBD>
    <KBD>ppdc -d myppds/fr -l fr mydrivers.drv ENTER</KBD>
    <KBD>ppdc -d myppds/it -l it mydrivers.drv ENTER</KBD>
</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>
    <KBD>ppdc -d myppds -l de,en,es,fr,it mydrivers.drv ENTER</KBD>
</PRE>

<P>You'll learn more about localization in "<A
HREF="#LOCALIZATION">Chapter 5, Localizing Printer
Drivers</A>".</P>

<H2>Driver Information Files</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>

<!-- NEED 30 -->
<CENTER><TABLE WIDTH="80%" BORDER="1" CELLPADDING="10" CELLSPACING="0" BGCOLOR="#CCCCCC">
<CAPTION ALIGN="BOTTOM"><I><A NAME="LISTING2-1">Listing 2-1</A>, "examples/minimum.drv":</I></CAPTION>
<TR><TD>
<PRE>
<I>// Include standard font and media definitions</I>
<B>#include</B> &lt;font.defs&gt;
<B>#include</B> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard
// fonts...</I>
<B>Font</B> *

<I>// Manufacturer, model name, and version</I>
<B>Manufacturer</B> "Foo"
<B>ModelName</B> "FooJet 2000"
<B>Version</B> 1.0

<I>// Each filter provided by the driver...</I>
<B>Filter</B> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<B>MediaSize</B> Letter
<B>MediaSize</B> A4

<I>// Supported resolutions</I>
*<B>Resolution</B> k 8 0 0 0 "600dpi/600 DPI"

<I>// Specify the name of the PPD file we want to generate...</I>
<B>PCFileName</B> "foojet2k.ppd"
</PRE>
</TD></TR>
</TABLE></CENTER>

<H3>A Simple Example</H3>

<P>The example in <A HREF="#LISTING2-1">Listing 2-1</A> shows a
driver information file which defines the minimum required
attributes to provide a valid PPD file.</P>

<P>The first part of the file includes standard definition files
for fonts and media sizes:</P>

<PRE>
    #include &lt;font.defs&gt;
    #include &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 ESP
Ghostscript and the Apple PDF RIP. 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>

<!-- NEED 6 -->
<P>Other standard include files include:</P>

<UL>

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

	<LI><TT>&lt;pcl.h&gt;</TT> - Defines all of the HP-PCL
	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>
    Font *
</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>
    <I>//   name         encoding  version  charset  status</I>
    Font 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>
    Manufacturer "Foo"
    ModelName "FooJet 2000"
    Version 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>The list of filters comes after the information strings; for the
example in <A HREF="#LISTING2-1">Listing 2-1</A>, we have a single filter
that takes CUPS raster data:</P>

<PRE>
    Filter 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>

<!-- NEED 8 -->
<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>
    *MediaSize Letter
    MediaSize A4

    *Resolution 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, 2, 4, and 8 bits per
	color.  CUPS 1.2 and higher also support 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>

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

<PRE>
    PCFileName "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>.</P>

<H3>Grouping and Inheritance</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> directive produces a PPD
file with that name. <A HREF="#LISTING2-2">Listing 2-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>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>
    {
      // Supported resolutions
      *Resolution k 8 0 0 0 "600dpi/600 DPI"

      // Specify the model name and filename...
      ModelName "FooJet 2000"
      PCFileName "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>Defining Constants</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>
    #define NAME value
</PRE>

<!-- NEED 6in -->
<CENTER><TABLE WIDTH="80%" BORDER="1" CELLPADDING="10" CELLSPACING="0" BGCOLOR="#CCCCCC">
<CAPTION ALIGN="BOTTOM"><I><A NAME="LISTING2-2">Listing 2-2</A>, "examples/grouping.drv":</I></CAPTION>
<TR><TD>
<PRE>
<I>// Include standard font and media definitions</I>
<B>#include</B> &lt;font.defs&gt;
<B>#include</B> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard
<I>// fonts...</I>
<B>Font</B> *

<I>// Manufacturer and version</I>
<B>Manufacturer</B> "Foo"
<B>Version</B> 1.0

<I>// Each filter provided by the driver...</I>
<B>Filter</B> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<B>MediaSize</B> Letter
<B>MediaSize</B> A4

<B>{</B>
  <I>// Supported resolutions</I>
  *<B>Resolution</B> k 8 0 0 0 "600dpi/600 DPI"

  <I>// Specify the model name and filename...</I>
  <B>ModelName</B> "FooJet 2000"
  <B>PCFileName</B> "foojet2k.ppd"
<B>}</B>

<B>{</B>
  <I>// Supported resolutions</I>
  *<B>Resolution</B> k 8 0 0 0 "1200dpi/1200 DPI"

  <I>// Specify the model name and filename...</I>
  <B>ModelName</B> "FooJet 2001"
  <B>PCFileName</B> "foojt2k1.ppd"
<B>}</B>
</PRE>
</TD></TR>
</TABLE></CENTER>

<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>
    #define FOO "My String Value"
</PRE>

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

<PRE>
    <KBD>ppdc -DNAME="value" filename.drv ENTER</KBD>
</PRE>

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

<PRE>
    #define MANUFACTURER "Foo"
    #define FOO_600      0
    #define FOO_1200     1

    {
      Manufacturer "$MANUFACTURER"
      ModelNumber $FOO_600
      ModelName "FooJet 2000"
      ...
    }

    {
      Manufacturer "$MANUFACTURER"
      ModelNumber $FOO_1200
      ModelName "FooJet 2001"
      ...
    }
</PRE>

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

<PRE>
    // ModelNumber capability bits
    #define DUPLEX 1
    #define COLOR  2

    ...

    {
      // Define a model number specifying the capabilities of
      // the printer...
      ModelNumber ($DUPLEX $COLOR)
      ...
    }
</PRE>

<H3>Defining Color Support</H3>

<P>For printer drivers that support color printing, the
<TT>ColorDevice</TT> and <TT>ColorModel</TT> directives must be
used to tell the printing system that color output is desired
and in what formats. <A HREF="#LISTING2-3">Listing 2-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>
    ColorDevice true
</PRE>

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

<PRE>
    ColorModel Gray/Grayscale w chunky 0
    *ColorModel 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>

	<LI><TT>ciexyz</TT> - CIE XYZ</LI>

	<LI><TT>cielab</TT> - CIE Lab</LI>

</UL>

<P>Additional colorspaces are supported by the standard CUPS
image RIP filter and by ESP Ghostscript. The full list can be
found in <A HREF="#REF_COLOR">Appendix B, PPD Compiler Source
File Reference</A>.

<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>

<!-- NEED 8in -->
<CENTER><TABLE WIDTH="80%" BORDER="1" CELLPADDING="10" CELLSPACING="0" BGCOLOR="#CCCCCC">
<CAPTION ALIGN="BOTTOM"><I><A NAME="LISTING2-3">Listing 2-3</A>, "examples/color.drv":</I></CAPTION>
<TR><TD>
<PRE>
<I>// Include standard font and media definitions</I>
<B>#include</B> &lt;font.defs&gt;
<B>#include</B> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard
<I>// fonts...</I>
<B>Font</B> *

<I>// Manufacturer and version</I>
<B>Manufacturer</B> "Foo"
<B>Version</B> 1.0

<I>// Each filter provided by the driver...</I>
<B>Filter</B> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<B>MediaSize</B> Letter
<B>MediaSize</B> A4

<B>{</B>
  <I>// Supported resolutions</I>
  *<B>Resolution</B> k 8 0 0 0 "600dpi/600 DPI"

  <I>// Specify the model name and filename...</I>
  <B>ModelName</B> "FooJet 2000"
  <B>PCFileName</B> "foojet2k.ppd"
<B>}</B>

<B>{</B>
  <I>// Supports color printing</I>
  <B>ColorDevice</B> true

  <I>// Supported colorspaces</I>
  <B>ColorModel</B> Gray/Grayscale w chunky 0
  *<B>ColorModel</B> RGB/Color rgb chunky 0

  <I>// Supported resolutions</I>
  *<B>Resolution</B> - 8 0 0 0 "300dpi/300 DPI"
  <B>Resolution</B> - 8 0 0 0 "600dpi/600 DPI"

  <I>// Specify the model name and filename...</I>
  <B>ModelName</B> "FooJet Color"
  <B>PCFileName</B> "foojetco.ppd"
<B>}</B>
</PRE>
</TD></TR>
</TABLE></CENTER>

<H3>Defining Custom Options and Option Groups</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="#LISTING2-4">Listing 2-4</A> shows a variation of
the first example that provides two custom options in a group
named "Footasm".</P>

<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>
    Group "Footasm"
</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>
    Option "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>
    *Choice True/Yes "&lt;&lt;/cupsCompression 1&gt;&gt;setpagedevice"
    Choice False/No "&lt;&lt;/cupsCompression 0&gt;&gt;setpagedevice"
</PRE>

<!-- NEED 6in -->
<CENTER><TABLE WIDTH="80%" BORDER="1" CELLPADDING="10" CELLSPACING="0" BGCOLOR="#CCCCCC">
<CAPTION ALIGN="BOTTOM"><I><A NAME="LISTING2-4">Listing 2-4</A>, "examples/custom.drv":</I></CAPTION>
<TR><TD>
<PRE>
<I>// Include standard font and media definitions</I>
<B>#include</B> &lt;font.defs&gt;
<B>#include</B> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard
// fonts...</I>
<B>Font</B> *

<I>// Manufacturer, model name, and version</I>
<B>Manufacturer</B> "Foo"
<B>ModelName</B> "FooJet 2000"
<B>Version</B> 1.0

<I>// Each filter provided by the driver...</I>
<B>Filter</B> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<B>MediaSize</B> Letter
<B>MediaSize</B> A4

<I>// Supported resolutions</I>
*<B>Resolution</B> k 8 0 0 0 "600dpi/600 DPI"

<I>// Option Group</I>
<B>Group</B> "Footasm"

  <I>// Boolean option</I>
  <B>Option</B> "fooEnhance/Resolution Enhancement" Boolean AnySetup 10
    *<B>Choice</B> True/Yes "&lt;&lt;/cupsCompression 1&gt;&gt;setpagedevice"
    <B>Choice</B> False/No "&lt;&lt;/cupsCompression 0&gt;&gt;setpagedevice"

  <I>// Multiple choice option</I>
  <B>Option</B> "fooOutputType/Output Quality" PickOne AnySetup 10
    *<B>Choice</B> "Auto/Automatic Selection"
            "&lt;&lt;/OutputType(Auto)&gt;&gt;setpagedevice""
    <B>Choice</B> "Text/Optimize for Text"
            "&lt;&lt;/OutputType(Text)&gt;&gt;setpagedevice""
    <B>Choice</B> "Graph/Optimize for Graphics"
            "&lt;&lt;/OutputType(Graph)&gt;&gt;setpagedevice""
    <B>Choice</B> "Photo/Optimize for Photos"
            "&lt;&lt;/OutputType(Photo)&gt;&gt;setpagedevice""

<I>// Specify the name of the PPD file we want to generate...</I>
<B>PCFileName</B> "foojet2k.ppd"
</PRE>
</TD></TR>
</TABLE></CENTER>

<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>
    &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>Defining Constraints</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>
    UIConstraints "*Option1 *Option2"
    UIConstraints "*Option1 Choice1 *Option2"
    UIConstraints "*Option1 *Option2 Choice2"
    UIConstraints "*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><A HREF="#LISTING2-5">Listing 2-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>
    UIConstraints "*Duplex *OptionDuplexer False"
</PRE>

<!-- NEED 8in -->
<CENTER><TABLE WIDTH="80%" BORDER="1" CELLPADDING="10" CELLSPACING="0" BGCOLOR="#CCCCCC">
<CAPTION ALIGN="BOTTOM"><I><A NAME="LISTING2-5">Listing 2-5</A>, "examples/constraint.drv":</I></CAPTION>
<TR><TD>
<PRE>
<I>// Include standard font and media definitions</I>
<B>#include</B> &lt;font.defs&gt;
<B>#include</B> &lt;media.defs&gt;

<I>// List the fonts that are supported, in this case all standard
// fonts...</I>
<B>Font</B> *

<I>// Manufacturer, model name, and version</I>
<B>Manufacturer</B> "Foo"
<B>ModelName</B> "FooJet 2000"
<B>Version</B> 1.0

<I>// Each filter provided by the driver...</I>
<B>Filter</B> application/vnd.cups-raster 100 rastertofoo

<I>// Supported page sizes</I>
*<B>MediaSize</B> Letter
<B>MediaSize</B> A4

<I>// Supported resolutions</I>
*<B>Resolution</B> k 8 0 0 0 "600dpi/600 DPI"

<I>// Installable Option Group</I>
<B>Group</B> "InstallableOptions/Options Installed"

  <I>// Duplexing unit option</I>
  <B>Option</B> "OptionDuplexer/Duplexing Unit" Boolean AnySetup 10
    <B>Choice</B> True/Installed ""
    *<B>Choice</B> "False/Not Installed" ""

<I>// General Option Group</I>
<B>Group</B> General

  <I>// Duplexing option</I>
  <B>Option</B> "Duplex/Two-Sided Printing" PickOne AnySetup 10
    *<B>Choice</B> "None/No" "&lt;&lt;/Duplex false&gt;&gt;setpagedevice""
    <B>Choice</B> "DuplexNoTumble/Long Edge Binding"
           "&lt;&lt;/Duplex true/Tumble false&gt;&gt;setpagedevice""
    <B>Choice</B> "DuplexTumble/Short Edge Binding"
           "&lt;&lt;/Duplex true/Tumble true&gt;&gt;setpagedevice""

<I>// Only allow duplexing if the duplexer is installed</I>
<B>UIConstraints</B> "*Duplex *OptionDuplexer False"

<I>// Specify the name of the PPD file we want to generate...</I>
<B>PCFileName</B> "foojet2k.ppd"
</PRE>
</TD></TR>
</TABLE></CENTER>

<!-- NEED 4in -->
<H2>Importing Existing PPD Files</H2>

<P>The DDK includes a utility called <TT>ppdi(1)</TT> which
allows you to import existing PPD files into the driver
information file format. Once imported, you can modify,
localize, and regenerate the PPD files easily. The PPD files can
be for CUPS raster printer drivers or for PostScript printers -
the DDK makes no distinction when managing driver information or
PPD files.</P>

<P>Type the following command to import the PPD file
<VAR>mydevice.ppd</VAR> into the driver information file
<VAR>mydevice.drv</VAR>:</P>

<PRE>
    <KBD>ppdi -o mydevice.drv mydevice.ppd ENTER</KBD>
</PRE>

<P>If you have a whole directory of PPD files that you would
like to import, you can list multiple filenames or use shell
wildcards to import more than one PPD file on the
command-line:</P>

<PRE>
    <KBD>ppdi -o mydevice.drv mydevice1.ppd mydevice2.ppd ENTER</KBD>
    <KBD>ppdi -o mydevice.drv *.ppd ENTER</KBD>
</PRE>

<P>If the driver information file already exists, the new PPD
file entries are appended to the end of the file. Each PPD file
is placed in its own group of curly braces within the driver
information file.</P>

</DIV>

</BODY>
</HTML>