Ghostscript (Version 7.07)



Documentation
Introduction to Ghostscript
About ps2pdf

Ghostscript is a package of software that provides:

  • An interpreter for the PostScriptTM language, with the ability to convert PostScript language files to many raster formats, view them on displays, and print them on printers that don't have PostScript language capability built in;
  • An interpreter for Portable Document Format (PDF) files, with the same abilities;
  • The ability to convert PostScript language files to PDF (with some limitations) and vice versa; and
  • A set of C procedures (the Ghostscript library) that implement the graphics and filtering (data compression / decompression / conversion) capabilities that appear as primitive operations in the PostScript language and in PDF.

Documentation

Introduction to Ghostscript

Ghostscript is an interpreter for the PostScriptTM 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 file (avoid killing trees).
  2. Display a PostScript file to decide if you really need to print it (reduce the number of trees killed).
  3. Print a PostScript file to a non-PostScript printer (kill more trees).

An example of a very simple PostScript file is:

%!
/Helvetica findfont 72 scalefont setfont
72 72 moveto
(Hello, world!) show
showpage

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.

Displaying a PostScript file

Let's assume that you wish to display the above PostScript example and it is in a file named example.ps in the current directory. Start Ghostscript using:

% gs -sDEVICE=x11

After Ghostscript starts it will display

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.
..........................
Using NimbusSansL-Regu font for NimbusSanL-Regu.
GS>

in the text window and an image window will apear. Ghostscript is now waiting for you to tell it what to do. Typing (example.ps) run will produce

GS>(example.ps) run
>>showpage, press <return> to continue<<

The text "Hello, world!" will appear near the bottom of the image window. You will need to scroll down to see it. 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>quit

If the file is not in the current directory, then you will need to give a full path.

So now you know how to display a PostScript file. Some example PostScript files that come with Ghostscript are colorcir.ps, escher.ps, golfer.ps and tiger.ps. These should be in the directory /usr/share/ghostscript/7.07/examples/.

More details

If you want more details about the Ghostscript command line options, see the file Use.htm in directory /usr/share/doc/ghostscript-7.07 distributed with Ghostscript.

About ps2pdf

ps2pdf is a work-alike for nearly all the functionality (but not the user interface) of Adobe's AcrobatTM DistillerTM product: it converts PostScript files to Portable Document Format (PDF) files.

ps2pdf is implemented as a very small shell script (batch file) that invokes Ghostscript selecting a special "output device" called pdfwrite.

The usage for ps2pdf is:

% ps2pdf input.ps output.pdf

or

% ps2pdf input.ps

which is equivalent to

% ps2pdf input.ps input.pdf

Nach oben scrollen