]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/postscript-driver.html
Merge changes from CUPS 1.4svn-r8162.
[thirdparty/cups.git] / doc / help / postscript-driver.html
CommitLineData
28b9d139
MS
1<HTML>
2<!-- SECTION: Programming -->
3<HEAD>
4 <TITLE>Developing PostScript Printer Drivers</TITLE>
5</HEAD>
6<BODY>
7
8<p>This document describes how to develop printer drivers for PostScript printers. Topics include: <a href='#BASICS'>printer driver basics</a>, <a href='#CREATE'>creating new PPD files</a>, <a href='#IMPORT'>importing existing PPD files</a>, <a href='#FILTERS'>using custom filters</a>, <a href='#COLOR'>implementing color management</a>, <a href='#MACOSX'>adding Mac OS X features</a>, and <a href='#DEPLOY'>deploying your driver</a>.</p>
9
10<div class='summary'><table summary='General Information'>
11<tbody>
12<tr>
13 <th>See Also</th>
14 <td>Programming: <a href='raster-driver.html'>Developing Raster Printer Drivers</a><br>
15 Programming: <a href='api-filter.html'>Filter and Backend Programming</a><br>
16 Programming: <a href='ppd-compiler.html'>Introduction to the PPD Compiler</a><br>
17 Programming: <a href='api-raster.html'>Raster API</a><br>
18 References: <a href='ref-ppdcfile.html'>PPD Compiler Driver Information File Reference</a><br>
19 Specifications: <a href='spec-ppd.html'>CUPS PPD Extensions</a></td>
20</tr>
21</tbody>
22</table></div>
23
24
25<h2 class='title'><a name='BASICS'>Printer Driver Basics</a></h2>
26
27<p>A CUPS PostScript printer driver consists of a PostScript Printer Description (PPD) file that describes the features and capabilities of the device, zero or more <em>filter</em> programs that prepare print data for the device, and zero or more support files for color management, online help, and so forth. The PPD file includes references to all of the filters and support files used by the driver.</p>
28
29<p>Every time a user prints something the scheduler program, <a href='man-cupsd.html'>cupsd(8)</a>, determines the format of the print job and the programs required to convert that job into something the printer understands. CUPS includes filter programs for many common formats, for example to convert Portable Document Format (PDF) files into device-independent PostScript, and then from device-independent PostScript to device-dependent PostScript. <a href='#FIGURE_1'>Figure 1</a> shows the data flow of a typical print job.</p>
30
31<div class='figure'><table summary='PostScript Filter Chain'>
32<caption>Figure 1: <a name='FIGURE_1'>PostScript Filter Chain</a></caption>
33<tr><td><img src='/images/cups-postscript-chain.png' width='700' height='150' alt='PostScript Filter Chain'></td></tr>
34</table></div>
35
36<p>The optional PostScript filter can be provided to add printer-specific commands to the PostScript output that cannot be represented in the PPD file or to reorganize the output for special printer features. Typically this is used to support advanced job management or finishing functions on the printer. CUPS includes a generic PostScript filter that handles all PPD-defined commands.</p>
37
38<p>The optional port monitor handles interface-specific protocol or encoding issues. For example, many PostScript printers support the Binary Communications Protocol (BCP) and Tagged Binary Communications Protocol (TBCP) to allow applications to print 8-bit ("binary") PostScript jobs. CUPS includes port monitors for BCP and TBCP, and you can supply your own port monitors as needed.</p>
39
40<p>The backend handles communications with the printer, sending print data from the last filter to the printer and relaying back-channel data from the printer to the upstream filters. CUPS includes backend programs for common direct-connect interfaces and network protocols, and you can provide your own backend to support custom interfaces and protocols.</p>
41
42<p>The scheduler also supports a special "command" file format for sending maintenance commands and status queries to a printer or printer driver. Command print jobs typically use a single command filter program defined in the PPD file to generate the appropriate printer commands and handle any responses from the printer. <a href='#FIGURE_2'>Figure 2</a> shows the data flow of a typical command job.</p>
43
44<div class='figure'><table summary='Command Filter Chain'>
45<caption>Figure 2: <a name='FIGURE_2'>Command Filter Chain</a></caption>
46<tr><td><img src='/images/cups-command-chain.png' width='575' height='150' alt='Command Filter Chain'></td></tr>
47</table></div>
48
49<p>PostScript printer drivers typically do not require their own command filter since CUPS includes a generic PostScript command filter that supports all of the standard functions using PPD-defined commands.</p>
50
51
52<h2 class='title'><a name='CREATING'>Creating New PPD Files</a></h2>
53
54<p>We recommend using the CUPS PPD compiler, <a href='man-ppdc.html'>ppdc(1)</a>, to create new PPD files since it manages many of the tedious (and error-prone!) details of paper sizes and localization for you. It also allows you to easily support multiple devices from a single source file. For more information see the "<a href='ppd-compiler.html'>Introduction to the PPD Compiler</a>" document. <a href='#LISTING_1'>Listing 1</a> shows a driver information file for a black-and-white PostScript printer.</p>
55
56<p class='example'>Listing 1: <a name='LISTING_1'>"examples/postscript.drv"</a></p>
57
58<pre class='example'>
59// Include standard font and media definitions
60<a href='ref-ppdcfile.html#_include'>#include</a> &lt;font.defs&gt;
61<a href='ref-ppdcfile.html#_include'>#include</a> &lt;media.defs&gt;
62
63// Specify this is a PostScript printer driver
64<a href='ref-ppdcfile.html#DriverType'>DriverType</a> ps
65
66// List the fonts that are supported, in this case all standard fonts
67<a href='ref-ppdcfile.html#Font'>Font</a> *
68
69// Manufacturer, model name, and version
70<a href='ref-ppdcfile.html#Manufacturer'>Manufacturer</a> "Foo"
71<a href='ref-ppdcfile.html#ModelName'>ModelName</a> "Foo LaserProofer 2000"
72<a href='ref-ppdcfile.html#Version'>Version</a> 1.0
73
74// PostScript printer attributes
75<a href='ref-ppdcfile.html#Attribute'>Attribute</a> DefaultColorSpace "" Gray
76<a href='ref-ppdcfile.html#Attribute'>Attribute</a> LandscapeOrientation "" Minus90
77<a href='ref-ppdcfile.html#Attribute'>Attribute</a> LanguageLevel "" "3"
78<a href='ref-ppdcfile.html#Attribute'>Attribute</a> Product "" "(Foo LaserProofer 2000)"
79<a href='ref-ppdcfile.html#Attribute'>Attribute</a> PSVersion "" "(3010) 0"
80<a href='ref-ppdcfile.html#Attribute'>Attribute</a> TTRasterizer "" Type42
81
82// Supported page sizes
83*<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Letter
84<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> Legal
85<a href='ref-ppdcfile.html#MediaSize'>MediaSize</a> A4
86
87// Query command for page size
88<a href='ref-ppdcfile.html#Attribute'>Attribute</a> "?PageSize" "" "
89 save
90 currentpagedevice /PageSize get aload pop
91 2 copy gt {exch} if (Unknown)
92 23 dict
93 dup [612 792] (Letter) put
94 dup [612 1008] (Legal) put
95 dup [595 842] (A4) put
96 {exch aload pop 4 index sub abs 5 le exch
97 5 index sub abs 5 le and
98 {exch pop exit} {pop} ifelse
99 } bind forall = flush pop pop
100 restore"
101
102// Specify the name of the PPD file we want to generate
103<a href='ref-ppdcfile.html#PCFileName'>PCFileName</a> "fooproof.ppd"
104</pre>
105
106<h3>Required Attributes</h3>
107
108<p>PostScript drivers require the attributes listed in <a href='#TABLE_1'>Table 1</a>. If not specified, the defaults for CUPS drivers are used. A typical PostScript driver information file would include the following attributes:</p>
109
110<pre class='example'>
111<a href='ref-ppdcfile.html#Attribute'>Attribute</a> DefaultColorSpace "" Gray
112<a href='ref-ppdcfile.html#Attribute'>Attribute</a> LandscapeOrientation "" Minus90
113<a href='ref-ppdcfile.html#Attribute'>Attribute</a> LanguageLevel "" "3"
114<a href='ref-ppdcfile.html#Attribute'>Attribute</a> Product "" "(Foo LaserProofer 2000)"
115<a href='ref-ppdcfile.html#Attribute'>Attribute</a> PSVersion "" "(3010) 0"
116<a href='ref-ppdcfile.html#Attribute'>Attribute</a> TTRasterizer "" Type42
117</pre>
118
119<div class='table'><table summary='Required PostScript Printer Driver Attributes'>
120<caption>Table 1: <a name='TABLE_1'>Required PostScript Printer Driver Attributes</a></caption>
121<thead>
122<tr>
123 <th>Attribute</th>
124 <th>Description</th>
125</tr>
126</thead>
127<tbody>
128<tr>
129 <td><tt>DefaultColorSpace</tt></td>
130 <td>The default colorspace:
131 <tt>Gray</tt>, <tt>RGB</tt>, <tt>CMY</tt>, or
132 <tt>CMYK</tt>. If not specified, then <tt>RGB</tt> is
133 assumed.</td>
134</tr>
135<tr>
136 <td><tt>LandscapeOrientation</tt></td>
137 <td>The preferred landscape
138 orientation: <tt>Plus90</tt>, <tt>Minus90</tt>, or
139 <tt>Any</tt>. If not specified, <tt>Plus90</tt> is
140 assumed.</td>
141</tr>
142<tr>
143 <td><tt>LanguageLevel</tt></td>
144 <td>The PostScript language
145 level supported by the device: 1, 2, or 3. If not
146 specified, 2 is assumed.</td>
147</tr>
148<tr>
149 <td><tt>Product</tt></td>
150 <td>The string returned by
151 the PostScript <tt>product</tt> operator, which
152 <i>must</i> include parenthesis to conform with
153 PostScript syntax rules for strings. Multiple
154 <tt>Product</tt> attributes may be specified to support
155 multiple products with the same PPD file. If not
156 specified, "(ESP Ghostscript)" and "(GNU Ghostscript)"
157 are assumed.</td>
158</tr>
159<tr>
160 <td><tt>PSVersion</tt></td>
161 <td>The PostScript
162 interpreter version numbers as returned by the
163 <tt>version</tt> and <tt>revision</tt> operators. The
164 required format is "(version) revision". Multiple
165 <tt>PSVersion</tt> attributes may be specified to
166 support multiple interpreter version numbers. If not
167 specified, "(3010) 705" and "(3010) 707" are
168 assumed.</td>
169</tr>
170<tr>
171 <td><tt>TTRasterizer</tt></td>
172 <td>The type of TrueType
173 font rasterizer supported by the device, if any. The
174 supported values are <tt>None</tt>, <tt>Accept68k</tt>,
175 <tt>Type42</tt>, and <tt>TrueImage</tt>. If not
176 specified, <tt>None</tt> is assumed.</td>
177</tr>
178</table></div>
179
180<h3>Query Commands</h3>
181
182<p>Most PostScript printer PPD files include query commands (<tt>?PageSize</tt>, etc.) that allow applications to query the printer for its current settings and configuration. Query commands are included in driver information files as attributes. For example, the example in <a href='#LISTING_1'>Listing 1</a> uses the following definition for the <tt>PageSize</tt> query command:</p>
183
184<pre class='example'>
185<a href='ref-ppdcfile.html#Attribute'>Attribute</a> "?PageSize" "" "
186 save
187 currentpagedevice /PageSize get aload pop
188 2 copy gt {exch} if (Unknown)
189 23 dict
190 dup [612 792] (Letter) put
191 dup [612 1008] (Legal) put
192 dup [595 842] (A4) put
193 {exch aload pop 4 index sub abs 5 le exch
194 5 index sub abs 5 le and
195 {exch pop exit} {pop} ifelse
196 } bind forall = flush pop pop
197 restore"
198</pre>
199
200<p>Query commands can span multiple lines, however no single line may contain more than 255 characters.</p>
201
202<h3><a name='IMPORT'>Importing Existing PPD Files</a></h3>
203
204<P>CUPS includes a utility called <a href='man-ppdi.html'>ppdi(1)</a>
205which allows you to import existing PPD files into the driver information file
206format used by the PPD compiler <a href='man-ppdc.html'>ppdc(1)</a>. Once
207imported, you can modify, localize, and regenerate the PPD files easily. Type
208the following command to import the PPD file <VAR>mydevice.ppd</VAR> into the
209driver information file <VAR>mydevice.drv</VAR>:</P>
210
211<pre class='command'>
212ppdi -o mydevice.drv mydevice.ppd
213</pre>
214
215<P>If you have a whole directory of PPD files that you would like to import,
216you can list multiple filenames or use shell wildcards to import more than one
217PPD file on the command-line:</P>
218
219<pre class='command'>
220ppdi -o mydevice.drv mydevice1.ppd mydevice2.ppd
221ppdi -o mydevice.drv *.ppd
222</pre>
223
224<P>If the driver information file already exists, the new PPD
225file entries are appended to the end of the file. Each PPD file
226is placed in its own group of curly braces within the driver
227information file.</P>
228
229
230<h2 class='title'><a name='FILTERS'>Using Custom Filters</a></h2>
231
232<p>Normally a PostScript printer driver will not utilize any additional print filters. For drivers that provide additional filters such as a CUPS command file filter for doing printer maintenance, you must also list the following <tt>Filter</tt> directive to handle printing PostScript files:</p>
233
234<pre class='example'>
235<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-postscript 0 -
236</pre>
237
e4572d57
MS
238<h3>Custom Command Filters</h3>
239
240<p>The <tt>application/vnd.cups-command</tt> file type is used for CUPS command files. Use the following <tt>Filter</tt> directive to handle CUPS command files:</p>
241
242<pre class='example'>
243<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-command 100 /path/to/command/filter
244</pre>
245
246<p>To use the standard PostScript command filter, specify <var>commandtops</var> as the path to the command filter.</p>
247
248<h3>Custom PDF Filters</h3>
249
250<p>The <tt>application/pdf</tt> file type is used for unfiltered PDF files while the <tt>application/vnd.cups-pdf</tt> file type is used for filtered PDF files. Use the following <tt>Filter</tt> directive to handle filtered PDF files:</p>
251
252<pre class='example'>
253<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-pdf 100 /path/to/pdf/filter
254</pre>
255
256<p>For unfiltered PDF files, use:</p>
257
258<pre class='example'>
259<a href='ref-ppdcfile.html#Filter'>Filter</a> application/pdf 100 /path/to/pdf/filter
260</pre>
261
262<p>Custom PDF filters that accept filtered data do not need to perform number-up processing and other types of page imposition, while those that accept unfiltered data MUST do the number-up processing themselves.</p>
263
264<h3>Custom PostScript Filters</h3>
265
266<p>The <tt>application/vnd.cups-postscript</tt> file type is used for filtered PostScript files. Use the following <tt>Filter</tt> directive to handle PostScript files:</p>
267
268<pre class='example'>
269<a href='ref-ppdcfile.html#Filter'>Filter</a> application/vnd.cups-postscript 100 /path/to/postscript/filter
270</pre>
271
28b9d139
MS
272
273<h2 class='title'><a name='COLOR'>Implementing Color Management</a></h2>
274
275<p>Talk about ICC color profiles and sRGB as two best options.</p>
276
277
278<h2 class='title'><a name='MACOSX'>Adding Mac OS X Features</a></h2>
279
280<p>Talk about help books, icons, and PDEs.</p>
281
282
283<h2 class='title'><a name='DEPLOY'>Deploying Your Driver</a></h2>
284
285<p>Talk about install locations, etc.</p>
286
287
288</body>
289</html>