Hack 45 Print to Image and Other Rasterizing Options

figs/expert.gif figs/hack45.gif

Thumbnail the cover or rasterize the entire document.

You might sometimes need to convert PDF to other graphics formats. You can easily add a "Print to Image" printer by following [Hack #39] and changing a few ingredients. Alternatively, rasterize your PDF documents using Adobe Acrobat or Photoshop. Because Photoshop gives you the most power, you might prefer to "Print to PDF" and then open these pages in Photoshop.

4.15.1 Install a PNG (or JPEG or TIFF) Printer

The procedure for creating a bitmap (e.g., TIFF, JPEG, PNG) printer is the same as the procedure for creating the PDF printer in [Hack #39] . The configuration is just a little different. In this example, we'll configure a PNG printer, but you just as easily can create a JPEG or TIFF printer. The DEVICE option determines what gets created. We discuss alternative devices a little later.

Follow the PDF Printer instructions, except:

  1. Name the new printer GS png16m Printer instead of GS Pdf Printer.

  2. Name the new Redirected Port RPTPNG16M: instead of RPTPDF:.

  3. When configuring this new Redirected Port, name the options file C:\gs\png16m_printer.cfg instead of C:\gs\pdf_printer.cfg.

  4. When configuring this new Redirected Port, name the log file C:\gs\png16m_printer.log instead of C:\gs\pdf_printer.log.

  5. Create the file png16m_printer.cfg, referenced earlier. It is a text file of additional arguments passed to Ghostscript. An example is included with our Virtual Printer Kit. Change the paths to suit your Ghostscript and system setup.


    Using this procedure, you can create one printer for each image file format you commonly use. "Print to Image" devices and options

The documentation that comes with Ghostscript (C:\gs\gs8.14\doc\index.htm) explains the available output devices (Devices.htm) and general options (Use.htm) that you can use in the configuration file. Tables Table 4-8 and Table 4-9 provide a quick, abbreviated reference to give you a glimpse of what's possible.

Table 4-8. Some Ghostscript bitmap devices

Ghostscript device



Grayscale PNG


16-Color (4-bit) PNG


256-Color (8-bit) PNG


16-Million Color (24-bit) PNG


Grayscale JPEG


Color JPEG


16-Million Color (24-bit) TIFF


G3 Fax with EOLs

Table 4-9. Some Ghostscript bitmap options

Ghostscript option


-r<dpi resolution>

Sets the resolution of the output file in dots per inch. Screen resolution is commonly 72 dpi. To create thumbnails, set this to a low value, such as 20 dpi.


Sets the text antialiasing. 4 yields the greatest smoothing.


Sets the graphics antialiasing. 4 yields the greatest smoothing.


Sets the JPEG quality. Lower values yield greater compression at the expense of image quality. Image output filenames

When printing a multipage document to one of these bitmap printers, the output filename must include the %d page number variable so that each page gets a unique filename. To pad this variable with three leading zeros, use %03d. On the Windows command line, the % must be represented by %%. Here are some example filenames that you might enter into the Save As . . . dialog box:


Yields: report_page-1.png, report_page-2.png, . . .


Yields: book_pg-001.png, book_pg-002.png, . . .


Yields: tome_p-0001.png, tome_p-0002.png, . . .

4.15.2 Acrobat: Save As Image

Beginning with Acrobat 5, you can open a PDF and then Save As . . . to JPEG, PNG, or TIFF image files. From the Save As . . . dialog, click the Settings . . . button to configure image options. You can set the image resolution, color space, and compression, among other things.

4.15.3 Photoshop: Open PDF

Photoshop is an ideal place to manipulate bitmaps, so it makes sense to open your PDF right in Photoshop. If your original document isn't a PDF, print one using Acrobat Distiller or our GS Pdf Printer [Hack #39] . Open it in Photoshop, then Save As . . . to whatever format you want.

4.15.4 Mac OS X: Preview

As mentioned in [Hack #2], the Preview application that comes with Mac OS X lets you open PDF files and save them in a variety of graphics formats.