Questions tagged [postscript]

PostScript is a Turing-complete page description programming language, designed and developed by Adobe. There are three major releases: PostScript Level 1, released in 1984. PostScript Level 2 (1991) contained several important improvements. PostScript 3 (1997) is the latest version.

PostScript Overview

PostScript is a reverse-polish stack-based, dynamically-typed, dynamic-namespacing, scripting language with built-in primitives for generating rendered images from vector descriptions. PostScript employs the same "Adobe Image Model" as the PDF file format.

PostScript is used as an output format by many programs since it is designed to be easily machine-generated.

Like LISP, PostScript is homoiconic and code and data share the same representation. Procedures can take procedures as data and yield procedures as results, lending itself to techniques from concatenative-programming as well.

General Description of PostScript

PostScript is a Turing-complete general programming language, designed and developed by Adobe Systems. Many of the ideas which blossomed in PostScript had been cultivated in projects for Xerox and Evans & Sutherland.

Its main real-world application historically is as a page description language, or in its single-page EPS form a vector-graphics image-description language. It is dynamically-typed, dynamically-scoped, and stack-based which leads to a mostly Reverse Polish syntax.

There are three major releases of PostScript.

  1. PostScript Level 1 — this was released to the market in 1984 as the resident operating system of the Apple LaserWriter laser printer, inaugurating the Desktop Publishing Era.
  2. PostScript Level 2 — released in 1991, this contained several important improvements to Level 1, including support for image decompression, in-RIP separation, auto-growing dictionaries, garbage collection, Named Resources, binary encodings of the PostScript program stream itself.
  3. PostScript 3 — the latest and perhaps most widely adopted version was released in 1997. It too contains several import improvements over Level 2 such as Smooth Shading. The term “level” has been dropped.

Though PostScript is typically used as a page description language -- and therefore is implemented inside many printers to generate raster images -- it can also be used for other purposes. As a quick reverse-polish calculator with more memorable operator names than dc. As an output format generated by another program (usually in some other language).

Though PostScript files are typically 7-bit-clean ASCII, there exist several kinds of binary encoding described in the level 2 standard. And being programmable, a program may implement its own arbitrarily-complex encoding scheme for itself. There is an International Obfuscated Postscript Competition, somewhat less active than the C one.

Online References

FAQs

Books

  • Postscript Language Reference Manual, 1ed, 1985. Recommended for its small size, and easy operator index from the summary pages (missing from later editions).

  • Real World Postscript. Chapters by various authors on various topics, including excellent coverage of halftoning.

Curriculum

Read the documentation in this order to easily learn postscript:

  1. Paul Bourke's excellent tutorial: http://paulbourke.net/dataformats/postscript/

  2. Blue Book, first half, the original official tutorial:
    http://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF

  3. Green Book, how to use postscript effectively:
    http://www-cdf.fnal.gov/offline/PostScript/GREENBK.PDF

  4. Thinking in Postscript, 'nuff said: http://wwwcdf.pd.infn.it/localdoc/tips.pdf

  5. Mathematical Illustrations. Start small, build big. The math behind Bezier Curves. The Hodgman-Sutherland polygon clipping algorithm. Affine transformations and non-linear transformations of the path. 3D drawing and Gouraud shading. From the preface:

Which [of the many tools to help one produce mathematical graphics] to choose apparently involves a trade-off between simplicity and quality, in which most go for what they perceive to be simplicity. The truth is that the trade-off is unnecessary — once one has made a small initial investment of effort, by far the best thing to do in most situations is to write a program in the graphics programming language PostScript. There is practically no limit to the quality of the output of a PostScript program, and as one acquires experience the difficulties of using the language decrease rapidly. The apparent complexity involved in producing simple figures by programming in PostScript, as I hope this book will demonstrate, is largely an illusion. And the amount of work involved in producing more complicated figures will usually be neither more nor less than what is necessary.

Installation and/or Setup

The authentic Adobe PostScript interpreters are available in high-end printers, the Display PostScript (DPS) product, and the Acrobat Distiller product. As authors of the standard, these products are considered "the standard implementation" for the purpose of describing differences among PostScript implementations.

The Standard interface to the interpreter defined in the PLRM is the program-stream which may be either text or binary depending upon the details of the underlying channel or OS/controller. Acrobat Distiller has a GUI front-end to select the input postscript program and render its output as a pdf. Distiller also has some limited support for using the output text stream for reporting errors and other program output. GSView provides a similar GUI front-end for a similar workflow using Ghostscript as the interpreter.

Ghostscript and Xpost both work in a command-line mode. The postscript program file to run can be mentioned on the command-line (gs program.ps or xpost program.ps) which will open a graphics window to display the graphical output. Options may be used to render the graphics somewhere else like a disk file or suppress the graphics entirely and use postscript just as a text scripting language.

The various interpreters each have their own installation and setup instructions and it would be wasteful (and prone to falling out-of-date) to reproduce them here.

Freely-available PostScript interpreters

  • Ghostscript is available for all major platforms and Linux distributions, in source or binary form, under the GNU license or under other license arrangements with the authors, Artifex software. Ghostscript implements the full PostScript 3 standard.

  • Xpost is available in source form for all major platforms, under the BSD-3-clause license. It implements the Level-1 standard with some Level-2 extensions and some DPS extensions.

There is more introductory material that was formerly part of the SO Documentation project.

1059 questions
6
votes
2 answers

How to adjust BoundingBox of an EPS file?

I want to crop main area of a PS or PDF file to create an EPS file without white space. Commands of ghostrcipt, ps2pdf, epstools can crop the main drawing out of the document file. The problem is that they only crop in its original form, but I want…
Googlebot
  • 15,159
  • 44
  • 133
  • 229
6
votes
2 answers

comparison of latex with postscript

I came across latex both as a saving format and drawing framework under libreoffice and goffice. I also came across djvu as an alternative to pdf, which uses latex instead of postscript. Now, postscript is adobe's base for flash animations, and is…
6
votes
3 answers

Postscript: concatenate two strings?

How do I concatenate two strings in Postscript? (foo) (bar) ??? -> (foobar)
Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
6
votes
2 answers

Duplex Postscript - Force new page

Is there an easy way to force a postscript page onto a new physical page without inserting a blank page? e.g. Say I have a PS document with 10 postscript pages, which needs to print into different document bundles : 1 - Physical Page 1 Front Side 2…
Dane
  • 619
  • 5
  • 14
6
votes
3 answers

Ghostscript rotate pages

I use Ghostscript to convert PDF documents to PCL for printing. Recently I have the additional requirement that all pages must be rotated to Portrait before printing. I have found a way to do so using Ghostscript with following command and…
Zig158
  • 371
  • 2
  • 9
5
votes
5 answers

batch convert and crop postscript to pdf

I know barely enough to survive in this digital world. I have many one-page postscript files (graphs/images) I wish to convert to pdf and automatically crop to a narrow box. I'm on windows right now (I do use linux too, so don't hesitate to post…
PatrickT
  • 10,037
  • 9
  • 76
  • 111
5
votes
2 answers

How to annotate PS or PDF from (Linux) command line without losing quality?

Is there any command line tool for Linux that will allow me to annotate a PS or PDF file with text or a particular font, color, and size with no loss of quality? I have tried ImageMagick's convert, and the resulting PDF is of pretty poor quality. I…
Carl
  • 695
  • 8
  • 21
5
votes
2 answers

How to determine height and depth of a PostScript font?

I'm looking for PostScript code that estimates a PostScript font's height (room for ascender) and depth (room for descender). Could a font's bounding box (FontBBox) be used for this?` Here is some background for my question: glyphs of a font are…
Christian Lindig
  • 1,216
  • 1
  • 9
  • 24
5
votes
4 answers

Detecting output device in LaTeX

Is there a way, in a LaTeX style/class file, to detect which output device is being used (or at least which capabilities it has)? The reason is, I'm writing a class file in which I want to use some Postscript-specific packages (e.g. pstricks) if…
David Z
  • 128,184
  • 27
  • 255
  • 279
5
votes
1 answer

simple line with two hyperlinks at end in postscript and pdfmaker

Its superconfusing for me, since pdfmaker and postscript are doing same, but in practice coding style is quite different. I know how to make a line with 2 circles at its end, with moveto and lineto and arc command in Postscript language, however,…
Areza
  • 5,623
  • 7
  • 48
  • 79
5
votes
2 answers

How do I make ghostscript output a single specific page from a postscript file as a png?

I am trying to use ghostscript for its intended purpose, to interpret postscript files and output pngs. I would like a command that will convert a single specific page from a multi-page ps file to a single png. I have accomplished this in the case…
Chris
  • 435
  • 5
  • 12
5
votes
2 answers

Printing Graphics in Python

I need to print "Wheel Tags" from python. Wheel tags will have images, lines, and text. The Python tutorial has two paragraphs about creating postscript files with the image lib. After reading it I still do not know how to lay out the data. I was…
Harold Clark
  • 51
  • 1
  • 2
5
votes
2 answers

Ghostscript converting Postscript to PNG is over-saturated

I'm trying to use Ghostscript and/or ImageMagick to convert each page of a Postscript document into PNG images. The problem is that both produce images that are way too saturated (I think that's the right terminology). Here are the commands I'm…
mateolargo
  • 1,022
  • 10
  • 16
5
votes
1 answer

Writing a basic PostScript script by hand

I wanted to try and manually code a PostScript file. Why? Why not. From Wikipedia, I copied and pasted their basic Hello World program for PostScript which is: %!PS /Courier % name the desired font 20 selectfont % choose the size…
chiliNUT
  • 18,989
  • 14
  • 66
  • 106
5
votes
2 answers

How to convert thousands of PDF files to a single Postscript file in a specified order

I've discovered multiple options for convert a few to several PDFs into Postscript, but many are command-line programs with command-line limitations (this application lives on .NET). Our application generates tens-of-thousands of PDFs that we need…
tggagne
  • 2,864
  • 1
  • 21
  • 15