PostScript notes: Difference between revisions

From Helpful
Jump to navigation Jump to search
(Cristiane)
mNo edit summary
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Brliliacne for free; your parents must be a sweetheart and a certified genius.
{{#addbodyclass:tag_tech}}
{{notes}}
 
==Intro==
PostScript is perhaps best known as a page description language used in desktop publishing.
It is fully vector-based, so allows arbitrary scaling, masking, and other such transforms, and can be rasterized fairly easily.
 
From a programmer's view, PostScript is also a dynamically typed Turing-complete language with a reverse polish syntax.
 
 
PostScript was and still can be a convenient way of creating certain types of vector graphics. It is also a means of document transfer, though [[PDF]] has largely replaced in in that area, perhaps largely because PDF viewers are more convenient and modern than most PS viewers.
PostScript is still relatively widely used in academic publishing (now alongside PDF), particularly when generated from LaTeX.
 
 
Earlier versions of PostScript were made in part for laser printers, which contain Postscript interpreters {{comment|(also Raster Image Processor, RIP)}}, allowing them to create sharp vector-based prints by transferring a compact description of vector features rather than high-DPI rasterized images, which would be very large to store and transport.
 
{{comment|(Note that because of the ubiquity of [[PDF]]s, some people store images of pages in PDFs. Particularly users of older laser printers will notice that some documents print very slowly, which is usually because of this. The same is possible in PostScript, though less liekely because of the way it is and isn't used. It's a result of usage rather than format; PDF is actually largely the same as PS in many areas)}}
 
 
<!--
Interpreters with wider support are non-trivial - RIPs were already complex parts for printers at the time, regularly optional and pricy.
-->
 
The differences between the versions (PostScript Level 1 (1981), PostScript Level 2, and PostScript 3 (1997)) lies mostly in increasingly more powerful library-like functionality, for example for (de)compression, error correction, though also in more predefined colors, smoother shading and better color handling.
 
 
PostScript is often used to store documents that have pages, even though concepts such as pages are not central to PostScript.
 
==On DSC==
The Document Structuring Conventions (DSC) are a number of formatting conventions,
which make the use of PostScript for typical documents (articles and such) a bunch more predictable.
 
Among other things, DSC specifies there should be a prolog of metadata (in PostScript comments), which can be used for printing, faster seeking to a particular page{{verify}}, and has some other upsides.
 
 
See also:
* http://en.wikipedia.org/wiki/Document_Structuring_Conventions
* http://hepunx.rl.ac.uk/~adye/psdocs/DSC.html
 
==On PS and EPS==
{{stub}}
 
'''Encapsulated Postscript''' (EPS) is PostScript that meets a few extra constraints.
 
These constraints mostly make it reasonably self-contained and, often more importantly, safe to be embedded inside other PostScript.
 
 
Which also makes EPS potentially useful as a (vector) image format.
 
It is in fact a decent assumption that
: EPS often means images (no pages, and sized exactly to its contents), while
: PS usually means page-based documents.
 
 
EPS file constraints include that:
* it must consist of one page {{comment|(no <tt>showpage</tt> commands)}}
* it must have a valid bounding box
* it must have no net effect when embedded:
** it should leave the stack exactly as it was
** it should not affect global state, meaning they should not use certain commands (at least two dozen are off-limit)
* lines must each be 255 characters or less
 
 
EPS is allowed to contain a raster preview,
to give a user an idea of how something will look ''without'' requiring you to run it though a full PS interpreter.
(Note that use of these previews is still specific to some software and some platforms)
 
 
 
See also:
* http://en.wikipedia.org/wiki/PostScript
* http://en.wikipedia.org/wiki/Encapsulated_PostScript
* http://www.google.com/search?q=Encapsulated%20PostScript%20%E2%80%94%20File%20Format%20Specification
 
==PostScript Programming==
{{stub}}
PostScript has an RPN-like syntax and is executed in a stack-based way.
 
The most basic evaluation is done via the operand stack: naming operands implicitly pushes them onto the operand stack, and naming an operator will do whatever popping, calculation, and/or pushing work that is defined for it.
 
 
 
===Paths and coordinates===
{{stub}}
Paths can be used to draw polygons, define clipping paths, and such, and have the effect of moving the current drawing cursor{{verify}},
 
 
'''<tt>newpath</tt>''' clears the current path, followed by the construction of its segments, after which it is often drawn (or stored for later use?).
 
Absolute movements:
''x y'' moveto
''x y'' lineto
Relative movements:
''x y'' rlineto
''x y'' rmoveto
 
(line to and) arc at (x,y), with radius r, from a1 to a2 (angles in degrees), counter-clockwise:
''x y r a1 a2'' arc
 
Bezier curve to (x3,y3), with (x1,y1) and (x2,y2) as control points:
''x1 y1 x2 y2 x3 y3'' curveto
 
 
You can use '''<tt>closepath</tt>''' to automatically close a polygon, generating a line from the current coordinate to the first in the current path.
 
 
There is also a <tt>charpath</tt>, which adds text shapes to current path
 
<!--
'''<tt>currentpoint</tt>''' pushes the current coordinate onto the stack
-->
 
===Basic drawing===
{{stub}}
 
'''<tt>stroke</tt>''' draws a line along current path
 
 
'''<tt>fill</tt>''' fills the current path, then clears the current path {{comment|(if you want to preserve the current path, one way is to do a <tt>gsave</tt>, <tt>fill</tt>, then <tt>grestore</tt>)}}.
 
 
'''<tt>clip</tt>''' sets the clipping path to whatever the current path is (considered closed if it was not), and does not change the current path.
 
Since everything that is drawn is a path in some way, you can pretty much clip any shape using any other shape (shapes, text, etc.).
 
Since it is not easy to set clipping to a larger area once you have reduced it, you probably want to clip in a local gsave/grestore block.
<!--
clipsave, cliprestore: clipping path stack in the current graphics state
 
 
 
Current fill/stroke properties:
% set fill:
0 setgray              % black fill
0.3 setgray           
1 setgray              % white fill
1 0 0 setrgbcolor      % as RGB
1 0 1 0.5 setcmykcolor % as CMYK
% set stroke:
1 setlinewidth        % (in points)
 
% line caps can be set to 0 (butt caps), 1 (round caps), or 2 (extended butt caps)
1 setlinecap
% line corners can be set to 0 (miter join), 1 (round join), or 2 (bevel join).
1 setlinejoin
 
 
% TODO: setdash
 
You may want to use gsave before and grestore to avoid clobbering current values with a block of drawing code.
 
 
-->
 
===Text===
<!--
* findfont: helper that finds a font by name. Pushes graphics state's font onto stack
* setfont
* scalefont
 
 
Select a font:
/Times-Roman findfont  % Get a font
20 scalefont            % size is 20 points
setfont                % make current font
%often on a single line, like:
/Times-Roman findfont 20 scalefont setfont
 
Showing text:
''string'' show
% for example
(This is Times-Roman clipped to a box) show
-->
 
 
===User space transformations===
<!--
Change the current transformation matrix:
* translate
* rotate
* scale: (<tt>''sx sy'' scale</tt>): change scaling of user coordinates
 
 
0.5 1 scale          % e.g. for narrow text
30 rotate            % 30 degrees counter-clockwise
 
* concat
* concatmatrix
 
-->
 
===Procedures and blocks===
<!--
'''def''' lets you set variables and procedures, in the current dictionary (topmost dictionary on the dictionary stack/
 
For example, set a variable:
% set x to 5
/x 5 def
 
A simple function would define measures on top of postscript points {{comment|(which are defined to be 1/72 inch, which also makes 1cm about 27.3 pt)}}, for example:
/inch {72 mul} def
/cm {28.34646 mul} def
 
This would allow e.g. the more readable {{inlinecode|1 inch 1 inch moveby}} instead of the equivalent {{inlinecode|72 72 moveby}}.
 
Functions take and return values by consuming stack and leaving values on there -- which you have to manage yourself. It is not always directly obvious what a function takes and leaves {{comment|(code commenting is useful. Do it.)}}.
 
For example, the following code draws a one-inch box, and consumes the two values on top of the stack as coordinates to draw it ''at'' (specifically, the top left corner goes there):
% Draw a box at the corner specified by the stack top
% consumes the stack top as x and y coordinates to draw at.
/box {
  newpath
  moveto
  72 0 rlineto
  0 72 rlineto
  -72 0 rlineto
  closepath
} def
It takes arguments in that moveto has none specified, but consumes two as per its specifications.
{{comment|(Note that mentioning values are actually stack pushes, which is how you normally balance pushes and pops on a very local scale)}}
 
 
 
<tt>for</tt> loops take a little more thought. For example, to draw 36 lines in a circle, you could do something like {{comment|(code adapted from an example at tailrecursive.org)}}:
 
0 10 360 {              % you can think of this as 'for (i=0; i<360; i+=10)'
                        %  except with anonymous, stack-based values
 
  newpath              % draw using independent paths
 
  gsave                % ...try to have no net effect on graphics state
 
  144 144 moveto
  rotate                % note no argument; takes the amount of degrees from the stack,
                        %  which the for puts there each loop
  72 0 rlineto          % one-inch path in (now rotated) local coordinates
  stroke                % and stroke it
 
  grestore              % (restore the graphics state that gsave pushed)
} for
 
 
 
'''<tt>bind</tt>''' goes through a function and replaces operator names with operators, primarily to speed up its execution by avoiding lookups each time. Replaces stack-top procedure with the revised one.
 
One example includes creating convenience aliases such as the following, without incurring a lookup slowdown each time these are used:
/M {moveto} bind def
/L {lineto} bind def
-->
 
===Stack related===
<!--
(operator stack:)
* dup: pushes a copy of the top stack value onto the stack
* pop: throws away operator stack's top
* index
* exch
* count: puts the count of the operand stack items on top of that stack
 
(graphics state stack:)
* grestore: push current graphics state onto graphics state stack
* gsave: pop the top of the graphics state stack
 
(dictionary stack:)
* begin: pushes given dictionary onto dictionary stack (for local variables)
* end: pops top dictionary; the one below it becomes current
 
(full system state:)
* restore
* save
 
 
===Helpers===
conditionals and loops:
* if (<tt>''bool proc'' if</tt>): executes proc if bool is true
* ifelse (<tt>''bool proc1 proc2'' ifelse</tt>): executes proc1 if bool is true, proc2 if it is false
 
* for: (<tt>''initial increment limit proc'' for</tt>)
 
 
strings
* search
 
 
math:
* add
* sub
* mul
* div
* ceiling
* floor
* truncate
* round
 
logic
* and
* or
* xor
* not
 
Type conversions
* cvi
* cvr
* cvs
* cvrs
 
 
Execution/literal conversion/tests
* cvlit
* cvx
* xcheck
 
 
-->
 
===Other===
<!--
 
showpage is a page break: it tells the interpreter we are done with a page.
In rendering/printing terms, it can be ejected now, and another prepared/loaded.
 
 
Raster images:
One common way is storing these as data (e.g. hex-encoded) which are converted into paths by {{inlinecode|image}} or {{inlinecode|colorimage}}, where you specify the data's format (columns, rows, bits per pixel, etc.)
 
Postscript 2 and 3 also support decoding of JPEG data{{verify}}
-->
 
===Errors===
See e.g. http://www.tailrecursive.org/postscript/errors.html#stackunderflow
 
===Concepts, syntax notes===
* '''Arrays'''
 
* '''coordinate spaces''': '''Device space''' is usually only used by the interpreters when generating for a specific device('s resolution). Most postscript is generated in '''user space''', which has (0,0) at the bottom left and a page size dependent maximum coordinate at the top right, e.g. (612,792) for Letter (8.5" by 11"). The units are postscript points, which are 1/72 inch.
 
 
* Comments are lines that start with <tt>%</tt>
 
* A '''dictionary''' stores name-value pairs. Dictionaries store variables/value, operators/code. There is a dictionary stack, and the way dictionary lookup works effectively implements (simple) scoping. Note: Dictionaries may be named and stored in other dictionaries.
 
* A '''path''' is a collection of line segments (not necessarily a polyline -- may be disjoint), which is effectively virtual until you specify something to do with it (stroke, fill, clip).
** '''current path''' has somewhat special status in the graphics state.
** '''clipping path''' does too, and is set to the page unless custom-set.
 
* '''graphics state''' refers to the system state in the interpreter. Since parts of this are useful to reuse, you can push/pop graphics state onto the graphics state stack. The state includes:
** the current path,
** the current font,
** the current transformation matrix, and more.
 
* '''Matrices''': Transformation is based on <!--(stack-based?)--> (3x3) matrices
 
* '''Names''' are more free-form than in many other languages; may consist of alphanumerics in any order (though starting with digits can get confusing, and sometimes be parsed as a number in scientific notation), excluding <tt>/%[](){}<></tt>. That is, you may not use those yourself; a few ''are'' existing operators stored, and so stored in dictionaries.
 
* '''Numbers''' comes in the form of integers, floats, ''radix''#''value'', and ''mantissa''E''exponent'' (base-10, scientific notation)
 
* '''Procedures'''
 
* '''Stacks''' are used in various places. Some of the more interesting include:
** the operand stack
** the dictionary stack
** the graphics state {{verify}}
 
* '''Strings''' can come in various forms. The example "ABC"
** can be bracketed as (ABC)
** can be hex-escaped as <414243>
 
 
Further notes:
* Escapes include:
** {{inlinecode|\n}}, {{inlinecode|\r}}, {{inlinecode|\t}}: Newline, Carriage return, Horizontal Tab
** {{inlinecode|\b}}: Backspace
** {{inlinecode|\f}}: Form feed
** {{inlinecode|\\}}: Backslash
** {{inlinecode|\(}}, {{inlinecode|\)}}:  Left and right parenthesis
** {{inlinecode|\ddd}}: octal escape
** Multi-line strings using \ at the end of the line
 
* The use of a /slash forces a name to be used as a variable/key, instead of dereferencing it for a value looked up in dictionaries{{verify}}
 
<!--
==File details==
 
First line:
%!
 
 
Trailer?
%%Trailer
%%DocumentFonts: Helvetica
%%Pages: 1
 
 
Common comments
 
%!PS-Adobe-3.0 EPSF-3.0
%%Creator: [generally the program that generated the postscript]
%%Title: [descriptive name or just the file name]
%%CreationDate: [date the file was created]
%%DocumentData: Clean7Bit
%%Origin: [eg: 0 0]
%%BoundingBox: xmin ymin xmax ymax
%%LanguageLevel: 2 [could be 1 2 or 3]
%%Pages: 1
%%Page: 1 1
%%EOF
 
 
%!PS-Adobe-2.0
%%Title: psgenh
%%Creator: gnuplot 3.5 (pre 3.6) patchlevel beta 338
%%CreationDate: Fri Jan 16 13:18:18 1998
%%DocumentFonts: (atend)
%%BoundingBox: 50 50 554 770
%%Orientation: Landscape
%%Pages: (atend)
%%EndComments
 
EPS should contain:
%%BoundingBox: 50 50 410 302
%%Orientation: Portrait
 
-->
 
===See also (programming)===
* http://www.tailrecursive.org/postscript/ 'A first guide to postscript'
* http://www.capcode.de/index.cfm?id=272
 
==Generating from code==
Often some mix of low-level postscript and higher-level helpers, some more usable than others.
 
Python:
* [http://pyx.sourceforge.net/ PyX] (geared to plotting)
 
* a [http://sourceforge.net/project/showfiles.php?group_id=10725&package_id=120272 python wrapper] for [http://pslib.sourceforge.net/ pslib]
 
* [http://www.pythonware.com/library/pil/handbook/psdraw.htm PSDraw] (part of [[PIL]])
 
* [http://pyscript.sourceforge.net/ PyScript]
** also for diagrams (e.g. in various alignment), can interact with TeX to generate PS for TeX <!--(does not depend on ghostscript?)-->
** pure-python
 
* [http://www.nongnu.org/pypsg/about/index.html pypsg]
** some optional dependencies{{verify}})
** pure-python
 
* there is a pyps.py floating about (single pure-python file, simple)
 
* [http://www.reportlab.org/ ReportLab]
 
 
 
==Editing, converting==
{{stub}}
In unices you can view and convert PS to raster images or PDF using fairly standard unix utilities (<tt>epstopdf</tt> imagemagick <tt>convert</tt>, and others), while in Windows you rely much more heavily on vector drawing applications and/or [http://www.cs.wisc.edu/~ghost/ Ghostscript].
 
Some options for vector editing:
* [http://www.inkscape.org/screenshots/index.php?lang=en Inkscape] (free)
* [http://sourceforge.net/projects/sodipodi/ Sodipodi] (free)
* Adobe Illustrator (paid-for)
* Corel Draw (paid-for)
<!--
Both of these gave me trouble:
* [http://www.koffice.org/karbon/ Karbon] (part of KOffice, under linux. Use import)
* [http://www.openoffice.org/product/draw.html OpenOffice Draw] (apparently; it gave me trouble)
-->
Such editors can often also save to PDF files and/or raster images.
 
Note that raster editors such as Photoshop, GIMP and such can regularly ''import'' PostScript, by rendering it into pixels.
 
 
<!--
It's actually not too hard to supply web-based conversion from PS to PDF or images, but since PostScript is a ([[Turing complete]]) programming language it may be potentially dangerous. PS from L04 can be assumed not to be, so adding it as an optional step tied to PS production is safe enough.
This usually relies on ghostscript, and is a little easier to do on unices.
-->
 
==See also==
 
Tutorials
* http://www.google.com/search?q=Practical+PostScript
* http://local.wasp.uwa.edu.au/~pbourke/dataformats/postscript/index.html
* http://www.tailrecursive.org/postscript/postscript.html
 
* http://www.tgreer.com/resources.html
* http://www.geocities.com/siliconvalley/5682/Programming.html
 
Introductions, references, techical info
* http://en.wikipedia.org/wiki/PostScript
* http://en.wikipedia.org/wiki/Document_Structuring_Conventions
* http://partners.adobe.com/public/developer/ps/index_specs.html
 
 
Other/Unsorted:
* http://atrey.karlin.mff.cuni.cz/~milanek/PostScript/Reference/
* http://web.ncf.ca/cj434/
<!--
* http://dsl.org/cookbook/cookbook_25.html#SEC363
 
-->
 
 
 
* [[PDF notes]]
 
[[Category:Programming]]

Latest revision as of 23:27, 21 April 2024

📃 These are primarily notes, intended to be a collection of useful fragments, that will probably never be complete in any sense.

Intro

PostScript is perhaps best known as a page description language used in desktop publishing. It is fully vector-based, so allows arbitrary scaling, masking, and other such transforms, and can be rasterized fairly easily.

From a programmer's view, PostScript is also a dynamically typed Turing-complete language with a reverse polish syntax.


PostScript was and still can be a convenient way of creating certain types of vector graphics. It is also a means of document transfer, though PDF has largely replaced in in that area, perhaps largely because PDF viewers are more convenient and modern than most PS viewers. PostScript is still relatively widely used in academic publishing (now alongside PDF), particularly when generated from LaTeX.


Earlier versions of PostScript were made in part for laser printers, which contain Postscript interpreters (also Raster Image Processor, RIP), allowing them to create sharp vector-based prints by transferring a compact description of vector features rather than high-DPI rasterized images, which would be very large to store and transport.

(Note that because of the ubiquity of PDFs, some people store images of pages in PDFs. Particularly users of older laser printers will notice that some documents print very slowly, which is usually because of this. The same is possible in PostScript, though less liekely because of the way it is and isn't used. It's a result of usage rather than format; PDF is actually largely the same as PS in many areas)


The differences between the versions (PostScript Level 1 (1981), PostScript Level 2, and PostScript 3 (1997)) lies mostly in increasingly more powerful library-like functionality, for example for (de)compression, error correction, though also in more predefined colors, smoother shading and better color handling.


PostScript is often used to store documents that have pages, even though concepts such as pages are not central to PostScript.

On DSC

The Document Structuring Conventions (DSC) are a number of formatting conventions, which make the use of PostScript for typical documents (articles and such) a bunch more predictable.

Among other things, DSC specifies there should be a prolog of metadata (in PostScript comments), which can be used for printing, faster seeking to a particular page(verify), and has some other upsides.


See also:

On PS and EPS

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

Encapsulated Postscript (EPS) is PostScript that meets a few extra constraints.

These constraints mostly make it reasonably self-contained and, often more importantly, safe to be embedded inside other PostScript.


Which also makes EPS potentially useful as a (vector) image format.

It is in fact a decent assumption that

EPS often means images (no pages, and sized exactly to its contents), while
PS usually means page-based documents.


EPS file constraints include that:

  • it must consist of one page (no showpage commands)
  • it must have a valid bounding box
  • it must have no net effect when embedded:
    • it should leave the stack exactly as it was
    • it should not affect global state, meaning they should not use certain commands (at least two dozen are off-limit)
  • lines must each be 255 characters or less


EPS is allowed to contain a raster preview, to give a user an idea of how something will look without requiring you to run it though a full PS interpreter. (Note that use of these previews is still specific to some software and some platforms)


See also:

PostScript Programming

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

PostScript has an RPN-like syntax and is executed in a stack-based way.

The most basic evaluation is done via the operand stack: naming operands implicitly pushes them onto the operand stack, and naming an operator will do whatever popping, calculation, and/or pushing work that is defined for it.


Paths and coordinates

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

Paths can be used to draw polygons, define clipping paths, and such, and have the effect of moving the current drawing cursor(verify),


newpath clears the current path, followed by the construction of its segments, after which it is often drawn (or stored for later use?).

Absolute movements:

x y moveto
x y lineto

Relative movements:

x y rlineto
x y rmoveto 

(line to and) arc at (x,y), with radius r, from a1 to a2 (angles in degrees), counter-clockwise:

x y r a1 a2 arc

Bezier curve to (x3,y3), with (x1,y1) and (x2,y2) as control points:

x1 y1 x2 y2 x3 y3 curveto


You can use closepath to automatically close a polygon, generating a line from the current coordinate to the first in the current path.


There is also a charpath, which adds text shapes to current path


Basic drawing

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

stroke draws a line along current path


fill fills the current path, then clears the current path (if you want to preserve the current path, one way is to do a gsave, fill, then grestore).


clip sets the clipping path to whatever the current path is (considered closed if it was not), and does not change the current path.

Since everything that is drawn is a path in some way, you can pretty much clip any shape using any other shape (shapes, text, etc.).

Since it is not easy to set clipping to a larger area once you have reduced it, you probably want to clip in a local gsave/grestore block.

Text

User space transformations

Procedures and blocks

Stack related

Other

Errors

See e.g. http://www.tailrecursive.org/postscript/errors.html#stackunderflow

Concepts, syntax notes

  • Arrays
  • coordinate spaces: Device space is usually only used by the interpreters when generating for a specific device('s resolution). Most postscript is generated in user space, which has (0,0) at the bottom left and a page size dependent maximum coordinate at the top right, e.g. (612,792) for Letter (8.5" by 11"). The units are postscript points, which are 1/72 inch.


  • Comments are lines that start with %
  • A dictionary stores name-value pairs. Dictionaries store variables/value, operators/code. There is a dictionary stack, and the way dictionary lookup works effectively implements (simple) scoping. Note: Dictionaries may be named and stored in other dictionaries.
  • A path is a collection of line segments (not necessarily a polyline -- may be disjoint), which is effectively virtual until you specify something to do with it (stroke, fill, clip).
    • current path has somewhat special status in the graphics state.
    • clipping path does too, and is set to the page unless custom-set.
  • graphics state refers to the system state in the interpreter. Since parts of this are useful to reuse, you can push/pop graphics state onto the graphics state stack. The state includes:
    • the current path,
    • the current font,
    • the current transformation matrix, and more.
  • Matrices: Transformation is based on (3x3) matrices
  • Names are more free-form than in many other languages; may consist of alphanumerics in any order (though starting with digits can get confusing, and sometimes be parsed as a number in scientific notation), excluding /%[](){}<>. That is, you may not use those yourself; a few are existing operators stored, and so stored in dictionaries.
  • Numbers comes in the form of integers, floats, radix#value, and mantissaEexponent (base-10, scientific notation)
  • Procedures
  • Stacks are used in various places. Some of the more interesting include:
    • the operand stack
    • the dictionary stack
    • the graphics state (verify)
  • Strings can come in various forms. The example "ABC"
    • can be bracketed as (ABC)
    • can be hex-escaped as <414243>


Further notes:

  • Escapes include:
    • \n, \r, \t: Newline, Carriage return, Horizontal Tab
    • \b: Backspace
    • \f: Form feed
    • \\: Backslash
    • \(, \): Left and right parenthesis
    • \ddd: octal escape
    • Multi-line strings using \ at the end of the line
  • The use of a /slash forces a name to be used as a variable/key, instead of dereferencing it for a value looked up in dictionaries(verify)


See also (programming)

Generating from code

Often some mix of low-level postscript and higher-level helpers, some more usable than others.

Python:

  • PyX (geared to plotting)
  • PyScript
    • also for diagrams (e.g. in various alignment), can interact with TeX to generate PS for TeX
    • pure-python
  • there is a pyps.py floating about (single pure-python file, simple)


Editing, converting

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

In unices you can view and convert PS to raster images or PDF using fairly standard unix utilities (epstopdf imagemagick convert, and others), while in Windows you rely much more heavily on vector drawing applications and/or Ghostscript.

Some options for vector editing:

  • Inkscape (free)
  • Sodipodi (free)
  • Adobe Illustrator (paid-for)
  • Corel Draw (paid-for)

Such editors can often also save to PDF files and/or raster images.

Note that raster editors such as Photoshop, GIMP and such can regularly import PostScript, by rendering it into pixels.


See also

Tutorials

Introductions, references, techical info


Other/Unsorted: