Introduction to GNU Ghostscript


Introduction to GNU Ghostscript

Ghostscript is an interpreter for the PostScript language. A PostScript interpreter usually takes as input a set of graphics commands. The output is usually a page bitmap which is then sent to an output device such as a printer or display. PostScript is embedded in many printers.

Ghostscript has several main uses:

  1. Display a PostScript or PDF file (avoid killing trees).
  2. Convert a PostScript file to a PDF (or vice versa)
  3. Display a PostScript file to decide if you really need to print it (reduce the number of trees killed).
  4. Print a PostScript file to a non-PostScript printer (kill more trees).

An example of a very simple PostScript file is: The 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 6.51. Other versions of Ghostscript are similar. The Ghostscript program is typically found in /usr/local/bin/gs

Ghostscript needs some initialization files in /usr/local/lib/ghostscript/6.51

and some fonts in /usr/local/lib/ghostscript/fonts.

The documenation files are in /usr/local/lib/ghostscript/6.51/doc

and some example PostScript files are in /usr/local/lib/ghostscript/6.51/examples.

Displaying a PostScript file

So now you know how to display a PostScript file. The same instructions apply for .pdf files as well. Some example PostScript files that come with Ghostscript are, and These should be in the examples/ directory under the ghostscript tree.

Printing a PostScript file

To get a list of available printer devices, start Ghostscript for displaying, then type: 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"

More details

A better way

If you are like me, you get sick of typing the long commands above. A program called gv and several derivatives exist for X11 on Unix or VMS. This allows you to display page 20 without having to display pages 1, 2, 3, 4, . 20. You can also print selected pages.

You may also find useful the ggv application distributed with the GNOME desktop environment.

This page was written by Russell Lang and Ralph Giles.

Please send FSF & GNU inquiries & questions to There are also other ways to contact the FSF.

Please send comments on these web pages to, send other questions to

Copyright (C) 1997, 1998, 2001, 2005 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

Updated: $Date: 2005/05/10 13:08:55 $ $Author: Arabidopsis $

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.