Using Ghostscript in FoxWeb

The following instructions provide information on the use install and test Ghostscript in order to use it to generate PDF files from your FoxWeb scripts. Ghostscript is an interpreter for PostScript and PDF files, with the ability to convert these files to several other formats and to each other. It also provides a PostScript printer driver, which you can use to produce PDF files. Versions entitled GPL Ghostscript are distributed with the GNU General Public License, which allows free use, and free copying and redistribution under certain conditions (including, in some cases, commercial distribution). For details please check the Ghostscript web site, or this site. The creation of PDF files with FoxWeb and Ghostscript is a two step process: First you must direct your report output to a PostScript file and then you must use Ghostscript to convert this file to PDF format.

Obtaining and installing Ghostscript

The first step is to download and install the latest version of Ghostscript. You can get GPL Ghostscript from one of the various mirror sites. A list can be found in the sites above. From there select the desired version (select Current for the latest version) and then download the executable setup program (the file name is typically gsXXXw32-gpl.exe, where XXX is the version number). The other files in this folder contain source code, so don't download them unless you have a lot of experience building binaries from C source code. Once the download completes, run the program to install Ghostscript on your server.

Installing a PostScript Printer Driver

After downloading and installing the Ghostscript setup program, you will need to install a PostScript printer driver on your server. Ghostscript includes ghostpdf.ppd, a PostScript Printer Description (PPD) file. To install a "Ghostscript PDF" printer on Windows XP, 2000, or 2003, select the Windows Control Panel, Printers and Faxes, Add a Printer, Local Printer, Use port FILE: (Print to File), Have Disk..., select the directory containing ghostpdf.ppd and ghostpdf.inf, select "Ghostscript PDF", Replace existing driver (if asked), and answer the remaining questions appropriately. After installing, open the "Ghostscript PDF" properties, select the Device Settings tab, set "Minimum Font Size to Download as Outline" to 0 pixels. You may also set PDF parameters, by selecting the "Ghostscript PDF" Printing Preferences, then the Advanced button. The PDF settings are under "Printer Features".

Testing your Setup

You can test the installation of the Ghostscript PDF printer driver by printing from any application on your server. A Save As dialog will pop up, asking you for the location where you would like to save your PostScript file. Once the file is created on your hard-drive, you can translate it to PDF with the Ghostscript interpreter. On Windows systems the interpreter is named gswin32c.exe and is located in the bin sub-folder of your Ghostscript program folder. The syntax to convert a PostScript file to PDF is as follows:

gswin32c.exe -q -dNOPAUSE -dBATCH -sOutputFile=output.pdf -sDEVICE=pdfwrite -c .setpdfwrite -f input.ps

In the above command input.ps is the source PostScript file and output.pdf is the file you are creating. You may specify additional options in this command line to control certain aspects of the translation. For details click on the ps2pdf link in the main page of the Ghostscript documentation.

Once you have verified your ability to print to PostScript files and translate these files to PDF, you are ready to start creating PDF files from your FoxWeb scripts with the fwPDF object.


© Aegis Group