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
1 answer

Fit to page size in ghostscript (with a possibly corrupt input)

I'm trying to use ghostscript to convert a .ps file to a series of .png files, largely because I don't have a tolerable ps viewer. This is the command I've used: gs -dBATCH -dEPSCrop -dEPSFitPage -sDEVICE=png16m -r300 -dNOPAUSE…
keflavich
  • 18,278
  • 20
  • 86
  • 118
6
votes
2 answers

How to convert PDF to low-resolution (but good quality) JPEG?

When I use the following ghostscript command to generate jpg thumbnails from PDFs, the image quality is often very poor: gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeggray -g465x600 -dUseCropBox -dPDFFitPage -sOutputFile=pdf_to_lowres.jpg test.pdf By…
Sharad Goel
  • 145
  • 1
  • 2
  • 6
6
votes
1 answer

Use Ghostscript to convert PCL to PostScript

So I want to use Ghostscript to convert files that are created in PCL format to PostScript. That's the gist of my problem. I am simply trying to run it on the command line, but in the final stage it will have to be run on a lp command like lp -d <…
Bryon
  • 61
  • 1
  • 1
  • 2
6
votes
1 answer

gnuplot postscript terminal not showing transparent symbols

Hopefully, this is a stupid question, and easy to fix. When I run this simple gnuplot script: #!/usr/bin/env gnuplot set term png set out "out.png" plot "
Vinicius Placco
  • 1,683
  • 2
  • 14
  • 24
6
votes
1 answer

The 14 standard PDF fonts and character encoding

I'm having difficulty producing PDFs that make use of the 14 standard PDF fonts. Let's use Times-Roman as an example. I create a Font dictionary of type Type1, with BaseFont set to Times-Roman. If I omit the Encoding entry to the Font dictionary, or…
Brecht Machiels
  • 3,181
  • 3
  • 25
  • 38
6
votes
2 answers

R error on a Mac: "family 'Times New Roman' not included in postscript() device"

I am using R on a macbook. This code: postscript("plot.eps") ggplot(SomeData, aes (x=Cue, y=var1, group=var2, color=var2, shape=var2)) + geom_line(size=0.5) + geom_point(size = 3) + geom_errorbar(aes(ymin=Var1-ci, ymax=Var1+ci), width=0.15,…
user3620237
6
votes
2 answers

Linux PDF/Postscript Optimizing

So I have a report system built using Java and iText. PDF templates are created using Scribus. The Java code merges the data into the document using iText. The files are then copied over to a NFS share, and a BASH script prints them. I use acroread…
Sheldon Ross
  • 5,364
  • 7
  • 31
  • 37
6
votes
3 answers

Validating a Postscript without trying to print it?

Saving data to Postscript in my app results in a Postscript file which I can view without issues in GhostView, but when I try to print it, the printer isn't able to print it because it seems to be invalid. Is there a way to validate / find errors in…
Epaga
  • 38,231
  • 58
  • 157
  • 245
6
votes
3 answers

printing to Postscript from vim

I have problem with printing to postscript from Vim. I'm, using utf-8 encoding with czech characters like 'ščřž' but in the output I get upside question mark instead of the correct characters. vim --version VIM - Vi IMproved…
Milan Leszkow
  • 61
  • 1
  • 2
6
votes
3 answers

Count PDF pages from stdin with Ghostscript (PostScript)

Well I found on stackoverflow how to count pages of PDF file using Ghostscript by executing the following command on a shell gs -q -dNODISPLAY -c "($PATH_TO_PDF) (r) file runpdfbegin pdfpagecount = quit"') I would like to get the pdf from stdin.…
Mathias
  • 6,777
  • 2
  • 20
  • 32
6
votes
8 answers

Convert from PDF to Postscript using Java

I am having a J2EE based application, where I am using a reporting tool to generate outputs in PDF format. I need a utility/ tool in Java which can help me convert my PDF file to postscript format so that I can print it to a printer... My…
Aniket Bharambe
  • 69
  • 1
  • 1
  • 2
6
votes
2 answers

Postscript - document size

how to set page size in the postscript? how to rotate the document to width? . . %! %% Example 1 newpath 100 200 moveto 200 250 lineto 100 300 lineto 2 setlinewidth stroke showpage Thank you.
6
votes
2 answers

bold enhanced text in gnuplot

UPDATE: this issue has been resolved in newer versions (>5.0) of gnuplot; see @andyras' answer. I am having difficulty getting gnuplot to create labels with bold and enhanced text in non-postscript terminals. The following script #!/usr/bin/env…
andyras
  • 15,542
  • 6
  • 55
  • 77
6
votes
3 answers

How include img in postscript

I want to add image to my postscript code %!PS-Adobe-3.0 /Times-Roman findfont 12 scalefont setfont 50 700 moveto (text) show showpage but i dont have idea to do that. Someone help?
badzz124
  • 71
  • 1
  • 4
6
votes
2 answers

PostScript mark token

In PostScript if you have [4 5 6] you have the following tokens: mark integer integer integer mark The stack goes like this: | mark | | mark | integer | | mark | integer | integer | | mark | integer | integer | integer | | array | Now my…
juFo
  • 17,849
  • 10
  • 105
  • 142