Enjoy a convenient path to PDF, free of charge.
Any program that prints can also create PDFs. Adobe Acrobat sets the standard for PDF creation, but it can be too expensive. Ghostscript is a free PostScript interpreter that can also create PDFs, much like Acrobat's Distiller. Use RedMon to plug the power of Ghostscript into the convenience of a Windows printer, and you'll have "Print to PDF"!
|
The Ghostscript home page is http://www.cs.wisc.edu/~ghost/. As of this writing, the current version of AFPL Ghostscript is 8.14. Download and run the corresponding installer, gs814w32.exe. Our configuration, which follows, assumes Ghostscript is installed in the default location, C:\gs\. If you ever need to reinstall Ghostscript, first uninstall it from the Add or Remove Programs dialog in the Windows Control Panel.
The RedMon home page is http://www.cs.wisc.edu/~ghost/redmon/. As of this writing, the current version of RedMon is 1.7. Download the corresponding zip file, redmon17.zip, into a new directory called redmon17. Unzip it and double-click setup.exe to install.
The PDF Hacks Virtual Printer Kit (VPK) has printer driver files, PPD files, and sample configuration files. Download it from http://www.pdfhacks.com/virtual_printer/. Unzip it into a convenient directory and note its contents. We'll call on these pieces as we need them. The README file might contain updates to these instructions.
|
The rest of this hack is divided by platform: Windows XP or 2000, and Windows 98.
You already installed Ghostscript, RedMon, and our Virtual Printer Kit, right? All that remains is to install and configure your PDF printer.
Any number of PostScript (PS) printers can use the same, core PS driver. To create a complete printer driver, we must combine this core with a printer's PPD file, which describes its capabilities in detail.
Windows XP comes with an up-to-date core PS driver. Our Virtual PostScript Printer driver is simply an INF file instructing Windows to combine this core with the (freely distributable) PPD from Adobe that describes the Acrobat 5 Distiller printer. The result is a printer that is almost ready to create a PDF.
From the Printers and Faxes folder (Start Settings Printers and Faxes) click Add a Printer under Printer Tasks and the wizard will open. Click Next to begin.
Select Local Printer, uncheck Automatically Detect, and click Next.
Select Create a New Port and choose the Redirected Port from the drop-down list. Click Next. A dialog will open asking for the port name. Enter RPTPDF: and click OK. When you installed RedMon, it created this Redirected Port option.
The wizard will present you with a list of printers and manufacturers, but we don't want these. Click Have Disk . . . and then Browse . . . . Navigate to the driver\WinXP\ directory in our Virtual Printer Kit, open ADIST5GS.INF, and then click OK. The wizard should now display only one printer, our Virtual PostScript Printer. Select this printer, as shown in Figure 4-7. Windows might complain that this printer driver is not signed. Click Next.
If the wizard remarks that a driver already is installed for this printer, select Keep Existing Driver and click Next.
Name the printer GS Pdf Printer and select No default printer. Click Next.
Select No to keep it from printing a test page and click Next.
Click Finish to complete the installation. Windows might complain that our driver is not Windows Logo-certified. If so, confirm that you want to install our driver.
The GS Pdf Printer printer should now appear in your Printers and Faxes folder.
Now, wire your new printer to the Ghostscript program by configuring the redirected port you created, RPTPDF:.
Right-click your new GS Pdf Printer printer and select Properties. Click the Ports tab.
Make sure the "Enable bidirectional support" checkbox is unchecked.
Select the Redirected Port you just created, RPTPDF:, and click Configure Port . . . .
Set the port properties as shown in Table 4-3, changing the paths to suit your setup. Be careful not to overlook the solitary hyphen at the end of the program arguments.
Field |
Value |
---|---|
Redirect this port to the program: |
C:\gs\gs8.14
\bin\gswin32c.exe |
Arguments for this program are: |
-sOutputFile="%1"@
C:\gs
\pdf_printer.cfg-f - |
Output: |
Prompt for Filename |
Run: |
Minimized |
Click the Log File button to configure the Log File Properties. Set Use Log File and enter a log filename, such as C:\gs\pdf_printer.log. Don't set Debug.
Click OK to close the Log File Properties. Click OK to accept the new port settings. Click Close to accept the new printer settings, as shown in Figure 4-8, and close the GS Pdf Printer Properties dialog.
To complete the port configuration, you must create the file C:\gs\pdf_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.
-dSAFER -dBATCH -dNOPAUSE -Ic:\gs\gs8.14\Resource -Ic:\gs\fonts -Ic:\gs\gs8.14\lib -sFONTPATH=c:\WINDOWS\FONTS -sDEVICE=pdfwrite -r1200 -c save pop
Voilà! Now, let's test it. Jump down to Section 4.9.6, later in this hack.
You already installed Ghostscript, RedMon, and our Virtual Printer Kit, right? All that remains is to install and configure your PDF printer.
Any number of PostScript (PS) printers can use the same core PS driver. To create a complete printer driver, we must combine this core with a printer's PPD file, which describes its capabilities in detail.
The trouble is, we need an up-to-date PS core. Search your computer hard drive for ADOBEPS4.DRV to see if a recent PS core is installed. If you find it, you will be able to copy our required files, listed later in this section, from your hard drive. If you don't find it, you have a couple options.
One option is to use the Adobe PostScript driver installer, as described in the earlier note. However, its license severely restricts its use. The other option is to download a printer driver from some manufacturer, a driver that contains all the core files we need and employs a permissive license.
For this latter purpose, I like the printer driver download for the Phaser 550 (driver version 4.52) from http://www.Xerox.com. It is a self-extracting executable, win9xadb.exe, which provides all the necessary files in a neat directory. Check the Virtual Printer Kit README for other possible sources.
Whichever driver you use, these are the files you ultimately must collect. You should collect them all from a single source to ensure they're compatible:
Copy these files into the Virtual Printer Kit directory driver\Win9x\. That directory already contains the final two ingredients: our Virtual PostScript Printer PPD file and the Windows INF file used by the Add Printer install wizard to tie everything together.
From the Printers folder (Start Settings Printers) double-click the Add Printer icon. Click Next to begin.
Select Local Printer and click Next.
The wizard will present you with a list of printers and manufacturers, but we don't want these. Click Have Disk . . . and then Browse . . . . Navigate to the driver\Win9x\ directory in our Virtual Printer Kit and click Open and then OK. The wizard should now display only one printer, our Virtual PostScript Printer. Select this printer. Click Next.
If the wizard remarks that a driver is installed for this printer, select Replace Existing Driver and click Next.
Under Available Ports, select FILE: and click Next.
Name the printer GS Pdf Printer and select No default printer. Click Next.
The wizard should be finished. If a Version Conflict dialog opens to complain that you are overwriting newer files with older files, the safest thing to do is to keep the newer files.
The GS Pdf Printer printer now should appear in your Printers and Faxes folder. Wire your new printer to the Ghostscript program by adding and configuring a redirected port.
Let's wire your new GS Pdf Printer printer to the Ghostscript program with a RedMon redirected port.
Right-click your new GS Pdf Printer printer and select Properties. Click the Details tab.
Click Add Port . . . and a dialog opens. Select Other, select Redirected Port, and click OK. Name the port RPTPDF: and click OK.
On the Details tab, click Spool Settings . . . . Select "Disable bi-directional support for this printer" and click OK.
On the Details tab, click Port Settings . . . . Set the port properties as shown in Table 4-4, changing the paths to suit your Ghostscript setup. Be careful not to overlook the solitary hyphen at the end of the program arguments.
Field |
Value |
---|---|
Redirect this port to the program: |
C:\gs\gs8.14
\bin\gswin32c.exe |
Arguments for this program are: |
-sOutputFile="%1"@"
C:\gs
\pdf_printer.cfg"-f - |
Output: |
Prompt for Filename |
Run: |
Minimized |
Click the Log File button to configure the Log File Properties. Set Use Log File and enter a log filename, such as C:\gs\pdf_printer.log. Don't set Debug.
Click OK to close the Log File Properties. Click OK to accept the new port settings. Click OK to accept the new printer settings and close the GS Pdf Printer Properties dialog.
To complete the port configuration, you must create the file pdf_printer.cfg, referenced earlier. It is a text file of additional arguments passed to Ghostscript. An example is included with the Virtual Printer Kit. Change the paths to suit your Ghostscript and system setup.
-dSAFER -dBATCH -dNOPAUSE -I"c:\gs\gs8.14\Resource" -I"c:\gs\fonts" -I"c:\gs\gs8.14\lib" -sFONTPATH=c:\WINDOWS\FONTS -sDEVICE=pdfwrite -r1200 -c save pop
Voilà! Now, let's test it.
Open the GS Pdf Printer properties dialog, click the General tab, and click Print Test Page. After a pause, a dialog will open where you can enter the PDF's filename. Select a suitable filename and click OK. Note that it will overwrite a file without asking and that it does not automatically add the PDF extension to the filename.
When it is done, open the PDF in Reader. How does it look? The next few hacks discuss how to tune Ghostscript for your purposes.
If an error occurs or the PDF file isn't created, carefully double-check the printer configuration and consult the log file:
Is bi-directional printing disabled?
Does the redirected port setting match those given earlier? Mind the separate, trailing hyphen in the program arguments.
Is pdf_printer.cfg in the correct location? Do its contents match those given earlier?
Have all C:\gs\ paths been updated to reflect the location of your Ghostscript installation?