Friday, September 4, 2009

Open Source PDF Printing in Windows

Configuring broad application PDF and TIFF printing using Ghost Script and Red Mon port redirection.

If you have ever wanted to produce PDFs without having to pay for Adobes PDF writer please read on. If you have no need to create pdfs for free, then this is not the article for you.

Setting up Ghost Script
Down load the latest version of ghost script.
  • Download from http://www.cs.wisc.edu/~ghost/
  • (AFPL is the Always Free Version, and the GPL is the OK for commercial version, other wise they are nearly identical.)
Install into C:\gs
  • Run the installer and accept all the defaults except the location. Change that to C:\gs. At this time there are still some issues with directory names that include spaces.

Setting up RedMon port redirection Download and install the latest version of RedMon

Setting up printer

Since ghost script is a command line tool that uses it’s own environment, each printer will either be used at the ghost script command prompt, or via a pre written script. Obviously a script is better. We then must configure the port redirector to use this script


Printer Script

A script is just a test file that contains the required commands and settings. We will be creating one called “tif.rsp” and we will be placing it in the C:\gstools directory.

  1. Create a text file
  2. Cut and past the following lines.

-Ic:\gs\gs8.54\lib;c:\gs\fonts

-sDEVICE=tiffg4

-sOutputFile=c:\print.tif

-dNOPAUSE

-dSAFER

-dBATCH

-r600

-sPAPERSIZE=a4

  1. Save this as tif.rsp
  2. Copy tif.rsp to C:\gstools

Script items explained

If you want to change some of the variables inorder to make more printers that do difrent things, here is a list of each and wht they do.

  • -Ic:\gs\gs8.64\lib;c:\gs\fonts: Tells they system were to find Ghost Script and its fonts. It is highly likely you will need to change the version number to match your particular set up.
  • -sDEVICE=Device Name: Instruct GS to use a particular virtual encoder. Some acceptable encoders are

jpeg (several additional options are required to control quality with JPEG)

pdfwrite (sounds like this prints pdf’s to me)

tiffg4 (four bit black and white)

tiffgray (eight bit grey scale))

tiff12nc (12 bit RGB color)

tiff24nc (24 bit RGB color)

tiff32nc (32 bit CMYK color)

tiffsep (Creates one 32bit CMYK and a 8 bit grey for each separation)

There are also devices for fax, BMP, PCX, Photoshop PSD, Adobe PDF, PS, EPS, PXL, and many more.


Create a virtual printer
    1. Go to Printers and Faxes (Off of the start menu or in the control panel)
    2. Add a printer
    3. Choose Local
    4. Set the port to RPT1 (created by the RedMon installer.)
      • If this port does not exist, add it.
      • Select the Create a New Port option and choose Redirected Port.
      • Name it RPT1: -or- RPT2:, or RPT3:, etc.
    5. Choose the Generic manufacturer and MS Publishing Imagesetter for the type.
    6. Open the printer just created
    7. Go to properties
    8. Go to the Ports Tab
    9. Set the configuration options for the port to:
    10. Redirect this port to the program: C:\gs\gs8.xx\bin\gswin32c.exe (obviously you will need to change these to your particular location for each)
    11. Arguments for this program are: @c:\gstools\tif.rsp -

(See window snapshot below for example) Pay attention that there is a hyphen at the end of the Arguments for this program field.



Prompt for filename

When output is set to Prompt for filename, the redirection program should write its output to a file. The name of the file is obtained from a Save as dialog, can be obtained by inserting %1 in the program arguments. If you wish to place %1 in the program arguments and do not want it substituted with the filename, you must instead use %%1.

For example, the program arguments might include:

 -sOutputFile="%1"

This method is recommended for use with Ghostscript, and is commonly used with a PostScript printer driver and the Ghostscript pdfwrite device to create a PDF writer.

Do not share a printer which uses RedMon with Prompt for filename. RedMon will not allow this because the Save as dialog box would appear on the server computer, not the client which submitted the print job.

Fine Tuning

After you install the printer, you may want to fine-tune its properties. To do so, open again the Printers setting folder, and right click on the printer; select `Properties`.

  1. Under `Device Settings`, set very low values (e.g. 5) to the following two parameters:
    1. Minimum font size to download as outline
    2. Maximum font size to download as bitmap
  2. Next, go to the `Advanced` tab, and from there, select `Printing Defaults…`. In the window that opens, select `Document options`, then `Postscript options`. Set the following two options:
    1. PostScript Output Option: Optimize for Portability
    2. TrueType Font Download Option: Outline


For large format color printing: I recommend using the Xerox Document Center CS50 PS. Just make sure you tell the driver the paper sizes you want to use are loaded. To do this just go back to the properties window, click on the Device Settings Tab and under the Tray Assignment menu select a few paper sizes. Personally I believe, in addition to Letter, Legal and Tabloid are musts.


Appendix:
We pages to know for this application set:

http://www.cs.biu.ac.il/~herzbea/makeP.htm#_Creating_PDF_using_Windows_Office_A

http://www.cs.wisc.edu/~ghost/doc/cvs/Devices.htm

http://server3.nethost.co.il/set_tif.html

http://www.noliturbare.com/

http://server3.nethost.co.il/set_tif.html

http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm#Known_paper_sizes

3 comments:

  1. The ftp download link on the RedMon page (http://pages.cs.wisc.edu/~ghost/redmon/index.htm) seems broken. Do you know another place where that zip archive may be downloaded?

    ReplyDelete
  2. Well, it's not hard ;-) Just google "redmon17.zip."

    ReplyDelete
  3. Yes they are supposed to maintain the current version but their FTP site goes down from time to time. Just do a search and you will find the zip file fairly easy.

    Also if you are looking to do very large format printing, like ARCH D or 24"x108" use the HP DesignJet 755CM/PS

    ReplyDelete