PostScript – PS Programming
PostScript can do more — much more — than describe where to put ink on paper.
It’s also a programming language, with variables, arrays, conditionals, and a stack. Not to mention superb vector graphics and fonts.
PostScript has been called “an unappreciated yet superb general purpose computing language”. You can write a PostScript program using any text editor. Here’s the familiar “Hello World” program in PostScript:
To run a program, all you need is a PostScript interpreter such as Ghostscript.
This article is divided in the following chapters:
» Online PostScript Tutorials
» PostScript File Format Specification
» Books on PostScript Programming
» PostScript Programs
» PostScript with Other Programming Languages
» Online reference and Troubleshooting PostScript Errors
» PostScript Training and Consulting
» PostScript Programming Questions
Online PostScript Tutorials
Want to write your own PS programs? Learn the basics for free, right here on the web:
» A First Guide to PostScript by P.J. Weingartner (Univ. of Indiana) A nicely written twelve-chapter primer, now in its fifth edition.
» PostScript Tutorial by Paul Bourke (Univ. of Western Australia) A one-page introduction to PS programming.
» PostScript Programming Tutorials (Interface Technologies Inc.) Short, concentrated tutorials that get you going real quick. (Free registration required.)
» Tom Greer’s Articles contain an introduction to elementary PS programming, including how to cache PS content you want to re-use, and how to merge data with a PDF form.
» Practical PostScript by David Byram-Wigfield An introduction to using PostScript to display and format text, including columns, line-wrap, justification, footnotes, and fonts. Typeset your own book for printing or distilling to PDF. (PDF, 92 pages)
» PostScript Quick Tips by Herb Weiner. An introduction to PostScript divided into 7 Chapters all downloadable in PDF files. PostScript subjects brought up include: Creating a Background Text Message, Printing Font Samples anc Converting PostScript to EPS
» The PostScript FAQ by Allen Braunsdorf. Lots of information on PostScript divided into subjects covering areas such as: PostScript General Questions, PostScript Formats and Conversions, PostScript Fonts, Programming in Postscript and Encapsulated PostScript (EPS)
PostScript File Format Specification
You can download the PostScript Printer Description File Format Specification (Version 4.3 in PDF) directly here!
Books on PostScript Programming
|PostScript Language Reference
The Red Book, Third Edition (912 pages, Addison-Wesley, 1999; ISBN 0201379228). This is the definitive reference from Adobe Systems, covering every aspect of the PS programming language, including Level 3 PostScript. Also available here and here as a PDF. Errata are here.
|PostScript By Example
by Henry McGilton & Mary Compione (640 pages, Addison-Wesley, 1992; ISBN 0-201-63228-4). Written in a clear, easy-to-understand style, this book is packed with examples and explanations. The most comprehensive introductory PS book available, and the only one that includes PS Level 2. Programs from this book are available here.
|PostScript Language Tutorial and Cookbook
The Blue Book, by Adobe Systems Inc. (256 pages, Addison-Wesley, 1986; ISBN 0-201-10179-3). An introduction to the elements of PS programming, plus a cookbook of practical examples, such as re-encoding a font. (PS Level 1 only). Also available here as an 850K PDF.
|PostScript Language Program Design
The Green Book, by Glenn C. Reid (240 pages, Addison-Wesley, 1988; ISBN 0-201-14396-8). A formal introduction to PS programming, including more advanced topics. (PS Level 1 only) “A pretty hard-core book for those with serious PostScript programming to do.” –Glenn C. Reid. Also available here as an 850K PDF here as an 850K PDF.
|Thinking In PostScript
by Glenn Reid (Addison-Wesley, 1990; out of print). Programming style for the serious programmer: How to use the PostScript language as it was designed to be used. Available here as an 850K PDF
|Mathematical Illustrations: A manual of Geometry and PostScript
by Bill Casselman (Cambridge University Press, 2004; ISBN 0521547881).An introduction to PostScript programming, including curves, recursion, and non-linear transformations, as well as how to create good mathematical illustrations, including 3-dimensional drawing, surfaces, motion, and polyhedra.
Also available here as PDF and PS files
|Learning PostScript by Doing
by André Heck (Amstel Institute, UvA 2005). Learn PostScript, especially suited for Programmers with knowledge in LaTex. Used in a Mastercourse with the topic “Mathematics in Pictures: Creating Mathematical Illustrations of High Quality”. Available here as an 2 MB PDF, can also be found at Scribd.
|Adobe 1 Font Format
The Black Book, by Adobe Systems Inc. (103 pages, Addison-Wesley, 1990; ISBN 0-201-57044-0). Everything you need to know and more about the Adobe 1 Font Format. This book is more for those interested in the history of Adobe Fonts. Available here as an 445 KB PDF.
|PostScript and PDF Acrobat
by Thomas Merz (2006, ISBN 3540655344). This book covers the whole range of PostScript and PDF application fields. It explains how several components work together and shows how to solve problems that may arise in practice without getting involved in PostScript programming.
» Gernot Hoffmann has lots of PS programs for graphing sine, gamma, Bezier, and other curves, as well as chromaticity diagrams and 3-D plots.
» John Deubert has a PostScript and Acrobat Resources page with lots of code samples.
» Graham Freeman has written PS programs for typesetting, drawing family trees, and producing color separations.
» Jamie Zawinski’s PS programs print labels for audio, DAT, 8mm, and VHS cassettes, CDs and their cases.
» Evan Danaher has written John Conway’s Game of Life in PS.
» Maurizio Loreti has PS programs for printing calendars in English and Italian.
» Oskar Schirmer has written programs for producing a polyhedron calendar and for computing the date of Easter Sunday.
» Peter Billam has subroutines for drawing in PS, a Perl program for typesetting music in PS, and compares the PS and Perl programming languages.
» Frank Siegert’s PS program calculates pi to over a quarter-million decimal places.
» Anders Karlsson has written a web server in PostScript!
» Julian Wiseman has a page with a lot of examples of PostScript Routines
The comp.sources.postscript newsgroup has been defunct for some time, but the archives contain a variety of hand-coded PS programs.
If you want to see what the source code for a PostScript interpreter looks like, take a look at Ghostscript.
PostScript with Other Programming Languages
» PSPLOT is a library of Fortran-callable subroutines for creating PostScript graphics files.
» CGRAPH lets you create PostScript graphics files from your C program.
» GNU PLOTUTILS has similar capabilities. (Unix)
» PSLIB creates PS graphics and text.
» Marco Schmidt’s web page has links to Java resources for creating and rendering PS and PDF documents.
» Python PS is a Python module for creating PS documents.
» PECL-PS is an extension for creating PS in PHP.
» PLISP is a compiler that generates PS from Lisp.
MANY PROGRAMMING LANGUAGES
» PGPLOT plots PS from C, C++, Fortran, Perl, Python, and other programming languages.
If you don’t have a copy of the Red Book handy, look at the below links:
» Laurens Leurs PS troubleshooting page with information about PostScript errors and possible work arounds.
PostScript Training and Consulting
» Acumen Training is a technical training company offering engineering-level courses in the PostScript language and the PDF file format. Instructor John Deubert has worked with PostScript for over twenty years, having been an Adobe employee during its start-up days. Acumen Training also produces the popular Acumen Journal, which contains articles on PostScript programming. Current and pas issues are available online
» SoftHorizons doing PostScript, GhostScript, PDF and PCL programming
» Tom Greer: Personalized PS training
PostScript Programming Questions