Working with Post Script in Ghostscript

Ghostscript is a utility for previewing and printing PostScript documents. Ghostscript enables you to print PostScript documents on many non-PostScript devices.

At its heart, Ghostscript is a nearly complete implementation of the PostScript language. Ghostscript includes the interpreter that processes PostScript input and generates output on an output device. A Ghostscript device can be a printer (or display screen), as well as an image-file format, such as BMP or PCX.

Ghostscript is distributed under the GNU GPL but is copyrighted and maintained by Aladdin Enterprises. The latest version remains under Aladdin's control for one year after its release, at which point it is transferred to the Free Software Foundation and can be distributed under GPL.

To run Ghostscript, first type export GS_DEVICE=x11 in a terminal window and then type gs. Ghostscript brings up an empty window and displays the following text in the terminal window (the version number is different if you are running a later version of Ghostscript):

GNU Ghostscript 7.07 (2003-05-17)

Copyright (C) 2003 artofcode LLC, Benicia, CA. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. GS>

At this point, you are interacting with the Ghostscript interpreter. Unless you know the Ghostscript language (which is like PostScript), you'll feel lost at this prompt. It's kind of like the C:> prompt under MS-DOS or the Linux shell prompt at a terminal.

If you have a PostScript file available, you can interactively load and view it in Ghostscript with a simple command. For example, try the following command:

GS> (/usr/share/ghostscript/7.07/examples/ run >>showpage, press <return> to continue<<

You have typed a Ghostscript command that should cause Ghostscript to load the file

/usr/share/ghostscri'pt/7.07/examples/ and process it. (If you are running a version of Ghostscript other than 7.07, you must change 7.07 to that version number.) The result is a picture in Ghostscript's output window. To exit Ghostscript, press Enter and type quit.

Fortunately, you do not have to use Ghostscript at the interpreter level (unless you know PostScript well and want to try PostScript commands interactively). Typically, you use Ghostscript to load and view a PostScript file.

Ghostscript takes several command-line arguments, including the file to be loaded. To see a list of Ghostscript options, type the gs -h command.

To see how Ghostscript renders a PostScript document, you can use any PostScript document you have available. You can view one of the sample PostScript files in the /usr/ share/ghostscript/7.07/examples directory (replace 7.07 with whatever version of Ghostscript is installed on your system — Ghostscript displays its version number when you start it). Type the following command, for example, in a terminal window:

gs /usr/share/ghostscript/7.07/examples/

Ghostscript opens that file, processes its contents, and displays the output in another window, as shown in Figure 10-15.

Figure 10-15: Ghostscript Displaying a PostScript File.

In this case, the output happens to be a picture of a golfer. After displaying the output, Ghostscript displays the following message:

>>showpage, press <return> to continue<<

Press Enter to continue. For a multiple-page PostScript document, Ghostscript then shows the next page. After all the pages are displayed, you return to the Ghostscript prompt. Type quit to exit Ghostscript.

Was this article helpful?

0 0
Make Money Writing

Make Money Writing

This Report Will Show You How To Make Money By Providing Writing Services To Other Internet Marketers. Learn how to make money by writing the right way. Grab your copy of this report now and learn. Why writing is a great way to earn money. How to compete with cheap writers, even if you charge a lot more money.

Get My Free Ebook

Post a comment