File: raster.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 (1547 lines) | stat: -rw-r--r-- 48,613 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
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
<html>
<body>

<div align='justify'>

<h1 align='right'><a name='RASTER_DRIVERS'>3 - Developing Raster
Printer Drivers</a></h1>

<p>This chapter describes how to develop PPD files for the included
DDK raster printer drivers.</p>

<h2>The DDK Drivers</h2>

<p>The DDK includes two general-purpose raster printer
drivers that support the HP-PCL and ESC/P languages. Driver
information files based upon these drivers can use a
driver-specific include file and the <tt>DriverType</tt>
directive.</p>

<p>Both drivers offer color management and dithering
capabilities which are described in detail in <a
href='#COLOR'>Chapter 6, Doing Raster Color Management</a>.</p>

<h2>The HP-PCL Driver</h2>

<p>The HP-PCL driver includes a printer command filter called
<tt>commandtopclx</tt> and a raster printer driver filter called
<tt>rastertopclx</tt>. The command filter supports head
cleaning, printing a self-test page, and ink cartridge
alignment.</p>

<!-- NEED 30 -->
<center><table border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i><a name='TABLE3-1'>Table 3-1, HP-PCL ModelNumber
constants</a></i></caption>
<tr bgcolor='#cccccc'>
	<th>Constant</th>
	<th>Description</th>
</tr>
<tr>
	<td valign='top'><tt>PCL_PAPER_SIZE</tt></td>
	<td align='justify' valign='top'>Use paper size command (<tt>ESC &amp; l # A</tt>)</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_INKJET</tt></td>
	<td align='justify' valign='top'>Use inkjet commands</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_RASTER_END_COLOR</tt></td>
	<td align='justify' valign='top'>Use new end-raster command (<tt>ESC * r C</tt>)</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_RASTER_CID</tt></td>
	<td align='justify' valign='top'>Use configure-image-data command (<tt>ESC * v # W</tt>)</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_RASTER_CRD</tt></td>
	<td align='justify' valign='top'>Use configure-raster-data command (<tt>ESC * g # W</tt>)</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_RASTER_SIMPLE</tt></td>
	<td align='justify' valign='top'>Use simple-raster-color command (<tt>ESC * r # U</tt>)</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_RASTER_RGB24</tt></td>
	<td align='justify' valign='top'>Use 24-bit RGB mode</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_PJL</tt></td>
	<td align='justify' valign='top'>Use PJL commands</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_PJL_PAPERWIDTH</tt></td>
	<td align='justify' valign='top'>Use PJL PAPERWIDTH/LENGTH commands</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_PJL_HPGL2</tt></td>
	<td align='justify' valign='top'>Use PJL ENTER HPGL2 command</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_PJL_PCL3GUI</tt></td>
	<td align='justify' valign='top'>Use PJL ENTER PCL3GUI command</td>
</tr>
<tr>
	<td valign='top'><tt>PCL_PJL_RESOLUTION</tt></td>
	<td align='justify' valign='top'>Use PJL SET RESOLUTION command</td>
</tr>
</table></center>

<p>The raster printer driver filter accepts grayscale, RGB, and
CMYK raster data for printing to laser and inkjet devices. It
supports PJL commands for device-specific features and uses PCL
3/4/5 raster graphics commands for all laser and some older
inkjet printers or the various PCL3GUI and HP-RTL variants that
are used by most of the inkjet printers sold by HP. The driver
does <i>not</i> support native text rendering due to the
limitations of font support in most PCL implementations.</p>

<p>The HP-PCL driver also provides an include file,
<tt>&lt;pcl.h&gt;</tt>. Driver information files that use the
HP-PCL driver begin with the following:</p>

<pre>
    #include &lt;font.defs&gt;
    #include &lt;media.defs&gt;
    #include &lt;raster.defs&gt;
    #include &lt;pcl.h&gt;

    DriverType pcl
</pre>

<!-- NEED 9 -->
<h3>ModelNumber Constants</h3>

<p><a href='#TABLE3-1'>Table 3-1</a> shows the constants that are
defined in the <tt>&lt;pcl.h&gt;</tt> include file. These
constants are used with the  <tt>ModelNumber</tt> directive to
control the behavior of the driver. For example, a typical PCL
laser printer would use the following <tt>ModelNumber</tt>
specification:</p>

<pre>
    ModelNumber ($PCL_PAPER_SIZE $PCL_PJL $PCL_PJL_RESOLUTION)
</pre>

<p>The parenthesis around the PCL constants tell the PPD
compiler to compute the bitwise OR of each of the values. The
HP-PCL driver will then use this information to tailor the
output of the driver for the printer, in this case to use
Printer Job Language ("PJL") commands to setup the job,
including the PJL resolution command, and to use the PCL 3 paper
size command. <a href='#TABLE3-2'>Table 3-2</a> shows the constants
to use for several common types of HP printers.</p>

<h3>Writing a Basic HP LaserJet Driver</h3>

<p>Now that we have covered the HP-PCL driver definitions, we
will create a driver for the HP LaserJet 2100, 2200, and 2300
series printers which supports all of the features that are
available via PCL 5. While these printers also support
PostScript, the interpreters have several known problems with
TrueType fonts which can only be bypassed by using the PCL 5
printing path.</p>

<p>All three models support printing at 300 and 600 DPI through
PCL 5 graphics; the 1200 DPI resolution is only available
through PostScript and PCL 6. Each printer has an optional
high-capacity paper tray and the 2200 and 2300 series printers
also offer an optional duplexing unit. <a
href='#LISTING3-1'>Listing 3-1</a> shows the driver information
file for a basic HP LaserJet driver which supports the three
models.</p>

<p>The file starts with the usual <tt>#include</tt> directives
and then sets the driver type and model number so that we use
the HP-PCL driver with the output tailored to a HP LaserJet
printer:</p>

<pre>
    // Specify that this driver uses the HP-PCL driver...
    DriverType pcl

    // Specify the driver options via the model number...
    ModelNumber ($PCL_PAPER_SIZE $PCL_PJL $PCL_PJL_RESOLUTION)
</pre>

<!-- NEED 50 -->
<center><table border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i><a name='TABLE3-2'>Table 3-2, ModelNumber values for
common HP printers</a></i></caption>
<tr bgcolor='#cccccc'>
	<th>Printer Model</th>
	<th>ModelNumber Value</th>
</tr>
<tr>
	<td valign='top'>HP Color LaserJet Series</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_RASTER_END_COLOR $PCL_RASTER_CID
	$PCL_RASTER_SIMPLE $PCL_RASTER_RGB24
	$PCL_PJL $PCL_PJL_RESOLUTION)</tt></td>
</tr>
<tr>
	<td valign='top'>HP DesignJet, Desktop</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_RASTER_END_COLOR $PCL_RASTER_CRD
	$PCL_PJL $PCL_PJL_PCL3GUI)</tt></td>
</tr>
<tr>
	<td valign='top'>HP DesignJet, High-End</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_RASTER_END_COLOR $PCL_RASTER_CID
	$PCL_RASTER_SIMPLE $PCL_RASTER_RGB24 $PCL_PJL $PCL_PJL_PAPERWIDTH
	$PCL_PJL_HPGL2 $PCL_PJL_RESOLUTION)</tt></td>
</tr>
<tr>
	<td valign='top'>HP DesignJet, Mid-Range</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_RASTER_END_COLOR $PCL_RASTER_CRD
	$PCL_RASTER_SIMPLE $PCL_RASTER_RGB24 $PCL_PJL $PCL_PJL_PAPERWIDTH
	$PCL_PJL_PCL3GUI $PCL_PJL_RESOLUTION)</tt></td>
</tr>
<tr>
	<td valign='top'>HP DeskJet Series</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_RASTER_END_COLOR $PCL_RASTER_CRD
	$PCL_PJL $PCL_PJL_PCL3GUI)</tt></td>
</tr>
<tr>
	<td valign='top'>HP LaserJet Series</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_PJL $PCL_PJL_RESOLUTION)</tt></td>
</tr>
<tr>
	<td valign='top'>HP OfficeJet Series</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_RASTER_END_COLOR $PCL_RASTER_CRD
	$PCL_PJL $PCL_PJL_PCL3GUI)</tt></td>
</tr>
<tr>
	<td valign='top'>HP Photosmart Series</td>
	<td valign='top'><tt>($PCL_PAPER_SIZE $PCL_RASTER_END_COLOR $PCL_RASTER_CRD
	$PCL_PJL $PCL_PJL_PCL3GUI)</tt></td>
</tr>
</TABLE></CENTER>

<p>Then we list all of the media sizes that are supported by the
printers along with the margins that should be used:</p>

<pre>
    HWMargins 18 12 18 12
    *MediaSize Letter
    MediaSize Legal
    MediaSize Executive
    MediaSize Monarch
    MediaSize Statement
    MediaSize FanFoldGermanLegal

    HWMargins 18 12.72 18 12.72
    MediaSize Env10

    HWMargins 9.72 12 9.72 12
    MediaSize A4
    MediaSize A5
    MediaSize B5
    MediaSize EnvC5
    MediaSize EnvDL
    MediaSize EnvISOB5
    MediaSize Postcard
    MediaSize DoublePostcard
</pre>

<!-- NEED 2in -->
<p>Next we use the <tt>ColorModel</tt> directive to specify that
our driver only prints grayscale output using the black
colorspace and PCL mode 3 raster compression:</p>

<pre>
    ColorModel Gray k chunky 3
</pre>

<p>These printers support printing at 300 and 600 DPI through
HP-PCL 5, so we list those resolutions using the
<tt>Resolution</tt> directive. We use 1 bit per color for 300
DPI to provide fast printing and 8 bits per color for 600 DPI to
provide the highest quality:</p>

<pre>
    Resolution - 1 0 0 0 "300dpi/300 DPI"
    *Resolution - 8 0 0 0 "600dpi/600 DPI"
</pre>

<p>All of the models provide two standard paper trays and one
optional tray. The first tray is used as both the multi-purpose
and manual feed tray and gets listed twice. We also provide an
"auto" tray which tells the printer to grab media from the first
available location:</p>

<pre>
    *InputSlot 7 "Auto/Automatic Selection"
    InputSlot 2 "Manual/Tray 1 - Manual Feed"
    InputSlot 4 "Upper/Tray 1"
    InputSlot 1 "Lower/Tray 2"
    InputSlot 5 "LargeCapacity/Tray 3"
</pre>

<!-- NEW PAGE -->
<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i><a name='LISTING3-1'>Listing 3-1,
"examples/laserjet-basic.drv"</a></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>// Include HP-PCL driver definitions</i>
<b>#include</b> &lt;pcl.h&gt;

<i>// Specify that this driver uses the HP-PCL driver...</i>
<b>DriverType</b> pcl

<i>// Specify the driver options via the model number...</i>
<b>ModelNumber</b> ($PCL_PAPER_SIZE $PCL_PJL $PCL_PJL_RESOLUTION)

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

<i>// Manufacturer and driver version</i>
<b>Manufacturer</b> "HP"
<b>Version</b> 1.0

<i>// Supported page sizes and their margins</i>
<b>HWMargins</b> 18 12 18 12
*<b>MediaSize</b> Letter
<b>MediaSize</b> Legal
<b>MediaSize</b> Executive
<b>MediaSize</b> Monarch
<b>MediaSize</b> Statement
<b>MediaSize</b> FanFoldGermanLegal

<b>HWMargins</b> 18 12.72 18 12.72
<b>MediaSize</b> Env10

<b>HWMargins</b> 9.72 12 9.72 12
<b>MediaSize</b> A4
<b>MediaSize</b> A5
<b>MediaSize</b> B5
<b>MediaSize</b> EnvC5
<b>MediaSize</b> EnvDL
<b>MediaSize</b> EnvISOB5
<b>MediaSize</b> Postcard
<b>MediaSize</b> DoublePostcard

<i>// Only black-and-white output with mode 3 compression...</i>
<b>ColorModel</b> Gray k chunky 3

<i>// Supported input slots</i>
*<b>InputSlot</b> 7 "Auto/Automatic Selection"
<b>InputSlot</b> 2 "Manual/Tray 1 - Manual Feed"
<b>InputSlot</b> 4 "Upper/Tray 1"
<b>InputSlot</b> 1 "Lower/Tray 2"
<b>InputSlot</b> 5 "LargeCapacity/Tray 3"
</pre></td></tr>
</table></center>

<!-- NEW PAGE -->
<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i>Listing 3-1,
"examples/laserjet-basic.drv", continued...</i></caption>
<tr><td><pre>
<i>// Supported resolutions</i>
<b>Resolution</b> - 1 0 0 0 "300dpi/300 DPI"
*<b>Resolution</b> - 8 0 0 0 "600dpi/600 DPI"

<i>// Tray 3 is an option...</i>
<b>Installable</b> "OptionLargeCapacity/Tray 3 Installed"
<b>UIConstraints</b> "*OptionLargeCapacity False
               *InputSlot LargeCapacity"

{
  <i>// HP LaserJet 2100 Series</i>
  <b>Throughput</b> 10
  <b>ModelName</b> "LaserJet 2100 Series"
  <b>PCFileName</b> "hpljt211.ppd"
}

{
  <i>// LaserJet 2200 and 2300 series have duplexer option...</i>
  <b>Duplex</b> normal
  <b>Installable</b> "OptionDuplex/Duplexer Installed"
  <b>UIConstraints</b> "*OptionDuplex False *Duplex"

  {
    <i>// HP LaserJet 2200 Series</i>
    <b>Throughput</b> 19
    <b>ModelName</b> "LaserJet 2200 Series"
    <b>PCFileName</b> "hpljt221.ppd"
  }

  {
    <i>// HP LaserJet 2300 Series</i>
    <b>Throughput</b> 25
    <b>ModelName</b> "LaserJet 2300 Series"
    <b>PCFileName</b> "hpljt231.ppd"
  }
}
</pre></td></tr>
</table></center>

<p>The numbers we used for the input slots are the PCL values
associated with each tray; consult the HP-PCL Language Reference
Manual for a complete list of possible values on all
printers.</p>

<p>Since the third tray is an optional accessory, we list an
installable option along with a constraint so that users may
only select the third tray if it has been installed:</p>

<pre>
    Installable "OptionLargeCapacity/Tray 3 Installed"
    UIConstraints "*OptionLargeCapacity False *InputSlot LargeCapacity"
</pre>

<p>By convention, installable options usually begin with the
prefix <tt>Option</tt>. Some vendors number the options, e.g.
<tt>Option1</tt>, <tt>Option2</tt>, etc., however we have opted
to use a more readable name, <tt>OptionLargeCapacity</tt>. Using a
textual name also allows you to add additional installable
options without renumbering existing options, and makes it
easier to validate constraints.</p>

<p>The HP LaserJet 2200 and 2300 series printers also have an
optional duplexer, which is listed using the <tt>Duplex</tt>
directive along with another installable option and
constraint:</p>

<pre>
    Duplex normal
    Installable "OptionDuplex/Duplexer Installed"
    UIConstraints "*OptionDuplex False *Duplex"
</pre>

<p>Again, we are using the more readable installable option name
<tt>OptionDuplex</tt> instead of <tt>Option2</tt>.</p>

<p>We finish things up by using grouping to isolate the three
printer models and provide unique values for the
<tt>Throughput</tt>, <tt>ModelName</tt>, and <tt>PCFileName</tt>
directives. Notice how we are able to group the duplex option
and then share the definition with the 2200 and 2300
drivers:</p>

<pre>
    {
      // HP LaserJet 2100 Series
      Throughput 10
      ModelName "LaserJet 2100 Series"
      PCFileName "hpljt211.ppd"
    }

    {
      // LaserJet 2200 and 2300 series have duplexer option...
      Duplex normal
      Installable "OptionDuplex/Duplexer Installed"
      UIConstraints "*OptionDuplex False *Duplex"

      {
	// HP LaserJet 2200 Series
	Throughput 19
	ModelName "LaserJet 2200 Series"
	PCFileName "hpljt221.ppd"
      }

      {
	// HP LaserJet 2300 Series
	Throughput 25
	ModelName "LaserJet 2300 Series"
	PCFileName "hpljt231.ppd"
      }
    }
</pre>

<p>To test the new drivers, start by running the <tt>ppdc</tt>
program to create the PPD files:</p>

<pre>
    <kbd>ppdc laserjet-basic.drv ENTER</kbd>
</pre>

<p>Then use the <tt>lpadmin(8)</tt> command to add the printer
with the correct device URI. The following example adds a HP
LaserJet 2100 which is connected via a JetDirect interface:</p>

<pre>
    <kbd>lpadmin -p lj2100 -E -v socket://lj2100 -i ppd/hpljt211.ppd ENTER</kbd>
</pre>

<p>Finally, print a test page to see it work:</p>

<pre>
    <kbd>lp -d lj2100 /usr/share/cups/data/testprint.ps ENTER</kbd>
</pre>

<h3>PJL Attributes</h3>

<p>The HP-PCL driver also supports extensive Printer Job
Language (PJL) commands through a combination of PPD attributes
and options. <a href='#TABLE3-3'>Table 3-3</a> lists the PJL
attributes that are supported along with the PPD options they
map to. PJL attributes are specified using the
<tt>Attribute</tt> directive using the <tt>cupsPJL</tt> keyword.
For example, the following attribute provides the PJL commands
to enable or disable the resolution enhancement features of the
printer:</p>

<pre>
    Attribute cupsPJL cupsRET
              "@PJL SET SMOOTHING=%?False:OFF;%?True:ON;%n"
</pre>

<p>The directive, <tt>Attribute</tt>, is followed by the
attribute keyword, <tt>cupsPJL</tt>, the attribute name,
<tt>cupsRET</tt>, and the attribute value, in this case a PJL
command string. The command string consists of PJL command text
and special substitution fields starting with the percent
(<tt>%</tt>) character.</p>

<p>In the example above, the <tt>%?</tt> substitution conditionally
inserts some text if the string matches the option value, typically the
name of the choice. In this case, we have two conditional substitutions.
The first inserts the text <tt>OFF</tt> if the <tt>cupsRET</tt> option
is <tt>False</tt>, and the second inserts the text <tt>ON</tt> if the
option is <tt>True</tt>. The syntax is as follows:</p>

<pre>
    %?<i>look for</i>:<i>insert</i>;
</pre>

<p>Multiple conditional substitutions can be listed up to about
230 characters - the PPD file format imposed a 255 character
line length limit, and attribute values cannot span multiple
lines.</p>

<!-- NEED 15 -->
<p>Aside from conditional substitutions, the HP-PCL driver
supports the following additional substitutions. Unknown
substitutions are inserted verbatim:</p>

<ul>

	<li><tt>%%</tt> - inserts the percent character
	(<tt>%</tt>).</li>

	<li><tt>%b</tt> - inserts the job-billing value for this
	job.</li>

	<li><tt>%h</tt> - inserts the job-originating-hostname
	value for this job.</li>

	<li><tt>%j</tt> - inserts the job-id value for this
	job.</li>

	<li><tt>%n</tt> - inserts the carriage return (ASCII CR
	or <tt>0D</tt> hex) and linefeed (ASCII LF or
	<tt>0A</tt> hex) characters.</li>

	<li><tt>%q</tt> - inserts the double quote character
	(<tt>"</tt>).</li>

	<li><tt>%s</tt> - inserts the current option value or
	choice.</li>

	<li><tt>%t</tt> - inserts the name/title of this
	job.</li>

	<li><tt>%u</tt> - inserts the job-originating-username
	value for this job.</li>

</ul>

<h3>Adding PJL Options to the Basic LaserJet Driver</h3>

<p>All three HP LaserJet models support additional options via
PJL commands. <a href='#LISTING3-2'>Listing 3-2</a> shows a
modified version of the driver which adds support the resolution
enhancement and toner saving features of the printers.</p>

<p>The new resolution enhancement option consists of a PPD
attribute containing the <tt>cupsRET</tt> command followed by
the <tt>cupsRET</tt> option. Since this option applies to the
entire job, the option is placed in the <tt>DocumentSetup</tt>
section:</p>

<pre>
    Attribute cupsPJL cupsRET
              "@PJL SET SMOOTHING=%?False:OFF;%?True:ON;%n"

    Option "cupsRET/Smoothing" Boolean DocumentSetup 10
      Choice "False/Off" ""
      *Choice "True/On" ""
</pre>

<p>The toner saving option is added the same way using the
<tt>cupsTonerSave</tt> attribute and option:</p>

<pre>
    Attribute cupsPJL cupsTonerSave
              "@PJL SET ECONOMODE=%?False:OFF;%?True:ON;%n"

    Option "cupsTonerSave/Save Toner" Boolean DocumentSetup 10
      *Choice "False/No" ""
      Choice "True/Yes" ""
</pre>

<p>Since we didn't specify a group for these options, they will
be put in the <tt>General</tt> option group.</p>

<!-- NEW PAGE -->
<center><table border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i><a name='TABLE3-3'>Table 3-3, PJL
attributes and options</a></i></caption>
<tr bgcolor='#cccccc'>
	<th width="25%">Attribute</th>
	<th width="25%">Option</th>
	<th width="50%">Description</th>
</tr>
<tr>
	<td valign='top'><tt>COLORSPACE. ColorModel</tt></td>
	<td valign='top'>Varies</td>
	<td align='justify' valign='top'>Specifies the colorspace to set
	at the beginning of the job.</td>
</tr>
<tr>
	<td valign='top'><tt>cupsBooklet</tt></td>
	<td valign='top'><tt>cupsBooklet</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the booklet printing mode.</td>
</tr>
<tr>
	<td valign='top'><tt>cupsPunch</tt></td>
	<td valign='top'><tt>cupsPunch</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the punch mode.</td>
</tr>
<tr>
	<td valign='top'><tt>cupsRET</tt></td>
	<td valign='top'><tt>cupsRET</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	set the resolution enhancement mode.</td>
</tr>
<tr>
	<td valign='top'><tt>cupsStaple</tt></td>
	<td valign='top'><tt>cupsStaple</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the stapler mode.</td>
</tr>
<tr>
	<td valign='top'><tt>cupsTonerSave</tt></td>
	<td valign='top'><tt>cupsTonerSave</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	set the toner saving mode.</td>
</tr>
<tr>
	<td valign='top'><tt>Duplex</tt></td>
	<td valign='top'><tt>Duplex</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the duplex mode.</td>
</tr>
<tr>
	<td valign='top'><tt>EndJob</tt></td>
	<td valign='top'>N/A</td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send at the end of a job.</td>
</tr>
<tr>
	<td valign='top'><tt>Jog</tt></td>
	<td valign='top'>Varies</td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the output jogging.</td>
</tr>
<tr>
	<td valign='top'><tt>MediaClass</tt></td>
	<td valign='top'>Varies</td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the media class.</td>
</tr>
<tr>
	<td valign='top'><tt>MediaColor</tt></td>
	<td valign='top'>Varies</td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the media color.</td>
</tr>
<tr>
	<td valign='top'><tt>MediaType</tt></td>
	<td valign='top'><tt>MediaType</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the media type.</td>
</tr>
<tr>
	<td valign='top'><tt>OutputType</tt></td>
	<td valign='top'>Varies</td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the output type.</td>
</tr>
<tr>
	<td valign='top'><tt>RENDERINTENT. ColorModel</tt></td>
	<td valign='top'>Varies</td>
	<td align='justify' valign='top'>Specifies the rendering intent
	to set at the beginning of the job.</td>
</tr>
<tr>
	<td valign='top'><tt>RENDERMODE. ColorModel</tt></td>
	<td valign='top'>Varies</td>
	<td align='justify' valign='top'>Specifies the render mode to set
	at the beginning of the job.</td>
</tr>
</table></center>

<!-- NEW PAGE -->
<center><table border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i>Table 3-3, PJL
attributes and options, continued...</i></caption>
<tr bgcolor='#cccccc'>
	<th width="25%">Attribute</th>
	<th width="25%">Option</th>
	<th width="50%">Description</th>
</tr>
<tr>
	<td valign='top'><tt>StartJob</tt></td>
	<td valign='top'>N/A</td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send at the beginning of a job.</td>
</tr>
<tr>
	<td valign='top'><tt>Tumble</tt></td>
	<td valign='top'><tt>Duplex</tt></td>
	<td align='justify' valign='top'>Specifies the PJL commands to
	send for setting the duplex tumble mode.</td>
</tr>
</table></center>

<!-- NEED 2in -->
<p>To test the new drivers, start by running the <tt>ppdc</tt>
program to create the PPD files:</p>

<pre>
    <kbd>ppdc laserjet-pjl.drv ENTER</kbd>
</pre>

<p>Then use the <tt>lpadmin(8)</tt> command to add the printer
with the correct device URI. The following example adds a HP
LaserJet 2100 which is connected via a JetDirect interface:</p>

<pre>
    <kbd>lpadmin -p lj2100 -E -v socket://lj2100 -i ppd/hpljt212.ppd ENTER</kbd>
</pre>

<p>Finally, print a test page to see it work:</p>

<pre>
    <kbd>lp -d lj2100 -o cupsTonerSave=True \
       /usr/share/cups/data/testprint.ps ENTER</kbd>
</pre>

<!-- NEW PAGE -->
<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i><a name='LISTING3-2'>Listing 3-2,
"examples/laserjet-pjl.drv"</a></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>// Include HP-PCL driver definitions</i>
<b>#include</b> &lt;pcl.h&gt;

<i>// Specify that this driver uses the HP-PCL driver...</i>
<b>DriverType</b> pcl

<i>// Specify the driver options via the model number...</i>
<b>ModelNumber</b> ($PCL_PAPER_SIZE $PCL_PJL $PCL_PJL_RESOLUTION)

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

<i>// Manufacturer and driver version</i>
<b>Manufacturer</b> "HP"
<b>Version</b> 2.0

<i>// Supported page sizes and their margins</i>
<b>HWMargins</b> 18 12 18 12
*<b>MediaSize</b> Letter
<b>MediaSize</b> Legal
<b>MediaSize</b> Executive
<b>MediaSize</b> Monarch
<b>MediaSize</b> Statement
<b>MediaSize</b> FanFoldGermanLegal

<b>HWMargins</b> 18 12.72 18 12.72
<b>MediaSize</b> Env10

<b>HWMargins</b> 9.72 12 9.72 12
<b>MediaSize</b> A4
<b>MediaSize</b> A5
<b>MediaSize</b> B5
<b>MediaSize</b> EnvC5
<b>MediaSize</b> EnvDL
<b>MediaSize</b> EnvISOB5
<b>MediaSize</b> Postcard
<b>MediaSize</b> DoublePostcard

<i>// Only black-and-white output with mode 3 compression...</i>
<b>ColorModel</b> Gray k chunky 3

<i>// Supported input slots</i>
*<b>InputSlot</b> 7 "Auto/Automatic Selection"
<b>InputSlot</b> 2 "Manual/Tray 1 - Manual Feed"
<b>InputSlot</b> 4 "Upper/Tray 1"
<b>InputSlot</b> 1 "Lower/Tray 2"
<b>InputSlot</b> 5 "LargeCapacity/Tray 3"
</pre></td></tr>
</table></center>

<!-- NEW PAGE -->
<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i>Listing 3-2,
"examples/laserjet-pjl.drv", continued...</i></caption>
<tr><td><pre>
<i>// Supported resolutions</i>
<b>Resolution</b> - 1 0 0 0 "300dpi/300 DPI"
*<b>Resolution</b> - 8 0 0 0 "600dpi/600 DPI"

<i>// Tray 3 is an option...</i>
<b>Installable</b> "OptionLargeCapacity/Tray 3 Installed"
<b>UIConstraints</b> "*OptionLargeCapacity False
               *InputSlot LargeCapacity"

<i>// PJL options</i>
<b>Attribute</b> cupsPJL cupsRET
          "@PJL SET SMOOTHING=%?False:OFF;%?True:ON;%n"

<b>Option</b> "cupsRET/Smoothing" Boolean DocumentSetup 10
  <b>Choice</b> "False/Off" ""
  *<b>Choice</b> "True/On" ""

<b>Attribute</b> cupsPJL cupsTonerSave
          "@PJL SET ECONOMODE=%?False:OFF;%?True:ON;%n"

<b>Option</b> "cupsTonerSave/Save Toner" Boolean DocumentSetup 10
  *<b>Choice</b> "False/No" ""
  <b>Choice</b> "True/Yes" ""

{
  <i>// HP LaserJet 2100 Series</i>
  <b>Throughput</b> 10
  <b>ModelName</b> "LaserJet 2100 Series PJL"
  <b>PCFileName</b> "hpljt212.ppd"
}

{
  <i>// LaserJet 2200 and 2300 series have duplexer option...</i>
  <b>Duplex</b> normal
  <b>Installable</b> "OptionDuplex/Duplexer Installed"
  <b>UIConstraints</b> "*OptionDuplex False *Duplex"

  {
    <i>// HP LaserJet 2200 Series</i>
    <b>Throughput</b> 19
    <b>ModelName</b> "LaserJet 2200 Series PJL"
    <b>PCFileName</b> "hpljt222.ppd"
  }

  {
    <i>// HP LaserJet 2300 Series</i>
    <b>Throughput</b> 25
    <b>ModelName</b> "LaserJet 2300 Series PJL"
    <b>PCFileName</b> "hpljt232.ppd"
  }
}
</pre></td></tr>
</table></center>


<!-- NEW PAGE -->
<h2>The ESC/P Driver</h2>

<p>The ESC/P driver includes a printer command filter called
<tt>commandtoescpx</tt> and a raster printer driver filter called
<tt>rastertoescpx</tt>. The command filter supports head
cleaning, printing a self-test page, and ink cartridge
alignment.</p>

<p>The raster printer driver filter accepts grayscale, RGB, and
CMYK raster data for printing to inkjet devices. It supports EJL
commands for device-specific features and uses the appropriate
ESC/P2 raster graphics commands for all inkjet printers sold by
Epson. The driver does <i>not</i> support native text rendering
due to the limitations of text support in most ESC/P
implementations.</p>

<p>The ESC/P driver also provides an include file,
<tt>&lt;escp.h&gt;</tt>. Driver information files that use the
ESC/P driver begin with the following:</p>

<pre>
    #include &lt;font.defs&gt;
    #include &lt;media.defs&gt;
    #include &lt;raster.defs&gt;
    #include &lt;escp.h&gt;

    DriverType escp
</pre>

<h3>ModelNumber Constants</h3>

<p><a href='#TABLE3-4'>Table 3-4</a> shows the constants that are
defined in the <tt>&lt;escp.h&gt;</tt> include file. These
constants are used with the  <tt>ModelNumber</tt> directive to
control the behavior of the driver. For example, a typical Epson
Stylus Color printer would use the following <tt>ModelNumber</tt>
specification:</p>

<pre>
    ModelNumber ($ESCP_MICROWEAVE $ESCP_USB $ESCP_REMOTE)
</pre>

<p>The parenthesis around the ESCP constants tell the PPD
compiler to compute the bitwise OR of each of the values. The
ESC/P driver will then use this information to tailor the output
of the driver for the printer, in this case to use the printer's
built-in microweaving (a way of printing using multiple passes),
send the USB packet mode escape sequence, and to use remote mode
commands. <a href='#TABLE3-5'>Table 3-5</a> shows the constants
to use for several common types of Epson printers.</p>

<h3>Writing a Basic Epson Stylus Photo R300 Driver</h3>

<p>Now that we have covered the ESC/P driver definitions, we
will create a driver for the popular Epson Stylus Photo R300
series printers. These printers offer 6-color, full-bleed
printing at up to 5760x1440 DPI and can print on recordable CDs
and DVDs as well as standard printer media.</p>

<!-- NEED 25 -->
<center><table border='1' cellpadding='5' cellspacing='0' width='80%'>
<caption align='bottom'><a name='TABLE3-4'><i>Table 3-4, ESC/P ModelNumber
constants</i></a></caption>
<tr bgcolor='#cccccc'>
	<th>Constant</th>
	<th>Description</th>
</tr>
<tr>
	<td valign='top'><tt>ESCP_MICROWEAVE</tt></td>
	<td align='justify' valign='top'>Use microweave command?</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_STAGGER</tt></td>
	<td align='justify' valign='top'>Are color jets staggered?</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_ESCK</tt></td>
	<td align='justify' valign='top'>Use print mode command?</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_EXT_UNITS</tt></td>
	<td align='justify' valign='top'>Use extended unit commands?</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_EXT_MARGINS</tt></td>
	<td align='justify' valign='top'>Use extended margin command?</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_USB</tt></td>
	<td align='justify' valign='top'>Send USB packet mode escape</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_PAGE_SIZE</tt></td>
	<td align='justify' valign='top'>Use page size command</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_RASTER_ESCI</tt></td>
	<td align='justify' valign='top'>Use <tt>ESC i</tt> graphics command</td>
</tr>
<tr>
	<td valign='top'><tt>ESCP_REMOTE</tt></td>
	<td align='justify' valign='top'>Use remote mode commands</td>
</tr>
</table></center>

<center><table border='1' cellpadding='5' cellspacing='0' width='80%'>
<caption align='bottom'><i><a name='TABLE3-5'>Table 3-5, ModelNumber values for
common Epson printers</a></i></caption>
<tr bgcolor='#cccccc'>
	<th>Printer Model</th>
	<th>ModelNumber Value</th>
</tr>
<tr>
	<td valign='top'>Epson Stylus Color</td>
	<td valign='top'><tt>($ESCP_MICROWEAVE $ESCP_USB $ESCP_REMOTE)</tt></td>
</tr>
<tr>
	<td valign='top'>Epson Stylus C-Series</td>
	<td valign='top'><tt>($ESCP_STAGGER $ESCP_USB $ESCP_REMOTE)</tt></td>
</tr>
<tr>
	<td valign='top'>Epson Stylus Photo</td>
	<td valign='top'><tt>($ESCP_MICROWEAVE $ESCP_ESCK $ESCP_USB
	$ESCP_REMOTE)</tt></td>
</tr>
<tr>
	<td valign='top'>Epson Stylus Pro</td>
	<td valign='top'><tt>($ESCP_MICROWEAVE $ESCP_EXT_UNITS
	$ESCP_EXT_MARGINS $ESCP_PAGE_SIZE $ESCP_REMOTE)</tt></td>
</tr>
</table></center>

<p>Our first cut of the driver will support printing at up to
1440 DPI. We'll add the full-bleed printing support in the next
section. <a href='#LISTING3-3'>Listing 3-3</a> shows the driver
information file for a basic Epson Stylus Photo R300 driver.</p>

<p>The file starts with the usual <tt>#include</tt> directives and
then sets the driver type and model number so that we use the ESC/P driver with the output tailored
to the R300:</p>

<pre>
    // Specify that this driver uses the ESC/P driver...
    DriverType escp

    // Specify the driver options via the model number...
    ModelNumber ($ESCP_ESCK $ESCP_EXT_UNITS $ESCP_EXT_MARGINS $ESCP_USB
        	 $ESCP_PAGE_SIZE $ESCP_RASTER_ESCI)
</pre>

<!-- NEED 19 -->
<p>Then we list all of the media sizes that are supported by the
printers along with the margins that should be used:</p>

<pre>
    HWMargins 8.4 0 8.4 0
    *MediaSize Letter
    MediaSize Legal
    MediaSize Executive
    MediaSize Statement
    MediaSize A4
    MediaSize A5
    MediaSize A6
    MediaSize B5
    MediaSize Env10
    MediaSize EnvC5
    MediaSize EnvDL
    MediaSize EnvISOB5
    MediaSize Postcard
    MediaSize DoublePostcard
</pre>

<p>The R300 supports custom page sizes up to 44 inches (1.1m) in
length. We use the <tt>VariablePaperSize</tt> directive to
instruct the PPD compiler to include the custom page size
attributes, and the <tt>MinSize</tt> and <tt>MaxSize</tt>
directives to specify the range of sizes that are supported:</p>

<pre>
    VariablePaperSize Yes
    MinSize 1in 4in
    MaxSize 8.5in 44in
</pre>

<p>The R300 driver also supports four color modes: Grayscale
(colorspace = w), Black (colorspace = k), RGB (colorspace =
rgb), and CMYK (colorspace = cmyk). The Grayscale and RGB modes
provide color/gamma-corrected output while the Black and CMYK
modes offer uncorrected color printing. The <tt>ColorModel</tt>
directive tells the PPD compiler to include each of these
modes:</p>

<pre>
    ColorModel Gray/Grayscale w chunky 1
    ColorModel Black k chunky 1
    *ColorModel RGB/Color rgb chunky 1
    ColorModel CMYK cmyk chunky 1
</pre>

<p>The driver provides printing at 360, 720, and 1440 DPI using
the <tt>Resolution</tt> directives. Each resolution makes use of
the bits per color, row count, and row step values:</p>

<pre>
    Resolution - 8 90 0 103 "360dpi/360 DPI"
    *Resolution - 8 90 0 206 "720dpi/720 DPI"
    Resolution - 8 90 0 412 "1440dpi/1440 DPI"
</pre>

<!-- NEW PAGE -->
<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i><a name='LISTING3-3'>Listing 3-3,
"examples/r300-basic.drv"</a></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>// Include ESC/P driver definitions</i>
<b>#include</b> &lt;escp.h&gt;

<i>// Specify that this driver uses the ESC/P driver...</i>
<b>DriverType</b> escp

<i>// Specify the driver options via the model number...</i>
<b>ModelNumber</b> ($ESCP_ESCK $ESCP_EXT_UNITS $ESCP_EXT_MARGINS
             $ESCP_USB $ESCP_PAGE_SIZE $ESCP_RASTER_ESCI)

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

<i>// Manufacturer and driver version</i>
<b>Manufacturer</b> "Epson"
<b>Version</b> 1.0

<i>// Supported page sizes and their margins</i>
<b>HWMargins</b> 8.4 0 8.4 0
*<b>MediaSize</b> Letter
<b>MediaSize</b> Legal
<b>MediaSize</b> Executive
<b>MediaSize</b> Statement
<b>MediaSize</b> A4
<b>MediaSize</b> A5
<b>MediaSize</b> A6
<b>MediaSize</b> B5
<b>MediaSize</b> Env10
<b>MediaSize</b> EnvC5
<b>MediaSize</b> EnvDL
<b>MediaSize</b> EnvISOB5
<b>MediaSize</b> Postcard
<b>MediaSize</b> DoublePostcard

<b>VariablePaperSize</b> Yes
<b>MinSize</b> 1in 4in
<b>MaxSize</b> 8.5in 44in

<i>// Four color modes are supported...</i>
<b>ColorModel</b> Gray/Grayscale w chunky 1
<b>ColorModel</b> Black k chunky 1
*<b>ColorModel</b> RGB/Color rgb chunky 1
<b>ColorModel</b> CMYK cmyk chunky 1

<i>// Supported resolutions</i>
<b>Resolution</b> - 8 90 0 103 "360dpi/360 DPI"
*<b>Resolution</b> - 8 90 0 206 "720dpi/720 DPI"
<b>Resolution</b> - 8 90 0 412 "1440dpi/1440 DPI"
</pre></td></tr>
</table></center>

<!-- NEW PAGE -->
<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i>Listing 3-3,
"examples/r300-basic.drv" continued...</i></caption>
<tr><td><pre>
<i>// Very basic dithering settings</i>
<b>Attribute</b> cupsInkChannels "" 6
<b>Attribute</b> cupsInkLimit "" 2.0

<b>Attribute</b> cupsCyanLtDk "" "0.5 1.0"
<b>Attribute</b> cupsMagentaLtDk "" "0.5 1.0"

<b>Attribute</b> cupsAllDither 360dpi "0.5 0.75 1.0"
<b>Attribute</b> cupsAllDither 720dpi "0.6 0.9 1.2"
<b>Attribute</b> cupsAllDither 1440dpi "0.9 1.35"

<b>Attribute</b> cupsESCPDotSize 360dpi 16
<b>Attribute</b> cupsESCPDotSize 720dpi 17
<b>Attribute</b> cupsESCPDotSize 1440dpi 18

{
  <i>// EPSON Stylus Photo R300 Series</i>
  <b>Throughput</b> 1
  <b>ModelName</b> "Epson Stylus Photo R300"
  <b>PCFileName</b> "epspr301.ppd"
}
</pre></td></tr>
</table></center>

<p>The R300 has 90 nozzles per color spaced at 120 DPI
vertically; the head controller can print 360 DPI horizontally.
The row count value is the same as the nozzle count, 90.
The row step values require a small amount of calculation; each
value is computed using the following formula:</p>

<pre>
    row-step = 100 * <i>x-dpi</i> / 360 + <i>y-dpi / 120</i>
</pre>

<!-- NEED 8 -->
<p>For 360x360 DPI, the row step is therefore:</p>

<pre>
    row-step = 100 * <i>x-dpi</i> / 360 + <i>y-dpi / 120</i>
             = 100 * 360 / 360 + 360 / 120
             = 100 * 1 + 3
	     = 100 + 3
	     = 103
</pre>

<p>The 720 and 1440 DPI resolutions are computed similarly, and
it is possible to support any multiple of the base resolution,
360x120 DPI, up to the physical limit of the printer controller,
5760x1440 DPI.</p>

<p>The R300 driver also needs some additional attributes defined
to control the amount and kind of ink that is printed on the
page. The first attribute we need to define is
<tt>cupsInkChannels</tt> which tells the driver how many colors
are used by the printer. In this case, the R300 is a 6-color
printer:</p>

<pre>
    Attribute cupsInkChannels "" 6
</pre>

<!-- NEED 5 -->
<p>Next we want to limit the amount of ink that is put on the
page to 200%. The <tt>cupsInkLimit</tt> attribute specifies this
value:</p>

<pre>
    Attribute cupsInkLimit "" 2.0
</pre>

<p>Since the R300 uses light versions of cyan and magenta, we
need to tell the driver when to use the light ink and when to
use the dark ink. The simplest attributes for this specify the
transition range as two numbers from 0 to 1. We'll transition
from 0.5 to 1.0 for both colors:</p>

<pre>
    Attribute cupsCyanLtDk "" "0.5 1.0"
    Attribute cupsMagentaLtDk "" "0.5 1.0"
</pre>

<p>Next, we want to specify the ink density for the dots that
the R300 can produce for each resolution using the
<tt>cupsAllDither</tt> attribute. Each number represents a
percentage of ink, so a value of 1.0 means 100% coverage for
each dot and a value of 2.0 means 200% coverage for each dot.
The driver uses this information to reduce the amount of ink
that is put on the page for each individual color. Since the
R300 supports three different dot sizes, we include three
numbers for the 360 and 720 DPI modes, however at 1440 DPI the
largest dot size is not needed:</p>

<pre>
    Attribute cupsAllDither 360dpi "0.5 0.75 1.0"
    Attribute cupsAllDither 720dpi "0.6 0.9 1.2"
    Attribute cupsAllDither 1440dpi "0.9 1.35"
</pre>

<p>Finally, we tell the driver which dot sizes to use for each
resolution using the <tt>cupsESCPDotSize</tt> attribute. These
values are defined in the corresponding developer reference
manual from Epson. For the R300, size 16 represents the largest
variable size dots and size 18 the smallest:</p>

<pre>
    Attribute cupsESCPDotSize 360dpi 16
    Attribute cupsESCPDotSize 720dpi 17
    Attribute cupsESCPDotSize 1440dpi 18
</pre>

<p>To test the new drivers, start by running the <tt>ppdc</tt>
program to create the PPD files:</p>

<pre>
    <kbd>ppdc r300-basic.drv ENTER</kbd>
</pre>

<!-- NEED 5 -->
<p>Then use the <tt>lpadmin(8)</tt> command to add the printer
with the correct device URI. The following example adds a R300
which is connected via a USB port:</p>

<pre>
    <kbd>lpadmin -p r300 -E -v 'usb://EPSON/Stylus%20Photo%20R300' -i \
           ppd/epspr301.ppd ENTER</kbd>
</pre>

<p>Finally, print a test page to see it work:</p>

<pre>
    <kbd>lp -d r300 /usr/share/cups/data/testprint.ps ENTER</kbd>
</pre>

<h3>Epson Remote Mode Attributes</h3>

<p>Most Epson inkjet printers support a special "remote" mode
which allows you to control things such as the paper cutter,
media type, drying time, and so forth. Remote mode also allows
you to query the current ink status from the printer, clean the
print heads, etc., and that functionality is supported via the
<tt>commandtoescpx</tt> filter.</p>

<p>Remote mode support is specified using the
<tt>ESCP_REMOTE</tt> model number constant. If remote mode is
enabled, the <tt>rastertoescpx</tt> driver will look for several
attributes to determine which remote mode commands to send and
with what values. <a href='#TABLE3-6'>Table 3-6</a> lists the
remote mode attributes and their values.</p>

<p>Typically, each attribute maps from a single, integer value
from the page device dictionary to a single integer value which
is used for the corresponding remote mode command. The only
exception to this rule is the <tt>cupsESCPPP</tt> attribute
which maps the <tt>MediaPosition</tt> value to two integer
values for the "PP" (paper path) remote mode command, for
example:</p>

<pre>
    Attribute cupsESCPPP 0 "1 255"
</pre>

<p>The integer values used for all remote mode commands are
documented in the corresponding Epson programming guide for your
printer.</p>

<h3>Adding Remote Mode Commands to the R300 Driver</h3>

<p>The R300 supports several remote mode commands that we can
use. We will add support for full-bleed printing and
specification of the media source. <a href='#LISTING3-4'>Listing
3-4</a> shows the updated driver information file. We'll start
by adding the <tt>ESCP_REMOTE</tt> constant to the model number
definition:</p>

<pre>
    ModelNumber ($ESCP_ESCK $ESCP_EXT_UNITS $ESCP_EXT_MARGINS $ESCP_USB
                 $ESCP_PAGE_SIZE $ESCP_RASTER_ESCI $ESCP_REMOTE)
</pre>

<p>Next we add the horizontal offset attribute,
<tt>cupsESCPFP</tt>, that is used to offset the page for
full-bleed printing:</P>

<pre>
    Attribute cupsESCPFP "" -80
</pre>

<p>Finally, we add <tt>InputSlot</tt> definitions for automatic
and manual feed printing, and <tt>cupsESCPPP</tt> attributes for
each <tt>MediaPosition</tt> value:</p>

<pre>
    *InputSlot 0 "Auto/Auto Select"
    InputSlot 1 "Manual/Manual Feed"

    Attribute cupsESCPPP 0 "1 255"
    Attribute cupsESCPPP 1 "2 1"
</pre>

<center><table border='1' cellpadding='5' cellspacing='0' width='80%'>
<caption align='bottom'><a name='TABLE3-6'><i>Table 3-6, Epson
remote mode attributes</i></a></caption>
<tr bgcolor='#cccccc'>
	<th>Attribute</th>
	<th>Description</th>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPAC</tt></td>
	<td align='justify' valign='top'>Enables/disables the
	cutter based upon the <tt>CutMedia</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPCO</tt></td>
	<td align='justify' valign='top'>Enables/disables the
	cutter based upon the <tt>CutMedia</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPEX</tt></td>
	<td align='justify' valign='top'>Sets the media position
	based upon the <tt>MediaPosition</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPFP</tt></td>
	<td align='justify' valign='top'>Sets the full-bleed
	horizontal position offset</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPMS</tt></td>
	<td align='justify' valign='top'>Sets the media size
	based upon the <tt>MediaPosition</tt> and
	<tt>PageSize</tt> values</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPMT</tt></td>
	<td align='justify' valign='top'>Sets the media type
	based upon the <tt>cupsMediaType</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPPC</tt></td>
	<td align='justify' valign='top'>Sets paper checking
	based upon the <tt>MediaPosition</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPPH</tt></td>
	<td align='justify' valign='top'>Sets the paper
	thickness based upon the <tt>cupsMediaType</tt>
	value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPPP</tt></td>
	<td align='justify' valign='top'>Sets the paper path
	based upon the <tt>MediaPosition</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPSN0</tt></td>
	<td align='justify' valign='top'>Sets the feed sequence
	based upon the <tt>cupsMediaType</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPSN1</tt></td>
	<td align='justify' valign='top'>Sets the platten gap
	based upon the <tt>cupsMediaType</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPSN2</tt></td>
	<td align='justify' valign='top'>Sets the paper
	feed/eject sequence based upon the
	<tt>cupsMediaType</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPSN6</tt></td>
	<td align='justify' valign='top'>Sets the eject delay
	based upon the <tt>cupsMediaType</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPSN80</tt></td>
	<td align='justify' valign='top'>Sets the cutting method
	based upon the <tt>CutMedia</tt> value</td>
</tr>
<tr>
	<td valign='top'><tt>cupsESCPSN81</tt></td>
	<td align='justify' valign='top'>Sets the cutting
	pressure based upon the <tt>CutMedia</tt> value</td>
</tr>
</table></center>

<p>To test the new drivers, start by running the <tt>ppdc</tt>
program to create the PPD files:</p>

<pre>
    <kbd>ppdc r300-remote.drv ENTER</kbd>
</pre>

<!-- NEED 5 -->
<p>Then use the <tt>lpadmin(8)</tt> command to add the printer
with the correct device URI. The following example adds a R300
which is connected via a USB port:</p>

<pre>
    <kbd>lpadmin -p r300 -E -v 'usb://EPSON/Stylus%20Photo%20R300' \
        -i ppd/epspr302.ppd ENTER</kbd>
</pre>

<p>Finally, print a test page to see it work:</p>

<pre>
    <kbd>lp -d r300 /usr/share/cups/data/testprint.ps ENTER</kbd>
</pre>

<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i><a name='LISTING3-4'>Listing 3-4,
"examples/r300-remote.drv"</a></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>// Include ESC/P driver definitions</i>
<b>#include</b> &lt;escp.h&gt;

<i>// Specify that this driver uses the ESC/P driver...</i>
<b>DriverType</b> escp

<i>// Specify the driver options via the model number...</i>
<b>ModelNumber</b> ($ESCP_ESCK $ESCP_EXT_UNITS $ESCP_EXT_MARGINS
             $ESCP_USB $ESCP_PAGE_SIZE $ESCP_RASTER_ESCI
             $ESCP_REMOTE)

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

<i>// Manufacturer and driver version</i>
<b>Manufacturer</b> "Epson"
<b>Version</b> 2.0

<i>// Supported page sizes and their margins</i>
<b>HWMargins</b> 0 0 0 0
*<b>MediaSize</b> Letter
<b>MediaSize</b> Legal
<b>MediaSize</b> Executive
<b>MediaSize</b> Statement
<b>MediaSize</b> A4
<b>MediaSize</b> A5
<b>MediaSize</b> A6
<b>MediaSize</b> B5
<b>MediaSize</b> Env10
<b>MediaSize</b> EnvC5
<b>MediaSize</b> EnvDL
<b>MediaSize</b> EnvISOB5
<b>MediaSize</b> Postcard
<b>MediaSize</b> DoublePostcard
</pre></td></tr>
</table></center>

<!-- NEW PAGE -->
<center><table width='90%' bgcolor='#cccccc' border='1' cellpadding='5' cellspacing='0'>
<caption align='bottom'><i>Listing 3-4,
"examples/r300-remote.drv" continued...</i></caption>
<tr><td><pre>
<b>VariablePaperSize</b> Yes
<b>MinSize</b> 1in 4in
<b>MaxSize</b> 8.5in 44in

<i>// Borderless printing offset...</i>
<b>Attribute</b> cupsESCPFP "" -80

<i>// Four color modes are supported...</i>
<b>ColorModel</b> Gray/Grayscale w chunky 1
<b>ColorModel</b> Black k chunky 1
*<b>ColorModel</b> RGB/Color rgb chunky 1
<b>ColorModel</b> CMYK cmyk chunky 1

<i>// Supported resolutions</i>
<b>Resolution</b> - 8 90 0 103 "360dpi/360 DPI"
*<b>Resolution</b> - 8 90 0 206 "720dpi/720 DPI"
<b>Resolution</b> - 8 90 0 412 "1440dpi/1440 DPI"

<i>// Paper trays...</i>
*<b>InputSlot</b> 0 "Auto/Auto Select"
<b>InputSlot</b> 1 "Manual/Manual Feed"

<b>Attribute</b> cupsESCPPP 0 "1 255"
<b>Attribute</b> cupsESCPPP 1 "2 1"

<i>// Very basic dithering settings</i>
<b>Attribute</b> cupsInkChannels "" 6
<b>Attribute</b> cupsInkLimit "" 2.0

<b>Attribute</b> cupsCyanLtDk "" "0.5 1.0"
<b>Attribute</b> cupsMagentaLtDk "" "0.5 1.0"

<b>Attribute</b> cupsAllDither 360dpi "0.5 0.75 1.0"
<b>Attribute</b> cupsAllDither 720dpi "0.6 0.9 1.2"
<b>Attribute</b> cupsAllDither 1440dpi "0.9 1.35"

<b>Attribute</b> cupsESCPDotSize 360dpi 16
<b>Attribute</b> cupsESCPDotSize 720dpi 17
<b>Attribute</b> cupsESCPDotSize 1440dpi 18

{
  <i>// EPSON Stylus Photo R300 Series</i>
  <b>Throughput</b> 1
  <b>ModelName</b> "Epson Stylus Photo R300"
  <b>PCFileName</b> "epspr302.ppd"
}
</pre></td></tr>
</table></center>


</div>

</body>
</html>