What Is PostScript?
PostScript is a page description language (PDL) developed by Adobe Systems and introduced in 1984. It was the technology that powered the desktop publishing revolution of the 1980s, enabling high-quality typesetting and graphics output on laser printers. Unlike raster formats (JPEG, PNG), PostScript describes pages as mathematical programs: instructions that a printer's interpreter executes to render text and vector graphics at whatever resolution the output device supports.
PostScript files use the .ps extension for multi-page documents and .eps (Encapsulated PostScript) for single-page graphics intended for embedding in other documents. Modern digital workflows have largely replaced PostScript with PDF — which is itself a direct descendant of PostScript — but PS/EPS files remain common in professional print, scientific publishing, and legacy prepress environments.
PostScript as a Programming Language
The most distinctive feature of PostScript is that it is a full Turing-complete programming language, not just a description markup format. It uses a stack-based, reverse Polish notation (RPN) execution model: operands are pushed onto a stack, and operators pop them off and push results.
Hello World in PostScript
%!PS
% A minimal PostScript program
/Helvetica findfont 24 scalefont setfont
72 720 moveto
(Hello, PostScript!) show
showpage
Line by line:
%!PS— The PostScript "magic comment" that identifies the file to interpreters and spoolers% text— Comment (everything after%on a line)/Helvetica findfont— Push the Helvetica font dictionary onto the stack24 scalefont— Scale it to 24 pointssetfont— Set as current font72 720 moveto— Move the current point to x=72, y=720 (in points; 72 points = 1 inch from bottom-left)(Hello, PostScript!) show— Render the string at the current pointshowpage— Flush the current page to the output device
Drawing Vector Graphics
%!PS
% Draw a blue rectangle with a red diagonal
newpath
100 100 moveto % Start at (100, 100)
300 100 lineto % Line to (300, 100)
300 300 lineto % Line to (300, 300)
100 300 lineto % Line to (100, 300)
closepath % Close back to start
0 0 1 setrgbcolor % Set fill color to blue (R=0, G=0, B=1)
fill
newpath
100 100 moveto
300 300 lineto
1 0 0 setrgbcolor % Red
2 setlinewidth
stroke
showpage
The PostScript Stack Model
Every PostScript operation works through the operand stack:
3 4 add % pushes 3, pushes 4, 'add' pops both and pushes 7
2 mul % pops 7 and 2, pushes 14
= % pops 14 and prints it: outputs "14"
This stack model makes PostScript a highly expressive language for graphics: transformations, loops, conditionals, and procedures are all supported.
% Draw 36 lines radiating from center (like a clock face)
/centerx 300 def
/centery 400 def
/radius 200 def
0 10 350 {
/angle exch def
newpath
centerx centery moveto
centerx angle cos radius mul add
centery angle sin radius mul add
lineto
0.5 setlinewidth
stroke
} for
showpage
DSC: Document Structuring Conventions
Professional PostScript files include DSC comments — structured comment lines beginning with %% that provide metadata and structure hints for print spoolers and previewers. DSC comments are not executed by the PostScript interpreter; they exist only for the surrounding infrastructure.
%!PS-Adobe-3.0
%%Title: Annual Report Cover
%%Creator: Adobe InDesign 2024
%%CreationDate: Mon Apr 15 09:30:00 2024
%%BoundingBox: 0 0 612 792
%%Pages: 1
%%EndComments
%%BeginProlog
% Custom procedures defined here
%%EndProlog
%%Page: 1 1
% ... page content ...
showpage
%%Trailer
%%EOF
Key DSC fields:
%%Title— Document title for spooler display%%Creator— Generating application%%BoundingBox: llx lly urx ury— Bounding box in points (crucial for EPS)%%Pages:— Total page count%%DocumentFonts:— Fonts used (allows pre-loading)
EPS: Encapsulated PostScript
EPS is a constrained variant of PostScript designed for embedding graphics in other documents (similar to how you embed an SVG in HTML). An EPS file:
- Must contain a
%%BoundingBoxcomment defining the graphic's dimensions - Must produce exactly one page of output
- Must not call
showpage(or call it in a way that host applications can intercept) - Should not alter global state (fonts, line width, color) without restoring it
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 200 200
%%Title: Logo
%%Creator: Illustrator
newpath
100 100 80 0 360 arc % Circle centered at (100,100), radius 80
0.2 0.4 0.8 setrgbcolor
fill
%%EOF
EPS files were the dominant format for vector graphics in professional printing until SVG became mainstream. Adobe Illustrator, CorelDRAW, and Inkscape can all open and export EPS. Modern macOS Preview can display EPS via Ghostscript, and Inkscape on Linux/Windows reads EPS natively.
Converting PostScript and EPS
Using Ghostscript (gs)
Ghostscript is the open-source PostScript and PDF interpreter and the primary tool for PS/EPS conversion. It is available on all platforms.
# Install on Debian/Ubuntu
sudo apt install ghostscript
# PS to PDF
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.ps
# PS to PNG (150 dpi)
gs -dBATCH -dNOPAUSE -sDEVICE=png16m -r150 -sOutputFile=page%03d.png input.ps
# EPS to PNG with exact bounding box
gs -dBATCH -dNOPAUSE -dEPSCrop -sDEVICE=png16m -r300 \
-sOutputFile=logo.png logo.eps
# PS to JPEG at 200 dpi
gs -dBATCH -dNOPAUSE -sDEVICE=jpeg -r200 -dJPEGQ=92 \
-sOutputFile=page%03d.jpg document.ps
Key Ghostscript flags:
-dBATCH— Exit after processing (no interactive prompt)-dNOPAUSE— Don't pause between pages-dEPSCrop— Crop output to the EPS BoundingBox-r150— Resolution in DPI-sDEVICE=— Output device:pdfwrite,png16m,jpeg,tiff24nc,svg, etc.
Using ps2pdf (Ghostscript shortcut)
# Direct conversion — ps2pdf is a wrapper around gs
ps2pdf input.ps output.pdf
# With paper size
ps2pdf -sPAPERSIZE=a4 input.ps output.pdf
# EPS to PDF preserving bounding box
ps2epsi input.eps output.eps # adds Preview section
epstopdf output.eps # converts to PDF
Using Python with Ghostscript
import subprocess
import shutil
from pathlib import Path
def ps_to_pdf(input_path: str, output_path: str, dpi: int = 150) -> bool:
"""Convert PostScript or EPS to PDF using Ghostscript."""
gs = shutil.which('gs') or shutil.which('gswin64c') # Windows fallback
if not gs:
raise RuntimeError("Ghostscript not found. Install it first.")
cmd = [
gs,
'-dBATCH', '-dNOPAUSE', '-dQUIET',
'-sDEVICE=pdfwrite',
f'-r{dpi}',
f'-sOutputFile={output_path}',
input_path,
]
result = subprocess.run(cmd, capture_output=True, text=True)
return result.returncode == 0
def eps_to_png(input_path: str, output_path: str, dpi: int = 300) -> bool:
"""Convert EPS to PNG using Ghostscript with bounding box crop."""
gs = shutil.which('gs') or shutil.which('gswin64c')
cmd = [
gs,
'-dBATCH', '-dNOPAUSE', '-dQUIET',
'-dEPSCrop',
'-sDEVICE=png16m',
f'-r{dpi}',
f'-sOutputFile={output_path}',
input_path,
]
result = subprocess.run(cmd, capture_output=True, text=True)
return result.returncode == 0
# Usage
ps_to_pdf('report.ps', 'report.pdf', dpi=300)
eps_to_png('logo.eps', 'logo.png', dpi=300)
Using Inkscape for EPS to SVG
# Inkscape command-line EPS to SVG conversion
inkscape --export-type=svg --export-filename=output.svg input.eps
# EPS to PNG via Inkscape
inkscape --export-type=png --export-dpi=300 --export-filename=output.png input.eps
PostScript in Modern Workflows
Printing: Many enterprise printers still speak PostScript natively. Sending a .ps file directly to a PostScript printer bypasses the host-side rasterization step, often producing better output quality and less CPU load on the print server.
Scientific publishing: LaTeX produces PostScript output via dvips and PDF via pdflatex. Many journals in mathematics, physics, and computer science still accept or even prefer EPS figures because they scale losslessly to any size.
Print prepress: PostScript remains a foundation technology in RIPs (Raster Image Processors) used by offset printers. PDF/X files (print-optimized PDF) are derived from PostScript workflows.
| Task | Recommended Tool |
|---|---|
| View PS/EPS on Windows | Ghostscript + GSView |
| View PS/EPS on macOS | Preview (built-in, via Ghostscript) |
| View PS/EPS on Linux | Evince, Okular, or gv |
| Convert PS to PDF | ps2pdf or gs -sDEVICE=pdfwrite |
| Convert EPS to PNG | gs -dEPSCrop -sDEVICE=png16m |
| Edit EPS vectors | Inkscape or Adobe Illustrator |
| Generate PS from LaTeX | dvips |
Related conversions
Frequent conversions across the catalogue: