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
9
votes
3 answers

Intercepting data sent to a Windows printer (using RedMon)

I need to intercept data being sent to a ESC/POS printer on Windows and analyze it. So I wanted to get the data in plain text, so that I can extract and make sense of information being sent to the printer. Currently, I have tried using RedMon to…
mabicha
  • 337
  • 2
  • 7
  • 16
8
votes
1 answer

How do you convert PDFs to PNGs with ghostscript?

I'm usually able to use ghostscript to convert PDFs to PNGs with the command: gs \ -q \ -dNOPAUSE \ -dBATCH \ -sDEVICE=pnggray \ -g2550x3300 \ -dPDFFitPage \ -sOutputFile=output.png \ input.pdf But this doesn't work for some PDF files. For…
Sharad Goel
  • 145
  • 1
  • 2
  • 6
8
votes
6 answers

How to merge two postscript files together?

I am trying to merge two or more postscript files into one. I tried concatenation but it does not work as each postscript file may have different resource header. Have anyone done this before? Are there any libraries (commercial or open source) out…
Syd
  • 1,526
  • 1
  • 15
  • 16
8
votes
3 answers

Viewing .ps files with google chrome?

I wonder if there is a way to view .ps files without downloading/saving them while one using the Google chrome?
math137
  • 183
  • 1
  • 7
8
votes
6 answers

Error in Converting PDF to PostScript with GhostScript, Access is denied Unable to open command line file _.at

I installed ghostscript and updated the appropriate path variables ... however, I'm getting an error when I try to execute this command: C:\PROGRA~1\gs\gs8.64\lib>pdf2ps mydocument.pdf mydocument.ps Access is denied. Unable to open command line file…
Joel Martinez
  • 46,929
  • 26
  • 130
  • 185
7
votes
3 answers

Overlay two postscript files (command line approach)?

I'm aware that similar questions have been answered here before: postscript - overlay one pdf or ps file on top of another - Stack Overflow overlay - Overlaying or merging multiple .ps files - Stack Overflow ... however, as they don't directly…
sdaau
  • 36,975
  • 46
  • 198
  • 278
7
votes
1 answer

How to embed fonts into an EPS file --and what is the exact definition of "embed"?

My company has created GraphPad Prism, a widely used program for scientists to analyze data and make technical graphs. Often scientists will export graphs from GraphPad Prism for submission to scientific journals. The format most journals want these…
7
votes
3 answers

Modifying a large file in Scala

I am trying to modify a large PostScript file in Scala (some are as large as 1GB in size). The file is a group of batches, with each batch containing a code that represents the batch number, number of pages, etc. I need to: Search the file for the…
Andrew Conner
  • 1,436
  • 13
  • 21
7
votes
2 answers

Smooth PostScript animations

I would like to run animations in PostScript smoothly. To see what I want, let me switch to PostScript directly. Call ghostscript, and 200 dup scale .5 setgray 0 0 3 3 rectfill We have now a gray square. 0 setgray 0 1 3 1 rectfill With a black…
false
  • 10,264
  • 13
  • 101
  • 209
7
votes
2 answers

how to embed a true type font within a postscript file

I have a cross platform app and for my Linux and Mac versions it generates a postscript file for printing reports and then prints them with CUPS. It works for simple characters and images but I would like to have the ability to embed a true type…
KPexEA
  • 16,560
  • 16
  • 61
  • 78
7
votes
4 answers

Simple way to add an image in postscript

I am trying to write a document in postscript. Thus far I've been able to write simple text, and work with lines and shapes. I'm now trying to add some images to the document. After searching on-line I can't seem to find any clear way to do…
Darknight
  • 2,460
  • 2
  • 22
  • 26
7
votes
3 answers

How can I add a footer to the bottom of each page of a postscript or pdf file in linux?

So I'd like to add a "footer" (an attribution) to the bottom of every page of a pdf file I am generating via postscript with groff in linux. I am converting the file from ps to pdf myself, with the ps2pdf tool, so I have access to both…
cwd
  • 53,018
  • 53
  • 161
  • 198
7
votes
1 answer

Open source PostScript interpreter

I'm looking for a simple PostScript interpreter to read. What open source PostScript interpreters exist? I know about Ghostscript of course and also about xpost. Oh, I've just found ralpage, but it does not compile out of the box in modern…
lhf
  • 70,581
  • 9
  • 108
  • 149
7
votes
6 answers

Conversion of TIFF to PDF with Ghostscript

Could you tell me how can I convert TIFF to PDF with using Ghostscript or Postscript? I tried to use this command: gswin32c.exe -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=o.pdf test.tif But it doesn't work. It produces an error: GPL…
user2065631
  • 91
  • 1
  • 1
  • 5
7
votes
5 answers

What are PostScript dictionaries, and how can they be accessed (via Ghostscript)?

I usually look at ghostscript as a command line tool; however, I never cease to be amazed at the sheer amount of settings and options present there - which is due to the fact that ghostscript is a full blown PostScript language interpreter (which I…
sdaau
  • 36,975
  • 46
  • 198
  • 278
1 2
3
70 71