Ghostscript has several main uses:
An example of a very simple PostScript file is:
%! /Helvetica findfont 72 scalefont setfont 72 72 moveto (Hello, world!) show showpageThe first line is a PostScript comment. It is ignored by the PostScript interpreter, but enables other programs to recognise that the file contains PostScript commands. The second line says to find the Helvetica font, scale it to 72 points high (1 inch) and then set it as the current font. The third line moves the current point to 1 inch in from the left and bottom edges of the page. The fourth line draws the text into the page bitmap at the current point. The final line causes the page bitmap to be output to paper or the display.
The information below assumes the use of GNU Ghostscript 5.50.
Other versions of Ghostscript are similar.
The Ghostscript program is typically found in
Ghostscript needs some initialization files in /usr/local/lib/ghostscript/5.50
and some fonts in /usr/local/lib/ghostscript/fonts.
The documentation files are in /usr/local/lib/ghostscript/5.50/doc
and some example PostScript files are in /usr/local/lib/ghostscript/5.50/examples.
gsIf Ghostscript has not been correclty installed, you will need to specify the full path, for example:
/usr/local/bin/gs -I/usr/local/lib/ghostscript/5.50:/usr/local/lib/ghostscript/fontsThe -I option tells Ghostscript to look for its configuration files and fonts in the two directories listed. After Ghostscript starts it will display
GNU Ghostscript 5.50 (1998-09-11) Copyright (C) 1998 Aladdin Enterprises, Menlo Park, CA. All rights reserved. This software comes with NO WARRANTY: see the file COPYING for details. GS>An X11 image window will appear. Ghostscript is now waiting for you to tell it what to do. Typing (example.ps) run will produce
GS>(example.ps) run Loading NimbusSanL-Regu font from /usr/local/lib/ghostscript/fonts\n019003l.pfb... 1669824 366951 1300076 11892 0 done. >>showpage, press <return> to continue<<The text "Hello, world!" will appear near the bottom of the X11 image window. When you have finished viewing the image window, switch to the text window and press the <return> key. You will be returned to the GS> prompt. Type quit to close Ghostscript.
GS>quitIf the file is not in the current directory, then you will need to give a full path. For example, (/user/john/example.ps) run.
So now you know how to display a PostScript file. Some example PostScript files that come with Ghostscript are colorcir.ps, chess.ps and tiger.ps. These should be in the /usr/local/lib/ghostscript/5.50/examples directory.
gs -sDEVICE=djet500The output will be sent to a scratch file. Ghostscript will come up with the GS> prompt again, we give it a file name, and after processing each page it will pause. This is probably undesirable. A better way to start Ghostscript is:
gs -sDEVICE=djet500 -dNOPAUSE example.ps -c quitThis tells Ghostscript not to pause after each showpage, to interpret the file example.ps and afterwards to exit. This is much more useful.
To get a list of available printer devices, start Ghostscript for displaying, then type:
GS>devicenames ==The destination for the printed output can be specified on the command line. To output to the file out.prn, add -sOutputFile="out.prn" somewhere before the name of the PostScript file. To pipe the output to the lpr program, use -sOutputFile="\|lpr queuename"