1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- SECTION: Programming -->
5 <title>Developing PostScript Printer Drivers
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8">
8 <meta name=
"creator" content=
"Mini-XML v2.7">
9 <style type=
"text/css"><!--
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
14 H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
19 font-family: monaco, courier, monospace;
24 font-family: monaco, courier, monospace;
28 border: dotted thin #7f7f7f;
56 border: dotted thin #999999;
61 PRE.command EM, PRE.example EM {
62 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
66 font-family: monaco, courier, monospace;
77 border: solid thin #999999;
88 -moz-border-radius: 10px;
93 text-decoration: none;
96 A:link:hover, A:visited:hover, A:active {
97 text-decoration: underline;
104 TR.data, TD.data, TR.data TD {
107 border-bottom: solid 1pt #999999;
111 border-bottom: solid 1pt #999999;
118 border: solid thin #999999;
119 border-collapse: collapse;
135 border: solid thin #cccccc;
142 border-bottom: solid thin #999999;
151 caption-side: bottom;
175 border: thin solid black;
183 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
192 border-bottom: solid 2pt #000000;
195 DIV.indent, TABLE.indent {
203 border-collapse: collapse;
206 TABLE.indent TD, TABLE.indent TH {
211 border-collapse: collapse;
219 border-bottom: solid thin #cccccc;
224 vertical-align: bottom;
233 border-bottom: solid thin #eeeeee;
238 TABLE.list TR:nth-child(even) {
242 TABLE.list TR:nth-child(odd) {
261 font-family: monaco, courier, monospace;
265 border: solid thin #999999;
266 border-collapse: collapse;
271 DIV.summary TABLE TD, DIV.summary TABLE TH {
272 border: solid thin #999999;
278 DIV.summary TABLE THEAD TH {
282 /* API documentation styles... */
289 div.body h3, div.body h4, div.body h5 {
290 margin-bottom: 0.5em;
293 .class, .enumeration, .function, .struct, .typedef, .union {
294 border-bottom: solid thin #999999;
301 code, p.code, pre, ul.code li {
302 font-family: monaco, courier, monospace;
305 ul.code, ul.contents, ul.subcontents {
306 list-style-type: none;
316 ul.contents li ul.code, ul.contents li ul.subcontents {
329 margin-bottom: 0.5em;
332 /* This is just for the HTML files generated with the framedhelp target */
335 border: solid thin black;
344 div.contents ul.contents {
347 div.contents ul.subcontents li {
358 PostScript printer driver documentation for CUPS.
360 Copyright 2007-2012 by Apple Inc.
361 Copyright 1997-2007 by Easy Software Products.
363 These coded instructions, statements, and computer programs are the
364 property of Apple Inc. and are protected by Federal copyright
365 law. Distribution and use rights are outlined in the file "LICENSE.txt"
366 which should have been included with this file. If this file is
367 file is missing or damaged, see the license at "http://www.cups.org/".
370 <h1 class='title'
>Developing PostScript Printer Drivers
</h1>
372 <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>, and
<a href='#MACOSX'
>adding OS X features
</a>.
</p>
374 <div class='summary'
><table summary='General Information'
>
378 <td>Programming:
<a href='raster-driver.html'
>Developing Raster Printer Drivers
</a><br>
379 Programming:
<a href='api-filter.html'
>Filter and Backend Programming
</a><br>
380 Programming:
<a href='ppd-compiler.html'
>Introduction to the PPD Compiler
</a><br>
381 Programming:
<a href='api-raster.html'
>Raster API
</a><br>
382 References:
<a href='ref-ppdcfile.html'
>PPD Compiler Driver Information File Reference
</a><br>
383 Specifications:
<a href='spec-ppd.html'
>CUPS PPD Extensions
</a></td>
387 <h2 class=
"title">Contents
</h2>
388 <ul class=
"contents">
389 <li><a href=
"#BASICS">Printer Driver Basics
</a></li>
390 <li><a href=
"#CREATING">Creating New PPD Files
</a><ul class=
"subcontents">
391 <li><a href=
"#IMPORT">Importing Existing PPD Files
</a></li>
393 <li><a href=
"#FILTERS">Using Custom Filters
</a></li>
394 <li><a href=
"#COLOR">Implementing Color Management
</a></li>
395 <li><a href=
"#MACOSX">Adding OS X Features
</a></li>
397 <h2 class='title'
><a name='BASICS'
>Printer Driver Basics
</a></h2>
399 <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>
401 <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>
403 <div class='figure'
><table summary='PostScript Filter Chain'
>
404 <caption>Figure
1:
<a name='FIGURE_1'
>PostScript Filter Chain
</a></caption>
405 <tr><td><img src='../images/cups-postscript-chain.png' width='
700' height='
150' alt='PostScript Filter Chain'
></td></tr>
408 <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>
410 <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>
412 <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>
414 <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>
416 <div class='figure'
><table summary='Command Filter Chain'
>
417 <caption>Figure
2:
<a name='FIGURE_2'
>Command Filter Chain
</a></caption>
418 <tr><td><img src='../images/cups-command-chain.png' width='
575' height='
150' alt='Command Filter Chain'
></td></tr>
421 <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>
424 <h2 class='title'
><a name='CREATING'
>Creating New PPD Files
</a></h2>
426 <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>
428 <p class='example'
>Listing
1:
<a name='LISTING_1'
>"examples/postscript.drv"</a></p>
430 <pre class='example'
>
431 // Include standard font and media definitions
432 <a href='ref-ppdcfile.html#_include'
>#include
</a> <font.defs
>
433 <a href='ref-ppdcfile.html#_include'
>#include
</a> <media.defs
>
435 // Specify this is a PostScript printer driver
436 <a href='ref-ppdcfile.html#DriverType'
>DriverType
</a> ps
438 // List the fonts that are supported, in this case all standard fonts
439 <a href='ref-ppdcfile.html#Font'
>Font
</a> *
441 // Manufacturer, model name, and version
442 <a href='ref-ppdcfile.html#Manufacturer'
>Manufacturer
</a> "Foo"
443 <a href='ref-ppdcfile.html#ModelName'
>ModelName
</a> "Foo LaserProofer 2000"
444 <a href='ref-ppdcfile.html#Version'
>Version
</a> 1.0
446 // PostScript printer attributes
447 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> DefaultColorSpace
"" Gray
448 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> LandscapeOrientation
"" Minus90
449 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> LanguageLevel
"" "3"
450 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> Product
"" "(Foo LaserProofer 2000)"
451 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> PSVersion
"" "(3010) 0"
452 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> TTRasterizer
"" Type42
454 // Supported page sizes
455 *
<a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Letter
456 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> Legal
457 <a href='ref-ppdcfile.html#MediaSize'
>MediaSize
</a> A4
459 // Query command for page size
460 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> "?PageSize" "" "
462 currentpagedevice /PageSize get aload pop
463 2 copy gt {exch} if (Unknown)
465 dup [612 792] (Letter) put
466 dup [612 1008] (Legal) put
467 dup [595 842] (A4) put
468 {exch aload pop 4 index sub abs 5 le exch
469 5 index sub abs 5 le and
470 {exch pop exit} {pop} ifelse
471 } bind forall = flush pop pop
474 // Specify the name of the PPD file we want to generate
475 <a href='ref-ppdcfile.html#PCFileName'
>PCFileName
</a> "fooproof.ppd"
478 <h3>Required Attributes
</h3>
480 <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>
482 <pre class='example'
>
483 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> DefaultColorSpace
"" Gray
484 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> LandscapeOrientation
"" Minus90
485 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> LanguageLevel
"" "3"
486 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> Product
"" "(Foo LaserProofer 2000)"
487 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> PSVersion
"" "(3010) 0"
488 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> TTRasterizer
"" Type42
491 <div class='table'
><table summary='Required PostScript Printer Driver Attributes'
>
492 <caption>Table
1:
<a name='TABLE_1'
>Required PostScript Printer Driver Attributes
</a></caption>
501 <td><tt>DefaultColorSpace
</tt></td>
502 <td>The default colorspace:
503 <tt>Gray
</tt>,
<tt>RGB
</tt>,
<tt>CMY
</tt>, or
504 <tt>CMYK
</tt>. If not specified, then
<tt>RGB
</tt> is
508 <td><tt>LandscapeOrientation
</tt></td>
509 <td>The preferred landscape
510 orientation:
<tt>Plus90
</tt>,
<tt>Minus90
</tt>, or
511 <tt>Any
</tt>. If not specified,
<tt>Plus90
</tt> is
515 <td><tt>LanguageLevel
</tt></td>
516 <td>The PostScript language
517 level supported by the device:
1,
2, or
3. If not
518 specified,
2 is assumed.
</td>
521 <td><tt>Product
</tt></td>
522 <td>The string returned by
523 the PostScript
<tt>product
</tt> operator, which
524 <i>must
</i> include parenthesis to conform with
525 PostScript syntax rules for strings. Multiple
526 <tt>Product
</tt> attributes may be specified to support
527 multiple products with the same PPD file. If not
528 specified,
"(ESP Ghostscript)" and
"(GNU Ghostscript)"
532 <td><tt>PSVersion
</tt></td>
534 interpreter version numbers as returned by the
535 <tt>version
</tt> and
<tt>revision
</tt> operators. The
536 required format is
"(version) revision". Multiple
537 <tt>PSVersion
</tt> attributes may be specified to
538 support multiple interpreter version numbers. If not
539 specified,
"(3010) 705" and
"(3010) 707" are
543 <td><tt>TTRasterizer
</tt></td>
544 <td>The type of TrueType
545 font rasterizer supported by the device, if any. The
546 supported values are
<tt>None
</tt>,
<tt>Accept68k
</tt>,
547 <tt>Type42
</tt>, and
<tt>TrueImage
</tt>. If not
548 specified,
<tt>None
</tt> is assumed.
</td>
552 <h3>Query Commands
</h3>
554 <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>
556 <pre class='example'
>
557 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> "?PageSize" "" "
559 currentpagedevice /PageSize get aload pop
560 2 copy gt {exch} if (Unknown)
562 dup [612 792] (Letter) put
563 dup [612 1008] (Legal) put
564 dup [595 842] (A4) put
565 {exch aload pop 4 index sub abs 5 le exch
566 5 index sub abs 5 le and
567 {exch pop exit} {pop} ifelse
568 } bind forall = flush pop pop
572 <p>Query commands can span multiple lines, however no single line may contain more than
255 characters.
</p>
574 <h3><a name='IMPORT'
>Importing Existing PPD Files
</a></h3>
576 <P>CUPS includes a utility called
<a href='man-ppdi.html'
>ppdi(
1)
</a>
577 which allows you to import existing PPD files into the driver information file
578 format used by the PPD compiler
<a href='man-ppdc.html'
>ppdc(
1)
</a>. Once
579 imported, you can modify, localize, and regenerate the PPD files easily. Type
580 the following command to import the PPD file
<VAR>mydevice.ppd
</VAR> into the
581 driver information file
<VAR>mydevice.drv
</VAR>:
</P>
583 <pre class='command'
>
584 ppdi -o mydevice.drv mydevice.ppd
587 <P>If you have a whole directory of PPD files that you would like to import,
588 you can list multiple filenames or use shell wildcards to import more than one
589 PPD file on the command-line:
</P>
591 <pre class='command'
>
592 ppdi -o mydevice.drv mydevice1.ppd mydevice2.ppd
593 ppdi -o mydevice.drv *.ppd
596 <P>If the driver information file already exists, the new PPD
597 file entries are appended to the end of the file. Each PPD file
598 is placed in its own group of curly braces within the driver
599 information file.
</P>
602 <h2 class='title'
><a name='FILTERS'
>Using Custom Filters
</a></h2>
604 <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>
606 <pre class='example'
>
607 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-postscript
0 -
610 <h3>Custom Command Filters
</h3>
612 <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>
614 <pre class='example'
>
615 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-command
100 /path/to/command/filter
618 <p>To use the standard PostScript command filter, specify
<var>commandtops
</var> as the path to the command filter.
</p>
620 <h3>Custom PDF Filters
</h3>
622 <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>
624 <pre class='example'
>
625 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-pdf
100 /path/to/pdf/filter
628 <p>For unfiltered PDF files, use:
</p>
630 <pre class='example'
>
631 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/pdf
100 /path/to/pdf/filter
634 <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>
636 <h3>Custom PostScript Filters
</h3>
638 <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>
640 <pre class='example'
>
641 <a href='ref-ppdcfile.html#Filter'
>Filter
</a> application/vnd.cups-postscript
100 /path/to/postscript/filter
645 <h2 class='title'
><a name='COLOR'
>Implementing Color Management
</a></h2>
647 <p>CUPS uses ICC color profiles to provide more accurate color reproduction. The
<a href='spec-ppd.html#cupsICCProfile'
><tt>cupsICCProfile
</tt></a> attribute defines the color profiles that are available for a given printer, for example:
</p>
649 <pre class='example'
>
650 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> cupsICCProfile
"ColorModel.MediaType.Resolution/Description" /path/to/ICC/profile
653 <p>where
"ColorModel.MediaType.Resolution" defines a selector based on the corresponding option selections. A simple driver might only define profiles for the color models that are supported, for example a printer supporting Gray and RGB might use:
</p>
655 <pre class='example'
>
656 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> cupsICCProfile
"Gray../Grayscale Profile" /path/to/ICC/gray-profile
657 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> cupsICCProfile
"RGB../Full Color Profile" /path/to/ICC/rgb-profile
660 <p>The options used for profile selection can be customized using the
<tt>cupsICCQualifier2
</tt> and
<tt>cupsICCQualifier3
</tt> attributes.
</p>
663 <h2 class='title'
><a name='MACOSX'
>Adding OS X Features
</a></h2>
665 <p>OS X printer drivers can provide
<a href='spec-ppd.html#MACOSX'
>additional attributes
</a> to specify additional option panes in the print dialog, an image of the printer, a help book, and option presets for the driver software:
</p>
667 <pre class='example'
>
668 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> APDialogExtension
"" /Library/Printers/Vendor/filename.plugin
669 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> APHelpBook
"" /Library/Printers/Vendor/filename.bundle
670 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> APPrinterIconPath
"" /Library/Printers/Vendor/filename.icns
671 <a href='ref-ppdcfile.html#Attribute'
>Attribute
</a> APPrinterPreset
"name/text" "*option choice ..."