1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<title>Details of Ghostscript output devices</title> 5<!-- $Id: Devices.htm,v 1.90 2005/10/20 19:46:23 ray Exp $ --> 6<!-- Originally: devices.txt --> 7<link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style"> 8</head> 9 10<body> 11<!-- [1.0 begin visible header] ============================================ --> 12 13<!-- [1.1 begin headline] ================================================== --> 14 15<h1>Details of Ghostscript output devices</h1> 16 17<!-- [1.1 end headline] ==================================================== --> 18 19<!-- [1.2 begin table of contents] ========================================= --> 20 21<h2>Table of contents</h2> 22 23<blockquote><ul> 24<li><a href="#Measurements">Notes on measurements</a> 25<li><a href="#File_formats">Image file formats</a> 26<ul> 27<li><a href="#PNG">PNG file format</a> 28<li><a href="#JFIF">JPEG file format (JFIF)</a> 29<li><a href="#PNM">PNM file format</a> 30<li><a href="#TIFF">TIFF file formats</a> 31<li><a href="#fax">fax file formats</a> 32<li><a href="#BMP">BMP file format</a> 33<li><a href="#PCX">PCX file format</a> 34<li><a href="#PSD">PSD file format (DeviceN color model)</a> 35</ul> 36<li><a href="#High-level">High level formats</a> 37<ul> 38<li><a href="#PDF">PDF file output</a> 39<li><a href="#PS">PostScript file output</a> 40<li><a href="#EPS">EPS file output</a> 41<li><a href="#PXL">PCL-XL file output</a> 42</ul> 43<li><a href="#Display_devices">Display devices</a> 44<ul> 45<li><a href="#x11_devices">X Window System</a> 46<li><a href="#display_device">display device (MS Windows, OS/2, gtk+)</a> 47</ul> 48<li><a href="#IJS">IJS - Inkjet and other raster devices</a> 49<li><a href="#Rinkj">Rinkj - Resplendent inkjet driver</a> 50<li><a href="#HP_ijs">HP Deskjet official drivers</a> 51<li><a href="#gimp-print">Gimp-Print driver collection</a> 52<li><a href="#Win">MS Windows printers</a> 53<li><a href="#SPARCprinter">Sun SPARCprinter</a> 54<ul> 55<li><a href="#SPARC_install">Installation</a> 56<li><a href="#SPARC_problems">Problems</a> 57</ul> 58<li><a href="#Apple">Apple dot matrix printer</a> 59<li><a href="#Test">Test devices</a> 60<ul> 61<li><a href="#Permute">Permutation (DeviceN color model)</a> 62<li><a href="#SPOT">spotcmyk (DeviceN color model)</a> 63<li><a href="#XCF">XCF (DeviceN color model)</a> 64<li><a href="#bitraw">Raw 'bit' devices</a> 65</ul> 66</ul></blockquote> 67 68<!-- [1.2 end table of contents] =========================================== --> 69 70<!-- [1.3 begin hint] ====================================================== --> 71 72<p>For other information, see the <a href="Readme.htm">Ghostscript 73overview</a>. You may also be interested in <a href="Make.htm">how to 74build Ghostscript</a> and <a href="Install.htm">install it</a>, as well as 75the description of the <a href="Drivers.htm">driver interface</a>. 76 77<p>Documentation for some older, superceded devices has been moved to 78<a href="Deprecated.htm">another document</a>. In general such devices are deprecated 79and will be removed in future versions of Ghostscript. In general all older printer 80drivers can be replaced by the ijs interface and one of the available 3rd party raster 81driver collections. We recommend moving to the ijs device for all such printing.</p> 82 83<!-- [1.3 end hint] ======================================================== --> 84 85<hr> 86 87<!-- [1.0 end visible header] ============================================== --> 88 89<!-- [2.0 begin contents] ================================================== --> 90 91<h2><a name="Measurements"></a>Notes on measurements</h2> 92 93<p> 94Several different important kinds of measures appear throughout this 95document: inches, centimeters and millimeters, points, and bits per pixel. 96 97<dl> 98 99<dt>Centimeters and millimeters</dt> 100<dd>ISO standard paper sizes such as A4 and A3 are commonly represented in 101the SI units of centimeters and millimeters. Centimeters are abbreviated 102<dfn><abbr>cm</abbr></dfn>, millimeters <dfn><abbr>mm</abbr></dfn>. ISO A4 paper is 103quite close to 210×297 millimeters (approximately 8.3×11.7 104inches).</dd> 105 106<dt>Inches</dt> 107<dd>1 inch equals 2.54 centimeters. The inch measure is sometimes 108represented by <dfn><abr>in</abr></dfn> or a quotation mark (<abr>"</abr>) to the right 109of a measure, like 8.5in or 8.5". 110U.S. "letter" paper is exactly 1118.5in×11in, approximately 21.6cm×27.9cm. (See in the usage 112documentation all the <a href="Use.htm#Known_paper_sizes">paper sizes 113predefined in Ghostscript</a>.)</dd> 114 115<dt>Points</dt> 116<dd>Points are a measure traditionally used in the printing trade and now 117in PostScript, which specifies exactly 72 points per inch (approximately 11828.35 per centimeter). The <a href="Use.htm#Known_paper_sizes">paper sizes 119known to Ghostscript</a> are defined in the initialization file 120<tt>gs_statd.ps</tt> in terms of points.</dd> 121 122<dt>Dots per inch</dt> 123<dd>Dots per inch or <dfn><abbr>dpi</abbr></dfn> is the common measure of 124printing resolution in the US.</dd> 125 126<dt>Bits per pixel</dt> 127<dd>Commonly abbreviated <dfn><abbr>bpp</abbr></dfn> this is the number of 128digital bits used to represent the color of each pixel. This is also referred 129to as 'bit depth' or 'pixel depth'.</dd> 130 131</dl> 132 133<hr> 134 135<h2><a name="File_formats"></a>Image file formats</h2> 136 137<p> 138Ghostscript supports output to a variety of image file formats 139and is widely used for rasterizing postscript and pdf files. 140A collection of such formats ('output devices' in Ghostscript terminology) 141are described in this section. 142</p> 143 144<p> 145Here are some commonly useful driver options that apply to all raster drivers. 146Options specific to particular file formats are described in their respective 147sections below.</p> 148 149<blockquote><dl> 150 151<dt>-sOutputFile=<em>filename</em></dt> 152<dd><p>This is a general option telling Ghostscript what to name the output. 153It can either be a single filename '<tt>tiger.png</tt>' or a template 154'<tt>figure-%03d.jpg</tt>' where the <tt>%03d</tt> is replaced by the page number.</p> 155 156 157<dt>-r<em>res</em></dt> 158<dt>-r<em>xres</em>x<em>yres</em></dt> 159<dd><p>This option sets the resolution of the output file in dots per inch. 160The default value if you don't specify this options is usually 72 <abbr>dpi</abbr>.</p></dd> 161 162<dt>-dTextAlphaBits=<em>n</em></dt> 163<dt>-dGraphicsAlphaBits=<em>n</em></dt> 164<dd><p>These options control the use of subsample antialiasing. Their use is highly recommended 165for producing high quality rasterizations of the input files. The size of the subsampling 166box <em>n</em> should be 4 for optimum output, but smaller values can be used for faster 167rendering. Antialiasing is enabled separately for text and graphics content.</p></dd> 168 169</dl></blockquote> 170 171<p> 172It is also conventional to call Ghostscript with the '<tt>-dSAFER -dBATCH -dNOPAUSE</tt>' trio 173of options when rasterizing to a file. These suppress interactive prompts and enable some 174security checks on the file to be run. Please see the <a href="Use.htm">Use documentation</a> 175for a complete description. 176</p> 177 178<h3><a name="PNG"></a>PNG file format</h3> 179 180<p><acronym>PNG</acronym> (pronounced 'ping') stands for Portable Network Graphics, 181and is the recommended format for high-quality images. It supports full quality 182color and transparency, offers excellent lossless compression of the image data, 183and is widely supported. Please see the 184<a href="http://www.libpng.org/pub/png/pngintro.html" class="offsite">PNG website</a> 185for a complete description of the format.</p> 186 187<p>Ghostscript provides a variety of devices for <acronymn>PNG output 188varying by bit depth. For normal use we recommend <tt>png16m</tt> for 24-bit RGB color, 189or <tt>pnggray</tt> for grayscale. The png256, png16 and pngmono devices respectively 190provide 8-bit color, 4-bit color and black-and-white for special needs.</p> 191 192<p>The pngalpha device is 32-bit RGBA color with transparency 193indicating pixel coverage. The background is transparent unless 194it has been explicitly filled. PDF 1.4 transparent files do not 195give a transparent background with this device. Text and graphics 196anti-aliasing are enabled by default.</p> 197 198<h4>Options</h4> 199 200<p>The pngalpha device has one option. 201The other png devices have no special options.</p> 202 203<blockquote> 204<dl> 205<dt><b><tt>-dBackgroundColor=</tt></b><b><em>16#RRGGBB</em></b> (RGB color, default white = 16#ffffff) 206<dd>For the <tt>pngalpha</tt> device only, 207set the suggested background color in the PNG bKGD chunk. 208When a program reading a PNG file does not support alpha 209transparency, the PNG library converts the image using 210either a background color if supplied by the program 211or the bKGD chunk. 212One common web browser has this problem, so when using 213<b><tt><body bgcolor="CCCC00"></tt></b> on a web page 214you would need to use <b><tt>-dBackgroundColor=16#CCCC00</tt></b> 215when creating alpha transparent PNG images for use on the 216page. 217</dl> 218</blockquote> 219 220<h4>Examples</h4> 221 222<p>Examples of how to use Ghostscript to convert postscript to PNG image files: 223 224<blockquote> 225<pre> 226 <kbd>gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 \ 227 -sOutputFile=tiger.png examples/tiger.png</kbd> 228 229 <kbd>gs -dSAFER -dBATCH -dNOPAUSE -r150 -sDEVICE=pnggray -dTextAlphaBits=4 \ 230 -sOutputFile=doc-%02d.png doc.pdf</kbd> 231</pre> 232</blockquote> 233<p></p> 234 235<h3><a name="JFIF"></a>JPEG file format (JFIF)</h3> 236 237<p> 238Ghostscript includes output drivers that can produce jpeg files 239from postscript or pdf images. These are the <tt>jpeg</tt> and 240<tt>jpeggray</tt> devices. 241 242<p>Technically these produce <a href="http://www.ijg.org/">Independent JPEG Group</a> 243JFIF (JPEG File Interchange Format) files, the common sort found on the web.</p> 244 245<p><strong>Please note</strong> that 246JPEG is a compression method specifically intended for continuous-tone 247images such as photographs, not for graphics, and it is therefore quite 248unsuitable for the vast majority of page images produced with PostScript. 249For anything other than pages containing simple images the lossy compression 250of the jpeg format will result in poor quality output regardless of the input. 251To learn more about the distinction, consult a reference about uses and abuses of JPEG, 252such as the JPEG FAQ 253 254<blockquote> 255<a href="http://www.faqs.org/faqs/jpeg-faq/" class="offsite">http://www.faqs.org/faqs/jpeg-faq/</a> 256</blockquote> 257 258<h4>Examples</h4> 259 260<p> 261You can use the JPEG output drivers -- <b><tt>jpeg</tt></b> to produce 262color JPEG files and <b><tt>jpeggray</tt></b> for grayscale JPEGs -- the 263same as other file-format drivers: by specifying the device name and an 264output file name, for example 265 266<blockquote> 267<pre><kbd>gs -sDEVICE=jpeg -sOutputFile=foo.jpg foo.ps</kbd></pre> 268</blockquote> 269 270<h4>Options</h4> 271 272<p> 273The JPEG devices support several special parameters to control the JPEG 274"quality setting" (DCT quantization level).</p> 275 276<blockquote> 277<dl> 278<dt><b><tt>-dJPEGQ=</tt></b><b><em>N</em></b> (integer from 0 to 100, default 75) 279<dd>Set the quality level <b><em>N</em></b> according to the widely used 280IJG quality scale, which balances the extent of compression against the 281fidelity of the image when reconstituted. Lower values drop more 282information from the image to achieve higher compression, and therefore 283have lower quality when reconstituted. 284 285<dt><b><tt>-dQFactor=</tt></b><b><em>M</em></b> (float from 0.0 to 1.0) 286<dd>Adobe's QFactor quality scale, which you may use in place of 287<b><tt>JPEGQ</tt></b> above. The QFactor scale is used by PostScript's 288DCTEncode filter but is nearly unheard-of elsewhere. 289</dl> 290</blockquote> 291 292<p> 293At this writing the default JPEG quality level of 75 is equivalent to 294<b><tt>-dQFactor=0.5</tt></b>, but the JPEG default might change in the 295future. There is currently no support for any additional JPEG 296compression options, such as the other DCTEncode filter parameters. 297</p> 298 299 300<h3><a name="PNM"></a>PNM</h3> 301 302<p>The PNM (portable network map) family of formats are very simple 303uncompressed image formats commonly used on unix-like systems. They 304are particularly useful for testing or as input to an external conversion 305utility.</p> 306 307<p>A wide variety of data formats and depths is supported. Devices include 308<tt>pbm 309 pbmraw pgm pgmraw pgnm pgnmraw pnm pnmraw ppm ppmraw pkm pkmraw pksm 310 pksmraw</tt>. 311</p> 312 313<h3><a name="TIFF"></a>TIFF file formats</h3> 314 315<p><acronym>TIFF</acronym> is a loose collection of formats, now largely 316superceded by <acronym>PNG</acronym> except in applications where backward 317compatibility or special compression is required. The <acronym>TIFF</acronym> 318file format is described in the 319<a href="http://partners.adobe.com/asn/developer/pdfs/tn/TIFF6.pdf" class="offsite">TIFF 6.0 Specification</a> 320published by Adobe Systems Incorporated.</p> 321 322<p> 323There are two unrelated sets of TIFF drivers. There are five color TIFF 324drivers that produce uncompressed output: 325 326<blockquote> 327<dl> 328<dt><b><tt>tiffgray</tt></b> 329<dd>Produces 8-bit gray output. 330<dt><b><tt>tiff12nc</tt></b> 331<dd>Produces 12-bit RGB output (4 bits per component). 332<dt><b><tt>tiff24nc</tt></b> 333<dd>Produces 24-bit RGB output (8 bits per component). 334<dt><b><tt>tiff32nc</tt></b> 335<dd>Produces 32-bit CMYK output (8 bits per component). 336<dt><b><tt>tiffsep</tt></b> 337<dd> 338The tiffsep device creates multiple output files. The device creates a single 33932 bit composite CMYK file (tiff32nc format) and multiple tiffgray files. 340A tiffgray file is created for each separation. 341 342<p> 343The file specified via the OutputFile command line parameter will contain 344CMYK data. This data is based upon the CMYK data within the file plus 345an equivalent CMYK color for each spot colors which is present. The equivalent 346CMYK color for each spot colors is determined using the alternate tint transform 347function specified in Separation and DeviceN color spaces. Since 348this file is created based upon having color planes for each colorant, the 349file will correctly represent the appearance of overprinting with spot colors. 350 351<p> 352File names for the separations for the 353CMYK colorants are created by appending '.Cyan.tif', '.Magenta.tif' 354'.Yellow.tif' or '.Black.tif' to the to the end of the file name 355specified via the OutputFile parameter. File names for the spot 356color separation files are created by appending '.sn.tif' (where n 357is the spot color number, see below) to the end of the file name specified via 358the OutputFile parameter. 359 360<p> 361Internally each spot color is assigned a spot color number. These 362numbers start with 0 for the first spot color. The spot color 363numbers are assigned in the same order as the names are printed to 364stderr (see below). This order also matches the ordering in the 365SeparationColorNames list, if this parameter is specified. The 366spot color numbers are not affected by the SeparationOrder parameter. 367 368<p> 369The names of spot colors may be specified via the SeparationColorNames device 370parameters. Or the tiffsep device will automatically recognize spot color 371names if <b><tt>-dMaxSeparations=8</tt></b> is specified on the 372command line. 373 374<p> 375If only a subset of the colorants for a file is desired then the separations 376to be output can be selected via the SeparationOrder 377device parameter. When colorants are selected via the 378SeparationOrder parameter, the composite CMYK output contains 379the equivalent CMYK data only for the selected colorants. 380 381<p> 382The tiffsep device also prints the names of any spot colors 383detected within a document to stderr. (stderr is also use for the 384output from the bbox device.) For each spot color the name of 385the color is printed preceded by '%%SeparationName: '. This 386provides a simple mechanism for users and external applications to be informed about 387the names of spot colors with a document. 388 389<p> 390Ghostscript currently limits the size of a pixel to 64 bits. 391Since the tiffsep device uses 8 bits per colorant, the device can handle 392a maximum of 8 colorants per pass. However it is possible to 393handle more than 8 colorants by doing multiple passes. For each 394pass after the first one, the names of all of the separations need 395to be specified via the SeparationColorNames parameter and the 396names of the desired separations need to be specified via the 397SeparationOrder parameter. It is 398possible to create an overall CMYK composite for more than 8 399colorants by then adding together (via an external application like 400imagemagick) the composite CMYK output files from the individual 401Ghostscript passes. 402</dl> 403</blockquote> 404 405<p> 406The remaining TIFF drivers all produce black-and-white output with different 407compression modes: 408 409<blockquote> 410<dl> 411<dt><b><tt>tiffcrle</tt></b> 412<dd>G3 fax encoding with no EOLs 413<dt><b><tt>tiffg3</tt></b> 414<dd>G3 fax encoding with EOLs 415<dt><b><tt>tiffg32d</tt></b> 416<dd>2-D G3 fax encoding 417<dt><b><tt>tiffg4</tt></b> 418<dd>G4 fax encoding 419<dt><b><tt>tifflzw</tt></b> 420<dd>LZW-compatible (tag = 5) compression 421<dt><b><tt>tiffpack</tt></b> 422<dd>PackBits (tag = 32773) compression 423</dl> 424</blockquote> 425 426 427<h4>Options</h4> 428 429<p> 430The black-and-white TIFF drivers support creation of files that are 431comprised of more than a single strip. Multi-strip files reduce the memory 432requirement on the reader, since readers need only store and process one 433strip at a time. These drivers provide two parameters beyond the standard 434set: 435 436<blockquote> 437<dl> 438<dt><b><tt>-dMaxStripSize=</tt><em>N</em></b> (non-negative integer; default = 0) 439<dd>Set the maximum (uncompressed) size of a strip. 440 441<dt><b><tt>-dAdjustWidth</tt><em>state</em></b> (0 or 1; default = 1) 442<dd>If this option set then if the requested page width is close to either A4 (1728 columns) or B4 (2048 columns), set the page width to A4 or B4 respectively. 443This behavior is the default. Pass -dAdjustWidth=0 to turn off this behavior. 444</dl></blockquote> 445 446<p> 447The TIFF 6.0 specification, Section 7, page 27, recommends that the size of 448each strip be about 8 Kbytes. As an example, to generate the 'tiger' in 449tiffg4 format that has the recommended strip size, use: 450 451<blockquote><pre> 452gs -sDEVICE=tiffg4 -sOutputFile=tiger.tiff -dMaxStripSize=8192 examples/tiger.eps 453</pre></blockquote> 454 455<p> 456If the value of the <tt>MaxStripSize</tt> parameter is smaller than a 457single image row, then no error will be generated, and the TIFF file will be 458generated correctly using one row per strip. Note that smaller strip sizes 459increase the size of the file by increasing the size of the StripOffsets and 460StripByteCounts tables, and by reducing the effectiveness of the compression 461which must start over for each strip. 462 463<p> 464If the value of MaxStripSize is 0 (the default), then the entire image will 465be a single strip. 466 467<p> 468Since v. 8.51 the logical order of bits within a byte, FillOrder, tag = 266 is 469controlled by a parameter: 470 471<blockquote> 472<dl> 473<dt><b><tt>-dFillOrder=</tt><em>1 | 2 </em></b> (default = 1) 474<dd>If this option set to 2 then pixels are arranged within a byte such that pixels 475with lower column values are stored in the lower-order bits of the byte; otherwise 476pixels are arranged in reverse order. 477</dl></blockquote> 478 479Earlier versions of Ghostscript always generated TIFF files with FillOrder = 2. 480According to the TIFF 6.0 specification, Section 8, page 32, support of 481FillOrder = 2 is not required in a Baseline TIFF compliant reader 482 483<h3><a name="fax"></a>FAX</h3> 484 485<p> 486Ghostscript supports a variety of fax encodings, both encapsulated in 487<acronym>TIFF</acronym> (see above) and as raw files. The later case is 488described here. 489</p> 490 491<p> 492The fax devices are <tt>faxg3</tt>, <tt>faxg32d</tt> and <tt>faxg4</tt>. 493</p> 494 495<h3><a name="BMP"></a>BMP</h3> 496 497<p> 498BMP is a simple uncompressed image format commonly used on MS Windows. 499It is supported by the devices <tt>bmpmono bmpgray bmpsep1 500 bmpsep8 bmp16 bmp256 bmp16m bmp32b</tt>. 501</p> 502 503<h3><a name="PCX"></a>PCX</h3> 504 505<p> 506PCX is an image format sometimes used on MS Windows. It has some support 507for image compression and alternate color spaces, and so can be a useful 508way to output CMYK. 509It is supported by the <tt>pcxmono pcxgray pcx16 pcx256 pcx24b pcxcmyk</tt> 510series of devices. 511</p> 512 513<h3><a name="PSD"></a>PSD</h3> 514 515<p> 516PSD is the image format used by Adobe Photoshop. 517It is supported by the <tt>psdcmyk</tt> and <tt>psdrgb</tt> devices. 518Of special interest with the <tt>psdcmyk</tt> device is that it supports spot 519colors. The names of the spot colors 520must be specified prior to opening a page. This can be done via adding the 521following to the command line: <b><tt>-c "<< /SeparationColorNames [ /Name1 /Name2 ] 522>> setpagedevice" -f</tt></b>. The <tt>psdcmyk</tt> device will support up to four 523spot colors. 524To view the results properly, a color needs to be assigned to each of 525the spot color planes within Photoshop. (Ghostscript assigns black as 526the default color for all spot colors in the psdcmyk device.) 527 528 529 530</p> 531 532<h2><a name="High-level"></a>High-level devices</h2> 533 534<p> 535In addition to raster image files, Ghostscript supports output in a number 536of 'high-level' formats. These allow Ghostscript to preserve (as much as 537possible) the drawing elements of the input file maintaining flexibility, 538resolution independence, and editability.</p> 539 540<h3><a name="PDF"></a>PDF writer</h3> 541 542<p>The <tt>pdfwrite</tt> device outputs PDF. Please refer to 543<a href="Ps2pdf.htm">Ps2pdf.htm</a> for the extensive <tt>pdfwrite</tt> 544device options.</p> 545 546<h3><a name="PS"></a>PS writer</h3> 547 548<p>The <tt>pswrite</tt> device outputs postscript.</p> 549 550<h4>Options</h4> 551 552<blockquote> 553<dl> 554<dt><b><tt>-dLanguageLevel=</tt><em>1 | 1.5 | 2 | 3</em></b> (default is 2) 555<dd>Set the language level of the generated file. 556Language level 1.5 is language level 1 with color extensions. 557Currently language level 3 generates the same PostScript as 2. 558</dl></blockquote> 559 560<h3><a name="EPS"></a>EPS writer</h3> 561 562<p>The <tt>epswrite</tt> device outputs encapsulated postscript.</p> 563 564<h4>Options</h4> 565 566<blockquote> 567<dl> 568<dt><b><tt>-dLanguageLevel=</tt><em>1 | 1.5 | 2 | 3</em></b> (default is 2) 569<dd>Set the language level of the generated file. 570Language level 1.5 is language level 1 with color extensions. 571Currently language level 3 generates the same PostScript as 2. 572</dl></blockquote> 573 574<h3><a name="PXL"></a>PXL</h3> 575 576<p>The <tt>pxlmono</tt> and <tt>pxlcolor</tt> devices output HP PCL-XL, 577a graphic language understood by many recent laser printers. 578 579<p> 580 581<hr> 582 583<h2><a name="Display_devices"></a>Display Devices</h2> 584 585<p> 586Ghostscript is often used for screen display of postscript and pdf documents. 587In many cases, a client or 'viewer' application calls the Ghostscript engine 588to do the rasterization and handles the display of the resulting image itself, 589but it is also possible to invoke Ghostscript directly and select an output 590device which directly handles displaying the image on screen. 591 592<p> 593This section describes the various display-oriented devices that are available 594in Ghostscript. 595 596<h3><a name="x11_devices"></a>X Window System</h3> 597 598<p> 599Perhaps the most common use of of a display device is with the X Window System 600on unix-like systems. It is the default device on the command line client on 601such systems, and is used more creatively by the gv client application. 602 603<p> 604The available devices are: 605 606<dl> 607<dt><b>x11</b> 608<dd>This is the default device, handling display on X11R6. 609 610<dt><b>x11alpha</b> 611<dd>This is the x11 device, but with antialiasing. It is equivalent to 612invoking the x11 device with the options <tt>-dGraphicsAlphaBits=4 613-dTextAlphaBits=4 -dMaxBitmap=50000000</tt>. 614 615<dt><b>x11cmyk</b> 616<dd>This device rasterizes the image in the CMYK color space, then flattens 617it to RGB for display. It's intended for testing only. 618 619<dt><b>x11mono</b> 620<dd>This is a strict black-and-white device for 1-bit monochrome displays. 621 622<dt><b>x11gray2</b> 623<dd>This is a device for 2 bpp (4-level) monochrome displays. 624 625<dt><b>x11gray4</b> 626<dd>This is a device for 4 bpp (16-level) monochrome displays. 627</dl> 628 629<h3><a name="display_device"></a>display device (MS Windows, OS/2, gtk+)</h3> 630<p> 631The <b><tt>display</tt></b> device is used by the MS Windows, 632OS/2 and the gtk+ versions of ghostscript. 633</p> 634 635<h4>Options</h4> 636 637<p>The display device has several user settable options.</p> 638 639<blockquote> 640<dl> 641<dt><b><tt>-dDisplayFormat=</tt></b><b><em>N</em></b> (integer bit-field) 642<dd>Some common values are 16#30804 for Windows RGB, 16#804 for gtk+ RGB, 64316#20101 for Windows monochrome, 16#102 for gtk+ monochrome, 64416#20802 grayscale, 16#20808 for CMYK, 16#a0800 for separations. 645The bit fields are 646<ul> 647<li> native (1), gray (2), RGB (4), CMYK (8), or separation (80000) 648 color spaces. 649<li> unused first byte (40) or last byte (80). 650<li> 1 (100), 4 (400), or 8 (800) bits/component. 651<li> bigendian (00000 = RGB) or littleendian (10000 = BGR) order. 652<li> top first (20000) or bottom first (00000) raster. 653<li> 16 bits/pixel with 555 (00000) or 565 (40000) bitfields. 654</ul> 655For more details, see the <a href="API.htm#display">Ghostscript 656Interpreter API.</a> 657<dt><b><tt>-dDisplayResolution=</tt></b><b><em>DPI</em></b> 658<dd>Set the initial resolution resolution for the display device. 659This is used by the Windows clients to set the display device 660resolution to the Windows display logical resolution. 661This can be overriden by the command line option 662<b><tt>-r</tt><em>DPI</em></b>. 663</dl> 664 665</blockquote> 666 667When using the separation color space, the following options may be set 668using setpagedevice, as described in the PostScript Language Reference: 669 670<blockquote> 671<dl> 672<dt><b><tt>SeparationColorNames</tt></b> 673<dd>An array giving the names of the spot colors 674 675<dt><b><tt>SeparationOrder</tt></b> 676<dd>An array giving the names and order of the colorants 677to be output. 678</dl> 679</blockquote> 680 681 682<hr> 683 684<h2><a name="IJS"></a>IJS - Inkjet and other raster devices</h2> 685 686<p> 687IJS is a relatively new initiative to improve the quality and ease of 688use of inkjet printing with Ghostscript. Using IJS, you can add new 689drivers, or upgrade existing ones, without recompiling Ghostscript. 690All driver authors are encouraged to adapt their drivers for IJS, and 691if there is an IJS driver available for your printer, it should be 692your first choice. 693</p> 694 695<p>Please see the <a href="http://www.linuxprinting.org/ijs/">IJS web 696page</a> for more information about IJS, including a listing of 697IJS-compatible drivers. 698</p> 699 700<p> 701A typical command line for IJS is: 702</p> 703 704<blockquote> 705<b><tt> 706gs -dSAFER -sDEVICE=ijs -sIjsServer=hpijs 707 -sDeviceManufacturer=HEWLETT-PACKARD -sDeviceModel='DESKJET 990' 708 -dIjsUseOutputFD -sOutputFile=/dev/usb/lp1 -dNOPAUSE -- 709 examples/tiger.eps 710</tt></b> 711</blockquote> 712 713 714<p> 715Individual IJS command line parameters are as follows: 716</p> 717 718<dl> 719<dt><b><tt>-sIjsServer=</tt></b><em>{path}</em> 720<dd>Sets the pathname for the IJS server (ie printer driver). 721Ghostscript will spawn a new process for this driver, and communicate 722with it using the IJS protocol. The pathname need not be absolute, 723as the PATH environment variable is searched, but it's probably a good 724idea for robustness and security. Note also that if -dSAFER is not 725specified, it's possible for PostScript code to set this parameter, 726so it can cause arbitrary code to be executed. See the section on <a 727href="Use.htm#Security">Security</a> for more information. 728</dl> 729 730<dl> 731<dt><b><tt>-sDeviceManufacturer=</tt></b><em>{name}</em> 732<dt><b><tt>-sDeviceModel=</tt></b><em>{name}</em> 733<dd>These parameters select the device according to IEEE-1284 standard 734device ID strings. In general, consult the documentation for the 735driver to find the appropriate settings. Note that, if the value 736contains a space, you'll want to quote the value in your shell, as 737in the example above. 738</dl> 739 740<dl> 741<dt><b><tt>-sIjsParams=</tt></b><em>{params}</em> 742<dd>This parameter allows you to set arbitrary IJS parameters on 743the IJS driver. The format is a comma-separated list of 744<b><tt>key=value</tt></b> pairs. If it is necessary to send a 745value containing a comma or backslash, it can be escaped with 746a backslash. Thus, <b><tt>'-sIjsParams=Foo=bar,Baz=a\,b'</tt></b> sets 747the parameter Foo to "bar", and Baz to "a,b". 748</dl> 749 750<dl> 751<dt><b><tt>-dIjsUseOutputFD</tt></b> 752<dd>This flag indicates that Ghostscript should open the output file 753and pass a file descriptor to the server. If not set, Ghostscript 754simply passes the filename set in OutputFile to the server. In most 755cases, this flag won't matter, but if you have a driver which works 756only with OutputFD (such as hpijs 1.0.2), or if you're using the 757-sOutputFile="|cmd" syntax, you'll need to set it. 758</dl> 759 760<dl> 761<dt><b><tt>-dBitsPerSample=</tt></b><em>N</em> 762<dd>This parameter controls the number of bits per sample. The 763default value of 8 should be appropriate for most work. For monochrome 764images, use -dBitsPerSample=1. 765</dl> 766 767<p>Generic Ghostscript options that are particularly relevant for IJS 768are summarized below: 769</p> 770 771<dl> 772<dt><b><tt>-r</tt></b><em>number</em> 773<br><b><tt>-r</tt></b><em>number1</em><b><tt>x</tt></b><em>number2</em> 774<dd>Sets the resolution, in dpi. If the resolution is not specified, 775Ghostscript queries the IJS server to determine the preferred resolution. 776When the resolution is specified, it overrides the value (if any) 777preferred by the IJS server. 778</dl> 779 780<dl> 781<dt><b><tt>-dDuplex</tt></b> 782<dt><b><tt>-dTumble</tt></b> 783<dd>These flags enable duplex (two-sided) printing. Tumble controls 784the orientation. When Tumble is false, the pages 785are oriented suitably at the left or right. When Tumble is true, 786the pages are oriented suitably for binding at the top or 787bottom. 788</dl> 789 790<dl> 791<dt><b><tt>-sProcessColorModel=</tt></b><em>{name}</em> 792<dd>Use this flag to select the process color model. Suitable values 793include DeviceGray, DeviceRGB, and DeviceCMYK. 794</dl> 795 796<h3>Building IJS</h3> 797 798<p> IJS is included by default on Unix gcc builds, and also in 799autoconf'ed builds. Others may need some makefile tweaking. First, 800make sure the IJS device is selected: 801 802<blockquote> 803DEVICE_DEVS2=$(DD)ijs.dev 804</blockquote> 805 806<p> Next, make sure that the path and execution type are set in 807the top level makefile. The values for Unix are as follows: 808 809<blockquote> 810IJSSRCDIR=ijs 811IJSEXECTYPE=unix 812</blockquote> 813 814<p> At present, "unix" and "win" are the only supported values for 815IJSEXECTYPE. If neither sounds appropriate for your system, it's 816possible that more porting work is needed. 817 818<p> Last, make sure that ijs.mak is included in the top level makefile. 819It should be present right after the include of icclib.mak. 820 821<p> IJS is not inherently platform-specific. We're very much interested 822in taking patches from people who have ported it to non-mainstream 823platforms. And once it's built, you won't have to recompile Ghostscript 824to support new drivers! 825 826<h2><a name="Rinkj"></a>Rinkj - Resplendent inkjet driver</h2> 827 828<p>The Rinkj driver is an experimental new driver, capable of driving 829some Epson printers at a very high level of quality. It is not 830currently recommended for the faint of heart.</p> 831 832<p>You will need to add the following line to your makefile: 833 834<blockquote> 835DEVICE_DEVS2=$(DD)rinkj.dev 836</blockquote> 837 838<p>Most of the configuration parameters, including resolution, choice 839of printer model, and linearization curves, are in a separate setup 840file. In addition, we rely heavily on an ICC profile for mapping 841document colors to actual device colors.</p> 842 843<p>A typical command line invocation is:</p> 844 845<blockquote><tt> 846gs -r1440x720 -sDEVICE=rinkj -sOutputFile=/dev/usb/lp0 847 -sSetupFile=lib/rinkj-2200-setup -sProfileOut=2200-cmyk.icm 848 -dNOPAUSE -dBATCH file.ps 849</tt></blockquote> 850 851<p> 852Individual Rinkj command line parameters are as follows: 853</p> 854 855<dl> 856<dt><b><tt>-sSetupFile=</tt></b><em>{path}</em> 857<dd>Specifies the path for the setup file. 858 859<dt><b><tt>-sProfileOut=</tt></b><em>{path}</em> 860<dd>Specifies the path for the output ICC profile. This profile should 861be a <i>link</i> profile, mapping the ProcessColorModel (DeviceCMYK by 862default) to the device color space. 863</dl> 864 865<p>For 6- and 7-color devices, the target color space for the output 866profile is currently a 4-component space. The conversion from this 867into the 6- or 7-color space (the "ink split") is done by lookup 868tables in the setup file.</p> 869 870<p>Setup files are in a simple "Key: value" text format. Relevant keys 871are:</p> 872 873<dl> 874<dt><b><tt>Manufacturer:</tt></b><em>{name}</em> 875<dt><b><tt>Model:</tt></b><em>{name}</em> 876<dd>The manufacturer and model of the individual device, using the 877same syntax as IEEE printer identification strings. Currently, the 878only supported manufacturer string is "EPSON", and the only supported 879model strings are "Stylus Photo 2200" and "Stylus Photo 7600". 880 881<dt><b><tt>Resolution:</tt></b><em>{x-dpi}</em>x<em>{y-dpi}</em> 882<dd>The resolution in dpi. Usually, this should match the 883Ghostscript resolution set with the <tt>-r</tt> switch. Otherwise, 884the page image will be scaled. 885 886<dt><b><tt>Dither:</tt></b><em>{int}</em> 887<dd>Selects among variant dither options. Currently, the choices are 888<tt>1</tt> for one-bit dither, and <tt>2</tt>, for a 2-bit variable 889dot dither. 890 891<dt><b><tt>Aspect:</tt></b><em>{int}</em> 892<dd>Controls the aspect ratio for highlight dot placement. Valid 893values are <tt>1</tt>, <tt>2</tt>, and <tt>4</tt>. For best results, 894choose a value near the x resolution divided by the y resolution. For 895example, if resolution is 1440x720, aspect should be 2. 896 897<dt><b><tt>Microdot:</tt></b><em>{int}</em> 898<dd>Chooses a microdot size. On EPSON devices, this value is passed 899directly through to the "ESC ( e" command. See EPSON documentation 900for further details (see, I <em>told</em> you this wasn't for the 901faint of heart). 902 903<dt><b><tt>Unidirectional:</tt></b><em>{int}</em> 904<dd>Enables (1) or disables (0) unidirectional printing, which is 905slower but possibly higher quality. 906 907<dt><b><tt>AddLut:</tt></b><em>{plane}</em> 908<dd>Adds a linearization look-up table. The plane is one of 909"CcMmYKk". The lookup table data follows. The line immediately 910following AddLut is the number of data points. Then, for each data 911point is a line consisting of two space-separated floats - the output 912value and the input value. If more than one LUT is specified for a 913single plane, they are applied in sequence. 914</dl> 915 916<p>A typical setup file is supplied in <tt>lib/rinkj-2200-setup</tt>. 917It is configured for the 2200, but can be adapted to the 7600 just by 918changing the "Model" line. 919 920<p>In addition, sample profiles are available at <a href="http://artofcode.com/rinkj/profiles/">artofcode.com/rinkj/profiles/</a>. 921 922<p>A known issue with this driver is poor support for margins and 923page size. In some cases, this will cause an additional page to be 924ejected at the end of a job. You may be able to work around this by 925supplying a cut-down value for <tt>-dDEVICEHEIGHTPOINTS</tt>, for 926example 755 for an 8.5x11 inch page on the EPSON 2200.</p> 927 928<h2><a name="HP_ijs"></a>HP Deskjet official drivers</h2> 929 930<p> 931HP provides official drivers for many of their Deskjet printer models. 932In order to use these drivers, you will need the HP Inkjet Server as 933well as Ghostscript, available from <a 934href="http://hpinkjet.sourceforge.net">http://hpinkjet.sourceforge.net</a>. 935This version of Ghostscript includes the patch from version 0.97 of 936the hpijs software. If you are installing hpijs from an RPM, you will 937only need the hpijs RPM, not the Ghostscript-hpijs one, as the code 938needed to work with hpijs is already included. 939 940<p> 941Note that newer version of the hpijs drivers support the IJS protocol. 942If you can, you should consider using the ijs driver instead. Among 943other things, the hpijs Ghostscript driver is Unix-only, and is untested 944on older Unix platforms. 945 946<p> 947As of the 0.97 version, hpijs supports the following printer models: 948 949<dl><dt><b>e-Series:</b> 950 <dd>e-20 951<dt><b>DeskJet 350C Series:</b> 952 <dd>350C 953<dt><b>DeskJet 600C Series:</b> 954 <dd>600C, 660C, 670/672C, 670TV, 680/682C 955<dt><b>DeskJet 600C Series Photo:</b> 956 <dd>610/612C, 640/648C, 690/692/693/694/695/697C 957<dt><b>DeskJet 630C Series:</b> 958 <dd>630/632C 959<dt><b>DeskJet 800C Series:</b> 960 <dd>810/812C, 830/832C, 840/842/843C, 880/882C, 895C 961<dt><b>DeskJet 900C Series, PhotoSmart::</b> 962 <dd>930/932C, 950/952C, 970C, PhotoSmart 1000/1100 963<dt><b>DeskJet 990C, PhotoSmart:</b> 964 <dd>960C, 980C, 990C, PhotoSmart 1215/1218 965 966</dl> 967 968<p>You will need to add the following line to your makefile: 969 970<blockquote> 971DEVICE_DEVS2=$(DD)DJ630.dev $(DD)DJ6xx.dev $(DD)DJ6xxP.dev $(DD)DJ8xx.dev $(DD)DJ9xx.dev $(DD)DJ9xxVIP.dev $(DD)AP21xx.dev 972</blockquote> 973 974<p> 975Please see <a 976href="http://hpinkjet.sourceforge.net">http://hpinkjet.sourceforge.net</a> 977for more information about this driver. Thanks to the folks at HP, 978especially David Suffield for making this driver available and working to 979integrate it with Ghostscript. 980</p> 981 982<h2><a name="gimp-print"></a>Gimp-Print driver collection</h2> 983 984<p> 985The Gimp-Print project provides a large collection of printer drivers 986with an IJS interface. Please see their 987<a href="http://gimp-print.sourceforge.net/" class="offsite">website</a> 988for details. 989</p> 990 991<hr> 992<h2><a name="Win"></a>MS Windows printers</h2> 993 994<p> 995This section was written by Russell Lang, the author of Ghostscript's 996MS Windows-specific printer driver, and updated by 997<a href="mailto:Pierre.Arnaud@opac.ch">Pierre Arnaud</a>, 998the current maintainer. 999</p> 1000 1001<p> 1002The <b><tt>mswinpr2</tt></b> device uses MS Windows printer drivers, and 1003thus should work with any printer with device-independent bitmap (DIB) 1004raster capabilities. The printer resolution cannot be selected directly 1005using PostScript commands from Ghostscript: use the printer setup in the 1006Control Panel instead. It is however possible to specify a maximum resolution 1007for the printed document (see below). 1008</p> 1009 1010<p> 1011If no Windows printer name is specified in <b><tt>-sOutputFile</tt></b>, 1012Ghostscript prompts for a Windows printer using the standard Print Setup 1013dialog box. You must set the orientation to Portrait and the page size to 1014that expected by Ghostscript; otherwise the image will be clipped. 1015Ghostscript sets the physical device size to that of the Windows printer 1016driver, but it does not update the PostScript clipping path. 1017</p> 1018 1019<p> 1020If a Windows printer name is specified in <b><tt>-sOutputFile</tt></b> using 1021the format <tt>"%printer%printer_name"</tt>, for instance 1022</p> 1023 1024<blockquote><b><tt> 1025gs ... -sOutputFile="%printer%Apple LaserWriter II NT" 1026</tt></b></blockquote> 1027 1028<p> 1029then Ghostscript attempts to open the Windows printer without prompting 1030(except, of course, if the printer is connected to <b><tt>FILE:</tt></b>). 1031Ghostscript attempts to set the Windows printer page size and orientation 1032to match that expected by Ghostscript, but doesn't always succeed. It uses 1033this algorithm: 1034</p> 1035 1036<ol> 1037<li>If the requested page size matches one of the Windows standard page 1038sizes +/- 2mm, request that standard size.</li> 1039 1040<li>Otherwise if the requested page size matches one of the Windows 1041standard page sizes in landscape mode, ask for that standard size in 1042landscape.</li> 1043 1044<li>Otherwise ask for the page size by specifying only its dimensions.</li> 1045 1046<li>Merge the requests above with the defaults. If the printer driver 1047ignores the requested paper size, no error is generated: it will print on 1048the wrong paper size.</li> 1049 1050<li>Open the Windows printer with the merged orientation and size.</li> 1051</ol> 1052 1053<p> 1054The Ghostscript physical device size is updated to match the Windows 1055printer physical device. 1056</p> 1057 1058<h3><a name="Win_properties"></a>Supported command-line parameters</h3> 1059 1060<p> 1061The <b><tt>mswinpr2</tt></b> device supports a limited number of command-line 1062parameters (e.g. it does not support setting the printer resolution). The 1063recognized parameters are the following: 1064</p> 1065 1066<blockquote> 1067<dl> 1068<dt><b><tt>-sDEVICE=mswinpr2</tt></b></dt> 1069<dd>Selects the MS Windows printer device. If Ghostscript was not 1070compiled with this device as the default output device, you have to specify 1071it on the command line.</dd> 1072 1073<dt><b><tt>-dNoCancel</tt></b></dt> 1074<dd>Hides the progress dialog, which shows the percent of the document page 1075already processed and also provides a <em>cancel</em> button. This option 1076is useful if GS is intended to print pages in the background, without any 1077user intervention.</dd> 1078 1079<dt><b><tt>-sOutputFile=</tt></b><b>"%printer%<em>printer_name</em>"</b></dt> 1080<dd>Specifies which printer should be used. The <em>printer_name</em> should be 1081typed exactly as it appears in the Printers control panel, including spaces.</dd> 1082 1083</dl> 1084</blockquote> 1085 1086<h3><a name="Win_options"></a>Supported options (device properties)</h3> 1087 1088<p> 1089Several extra options exist which cannot be set through the command-line, 1090but only by executing the appropriate PostScript setup code. These options 1091can be set through the inclusion of a setup file on the command-line: 1092</p> 1093 1094<blockquote><b><tt> 1095gs ... setup.ps ... 1096</tt></b></blockquote> 1097 1098<p> 1099The <tt>setup.ps</tt> file is responsible for the device selection, therefore 1100you should not specify the <b><tt>-sDEVICE=mswinpr2</tt></b> option on the 1101command-line if you are using such a setup file. Here is an example of such 1102a setup file: 1103</p> 1104 1105<blockquote><pre> 1106mark 1107 /NoCancel true % don't show the cancel dialog 1108 /BitsPerPixel 4 % force 4 bits/pixel 1109 /UserSettings 1110 << 1111 /DocumentName (Ghostscript document) % name for the Windows spooler 1112 /MaxResolution 360 % maximum document resolution 1113 >> 1114 (mswinpr2) finddevice % select the Windows device driver 1115 putdeviceprops 1116setdevice 1117</pre></blockquote> 1118 1119<p> 1120This example disables the progress dialog (same as the <tt><b>-dNoCancel</b></tt> 1121option), forces a 4 bits/pixel output resolution and specifies additional user 1122settings, such as the document name (which will be displayed by the Windows 1123spooler for the queued document) and the maximum resolution (here 360 dpi). 1124It then finds and selects an instance of the MS Windows device printer 1125and activates it. This will show the standard printer dialog, since no 1126<tt><b>/OutputFile</b></tt> property was specified. 1127</p> 1128 1129<p> 1130The following options are available: 1131</p> 1132 1133<blockquote> 1134<dl> 1135<dt><b><tt>/NoCancel <em>boolean</em></tt></b></dt> 1136<dd>Disables (hides) the progress dialog when set to <em><tt>true</tt></em> or 1137show the progress dialog if not set or set to <em><tt>false</tt></em>.</dd> 1138 1139<dt><b><tt>/OutputFile <em>string</em></tt></b></dt> 1140<dd>Specifies which printer should be used. The string should be of the form 1141<tt><b>%printer%<em>printer_name</em></b></tt>, where the <em>printer_name</em> should be 1142typed exactly as it appears in the Printers control panel, including spaces.</dd> 1143 1144<dt><b><tt>/QueryUser <em>integer</em></tt></b></dt> 1145<dd>Shows the standard printer dialog (<tt><b>1</b></tt> or any other value), 1146shows the <em>printer setup dialog</em> (<tt><b>2</b></tt>) or selects the 1147<em>default Windows printer</em> without any user interaction (<tt><b>3</b></tt>).</dd> 1148 1149<dt><b><tt>/BitsPerPixel <em>integer</em></tt></b></dt> 1150<dd>Sets the device depth to the specified bits per pixel. Currently supported 1151values are <tt><b>1</b></tt> (monochrome), <tt><b>4</b></tt> (CMYK with screening 1152handled by Ghostscript) and <tt><b>24</b></tt> (True Color, dithering handled by 1153the Windows printer driver; this option can produce huge print jobs).</dd> 1154 1155<dt><b><tt>/UserSettings <em>dict</em></tt></b></dt> 1156<dd>Sets additional options, defined in a dictionary. The following properties can 1157be set: 1158 1159<dl> 1160<dt><b><tt>/DocumentName <em>string</em></tt></b></dt> 1161<dd>Defines the user friendly document name which will be displayed by the 1162Windows spooler.</dd> 1163 1164<dt><b><tt>/DocumentRange <em>[n1 n2]</em></tt></b></dt> 1165<dd>Defines the range of pages contained in the document. This information can 1166be used by the printer dialog, in conjunction with the following property.</dd> 1167 1168<dt><b><tt>/SelectedRange <em>[n1 n2]</em></tt></b></dt> 1169<dd>Defines the selected range of pages. This information will be displayed in 1170the printer dialog and will be updated after the user interaction. A PostScript 1171program could check these values and print only the selected page range.</dd> 1172 1173<dt><b><tt>/MaxResolution <em>dpi</em></tt></b></dt> 1174<dd>Specifies the maximum tolerated output resolution. If the selected printer has 1175a higher resolution than <tt><b>dpi</b></tt>, then Ghostscript will render the 1176document with a submultiple of the printer resolution. For example, if 1177<tt><b>MaxResolution</b></tt> is set to 360 and the output printer supports 1178up to 1200 dpi, then Ghostscript renders the document with an internal 1179resolution of 1200/4=300 dpi. This can be very useful to reduce the memory 1180requirements when printing in True Color on some high resolution ink-jet color 1181printers.</dd> 1182 1183</dl></dd> 1184 1185</dl> 1186</blockquote> 1187 1188<p> 1189These properties can be queried through the <tt><b>currentpagedevice</b></tt> 1190operator. The following PostScript code snippet shows how to do it for some 1191of the properties: 1192</p> 1193 1194<blockquote><pre> 1195currentpagedevice /BitsPerPixel get == % displays the selected depth 1196 1197currentpagedevice /UserSettings get % get the additional options.. 1198/us exch def % ..and assign them to a variable 1199 1200us /DocumentName get == % displays the document name 1201us /SelectedRange get == % displays the selected page range 1202 1203% other misc. information (don't rely on them) 1204 1205us /Color get == % 1 => monochrome output, 2 => color output 1206us /PrintCopies get == % displays the number of copies requested 1207</pre></blockquote> 1208 1209<p> 1210There are a few undocumented parameters stored in the <tt><b>UserSettings</b></tt> 1211dictionary. You should not rely on them. Their use is still experimental and 1212they could be removed in a future version. 1213</p> 1214 1215<h3><a name="Win_duplex"></a>Duplex printing</h3> 1216 1217<p> 1218If the Windows printer supports the duplex printing feature, then it will 1219also be available through the <b><tt>mswinpr2</tt></b> device. You can query 1220for this support through the <b><tt>/Duplex</tt></b> property of the 1221<b><tt>currentpagedevice</tt></b>. If it returns <b><tt>null</tt></b>, then 1222the feature is not supported by the selected printer. Otherwise, <b><tt>true</tt></b> 1223means that the printer is currently set up to print on both faces of the paper 1224and <b><tt>false</tt></b> that it is not, but that it can. 1225</p> 1226 1227<p> 1228The following example shows how to print on both faces of the paper (using 1229the long side of the paper as the reference): 1230</p> 1231 1232<blockquote><pre> 1233<< /Duplex true /Tumble false >> setpagedevice 1234</pre></blockquote> 1235 1236<p> 1237</p> 1238 1239 1240<hr> 1241 1242<h2><a name="SPARCprinter"></a>Sun SPARCprinter</h2> 1243 1244<p> 1245This section was contributed by Martin Schulte. 1246 1247<p> 1248With a SPARCprinter you always buy software that enables you to do 1249PostScript printing on it. A page image is composed on the host, which 1250sends a bitmap to the SPARCprinter through a special SBUS video interface. 1251So the need for a Ghostscript interface to the SPARCPrinter seems low, but 1252on the other hand, Sun's software prints some PostScript drawings 1253incorrectly: some pages contain a thin vertical line of rubbish, and on 1254some Mathematica drawings the text at the axes isn't rotated. Ghostscript, 1255however, gives the correct results. Moreover, replacing proprietary 1256software should never be a bad idea. 1257 1258<p> 1259The problem is that there has yet been no effort to make the SPARCPrinter 1260driver behave like a BSD output filter. I made my tests using the script 1261shown here. 1262 1263<h3><a name="SPARC_install"></a>Installation</h3> 1264 1265<p> 1266Add <b><tt>sparc.dev</tt></b> to <b><tt>DEVICE_DEVS</tt></b> and compile 1267Ghostscript as described in the documentation on <a href="Make.htm">how to 1268build Ghostscript</a>. Afterwards you can use the following script as an 1269example for printing after modifying it with the right pathnames -- 1270including for <b>{GSPATH}</b> the full pathname of the Ghostscript 1271executable: 1272 1273<blockquote> 1274<pre>outcmd1='/vol/local/lib/troff2/psxlate -r' 1275outcmd2='<b><em>{GSPATH}</em></b> -sDEVICE=sparc -sOUTPUTFILE=/dev/lpvi0 -' 1276 1277if [ $# -eq 0 ] 1278then 1279 $outcmd1 | $outcmd2 1280else 1281 cat $* | $outcmd1 | $outcmd2 1282fi 1283</pre></blockquote> 1284 1285<h3><a name="SPARC_problems"></a>Problems</h3> 1286 1287<p> 1288Since <b><tt>/dev/lpi</tt></b> can be opened only for exclusive use, if 1289another job has it open (engine_ctl_sparc or another Ghostscript are the 1290most likely candidates), Ghostscript stops with "Error: /invalidfileaccess 1291in --.outputpage--" 1292 1293<p> 1294In case of common printer problems like being out of paper, a warning 1295describing the reason is printed to stdout. The driver tries access again 1296each five seconds. Due to a problem with the device driver (in the kernel) 1297the reason for printer failure isn't always reported correctly to the 1298program. This is the case, for instance, if you open the top cover (error 1299E5 on the printer's display). Look at the display on the printer itself if 1300a "Printer problem with unknown reason" is reported. Fatal errors cause 1301the print job to be terminated. 1302 1303<p> 1304Note: there is some confusion whether the resolution setting should be 1305the integers 300 and 400, or the symbolic constants DPI300 and DPI400 1306(defined in lpviio.h). Ghostscript releases have had it both ways. It 1307is currently the latter. However, INOUE Namihiko reports (in bug 1308<a href="http://bugs.ghostscript.com/show_bug.cgi?id=215256" 1309class="offsite">#215256</a>) 1310that the former works better for him. If anyone 1311has a definitive answer, please let us know. 1312 1313<hr> 1314 1315<h2><a name="Apple"></a>Apple dot matrix printer</h2> 1316 1317<p> 1318This section was contributed by Mark Wedel 1319<<a href="mailto:master@cats.ucsc.edu">master@cats.ucsc.edu</a>>. 1320 1321<p> 1322The Apple Dot Matrix Printer (DMP) was a parallel predecessor to the 1323Imagewriter printer. As far as I know, Imagewriter commands are a superset 1324of the Dot Matrix printer's, so the driver should generate output that can 1325be printed on Imagewriters. 1326 1327<p> 1328To print images, the driver sets the printer for unidirectional printing 1329and 15 characters per inch (cpi), or 120dpi. It sets the line feed to 1/9 1330inch. When finished, it sets the printer to bidirectional printing, 13311/8-inch line feeds, and 12 cpi. There appears to be no way to reset the 1332printer to initial values. 1333 1334<p> 1335This code does not set for 8-bit characters (which is required). It also 1336assumes that carriage return-newline is needed, and not just carriage 1337return. These are all switch settings on the DMP, and I have configured 1338them for 8-bit data and carriage return exclusively. Ensure that the Unix 1339printer daemon handles 8-bit (binary) data properly; in my SunOS 4.1.1 1340<b><tt>printcap</tt></b> file the string "<b><tt>ms=pass8,-opost</tt></b>" 1341works fine for this. 1342 1343<p> 1344Finally, you can search <b><tt>devdemp.c</tt></b> for 1345"<b><tt>Init</tt></b>" and "<b><tt>Reset</tt></b>" to find the strings that 1346initialize the printer and reset things when finished, and change them to 1347meet your needs. 1348 1349 1350<hr> 1351 1352<h2><a name="Test"></a>Special and Test devices</h2> 1353 1354<p> 1355The devices in this section are intended primarily for testing. They may 1356be interesting as code examples, as well. 1357 1358<h3>Raw 'bit' devices</h3> 1359 1360<p>There are a collection of 'bit' devices that don't do any special formatting 1361but output 'raw' binary data for the page images. These are used for benchmarking 1362but can also be useful when you want to directly access the raster data.</p> 1363 1364<p> 1365The raw devices are <tt>bit bitrgb bitcmyk</tt>. 1366 1367<h3><a name="Bounding_box_output"></a>Bounding box output</h3> 1368 1369<p> 1370There is a special <b><tt>bbox</tt></b> "device" that just prints the 1371bounding box of each page. You select it in the usual way: 1372 1373<blockquote><b><tt> 1374gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox 1375</tt></b></blockquote> 1376 1377<p> 1378It prints the output in a format like this: 1379 1380<blockquote> 1381<pre><b><tt>%%BoundingBox: 14 37 570 719 1382%%HiResBoundingBox: 14.308066 37.547999 569.495061 718.319158 1383</tt></b></pre></blockquote> 1384<p></p> 1385 1386<p> 1387Currently, it always prints the bounding box on <b><tt>stderr</tt></b>; 1388eventually, it should also recognize <b><tt>-sOutputFile=</tt></b>. 1389 1390<p> 1391By default, white objects don't contribute to the bounding box because 1392many files fill the whole page with white before drawing other objects. 1393This can be changed by: 1394 1395<blockquote><tt><b> 1396<< /WhiteIsOpaque true >> setpagedevice 1397</b></tt></blockquote> 1398 1399<p> 1400Note that this device, like other devices, has a resolution and a (maximum) 1401page size. As for other devices, the product (resolution x page size) is 1402limited to approximately 500K pixels. By default, the resolution is 4000 1403DPI and the maximum page size is approximately 125", or approximately 9000 1404default (1/72") user coordinate units. If you need to measure larger pages 1405than this, you must reset <em>both</em> the resolution and the page size in 1406pixels, e.g., 1407 1408<blockquote><b><tt> 1409gs -dNOPAUSE -dBATCH -sDEVICE=bbox -r100 -g500000x500000 1410</tt></b></blockquote> 1411 1412 1413<h3><a name="Permute"></a>Permutation (DeviceN color model)</h3> 1414 1415<p> 1416With no additional parameters, the device named "permute" looks 1417to Ghostscript like a standard CMYK contone device, and outputs a 1418PPM file, using a simple CMYK->RGB transform. This should be the 1419baseline for regression testing. 1420 1421<p> 1422With the addition of <tt><b>-dPermute=1</b></tt>, the internal behavior changes 1423somewhat, but in most cases the resulting rendered file should be the 1424same. In this mode, the color model becomes "DeviceN" rather than 1425"DeviceCMYK", the number of components goes to six, and the color 1426model is considered to be the (yellow, cyan, cyan, magenta, 0, black) 1427tuple. This is what's rendered into the memory buffer. Finally, on 1428conversion to RGB for output, the colors are permuted back. 1429 1430<p> 1431As such, this code should check that all imaging code paths are 143264-bit clean. Additionally, it should find incorrect code that assumes 1433that the color model is one of DeviceGray, DeviceRGB, or DeviceCMYK. 1434 1435<p> 1436Currently, the code has the limitation of 8-bit continuous tone 1437rendering only. An enhancement to do halftones is planned as well. Note, 1438however, that when testing permuted halftones for consistency, it is 1439important to permute the planes of the default halftone accordingly, and 1440that any file which sets halftones explicitly will fail a consistency 1441check. 1442 1443<h3><a name="SPOT"></a>spotcmyk (DeviceN color model)</h3> 1444 1445<p> 1446The <tt>spotcmyk</tt> device was created for debugging and testing of the DeviceN 1447extensions to Ghostscript that were released in version 8.0. 1448There are also another device (<tt>devicen</tt>) in the same 1449source file. It were created for testing however it are not actually useful 1450except as example code. 1451 1452<p>The <tt>spotcmyk</tt> device was also designed to provide example code for a 1453device which supports spot colors. 1454Spot colors need to be specified prior to opening the 1455first page. 1456This can be done via adding the 1457following to the command line: <b><tt>-c "<< /SeparationColorNames [ /Name1 /Name2 ] 1458>> setpagedevice" -f</tt></b>. 1459 1460<p> 1461The <tt>spotcmyk</tt> device produces a binary data file (similar to the bitcmyk 1462device) for the CMYK data. This data file has the name specified by the "OutputFile" 1463parameter. 1464The device also produces a binary data file (similar to the bitmono device) 1465for each spot color plane. 1466These data files have the name specified by the "OutputFile" 1467parameter with "sn" appended to the end (where "n" is the spot color number 0 to 12)". 1468 1469<p> 1470After the <tt>spotcmyk</tt> device produces the binary data files, the files are read 1471and PCX format versions of these files are created with ".pcx" appended to the binary 1472source file name. 1473 1474<p> If the the <tt>spotcmyk</tt> is being used with three spot colors and the 1475"OutputFile" parameter is <tt>xxx</tt> then the following files would be created 1476by the device: 1477 1478<blockquote> 1479<pre>xxx - binary CMYK data 1480xxxs0 - binary data for first spot color 1481xxxs1 - binary data for second spot color 1482xxxs2 - binary data for third spot color 1483xxx.pcx - CMYK data in PCX format 1484xxxs0.pcx - first spot color in PCX format 1485xxxs1.pcx - second spot color in PCX format 1486xxxs2.pcx - third spot color in PCX format 1487</pre> 1488</blockquote> 1489 1490<p> 1491The <tt>spotcmyk</tt> device has the creation of the binary data files separated 1492from the creation of the PCX files since the source file is intended as example 1493code and many people may not be interested in the PCX format. The PCX format was 1494chosen because it was simple to implement from preexisting code and viewers are 1495available. The PCX format does have the disadvantage that most of those viewers 1496are on Windows. 1497 1498 1499<h3><a name="XCF"></a>XCF (DeviceN color model)</h3> 1500 1501<p> 1502The XCF file format is the native image format for the GIMP program. This format 1503is currently supported by two devices: <tt> xcfrgb</tt> and <tt>xcfcmyk</tt>. 1504 1505<blockquote><em> 1506We have been warned by the people supporting the GIMP program that they reserve 1507the right to change the 1508XCF format at anytime and thus these devices may become invalid. They are being 1509included in the documentation because we have received some questions about 1510these devices do. 1511</em></blockquote> 1512 1513<p> 1514The XCF devices were created for testing of the DeviceN extensions to Ghostscript 1515which were released in version 8.0. 1516 1517<p> 1518The <tt>xcfrgb</tt> device uses a DeviceRGB process color model and creates 1519a normal XCF file. 1520 1521<p> 1522The <tt>xcfcmyk</tt> device was created as a means of viewing spot colors for 1523those users that do not have access to either Photoshop <a href=PSD">(see the PSD 1524devices)</a> or a PCX viewer <a href=SPOT">(see the <tt>spotcmyk</tt> device)</a>. 1525 1526<p> 1527The <tt>xcfcmyk</tt> device starts by using a DeviceCMYK process color model. The 1528DeviceCMYK process color model allows the <tt>xcfcmyk</tt> device to also 1529support spot colors. Spot colors need to be specified prior to opening the 1530first page. 1531This can be done via adding the 1532following to the command line: <b><tt>-c "<< /SeparationColorNames [ /Name1 /Name2 ] 1533>> setpagedevice" -f</tt></b>. 1534 1535<p> 1536After a page is complete, the <tt>xcfcmyk</tt> converts the CMYK image data into 1537RGB for storing in the XCF output file. The XCF format does not currently 1538support CMYK data directly. The spot color planes are converted into alpha 1539channel planes. This is done because the XCF format does not currently support 1540spot colors. 1541 1542</p> 1543 1544<!-- [2.0 end contents] ==================================================== --> 1545 1546<!-- [3.0 begin visible trailer] =========================================== --> 1547<hr> 1548 1549<p> 1550<small>Copyright © 1996-2002 artofcode LLC. 1551All rights reserved.</small> 1552 1553<p> 1554This software is provided AS-IS with no warranty, either express or 1555implied. 1556 1557This software is distributed under license and may not be copied, 1558modified or distributed except as expressly authorized under the terms 1559of the license contained in the file LICENSE in this distribution. 1560 1561For more information about licensing, please refer to 1562http://www.ghostscript.com/licensing/. For information on 1563commercial licensing, go to http://www.artifex.com/licensing/ or 1564contact Artifex Software, Inc., 101 Lucas Valley Road #110, 1565San Rafael, CA 94903, U.S.A., +1(415)492-9861. 1566 1567<p> 1568<small>Ghostscript version 8.53, 20 October 2005 1569 1570<!-- [3.0 end visible trailer] ============================================= --> 1571 1572</small></body> 1573</html> 1574 1575