1 / 24

Adobe PostScript

Adobe PostScript. by Jeffrey Jongko. Introduction. PostScript is a programming language optimized for printing graphics and text (whether on paper, film, or CRT is immaterial). In the jargon of the day, it is a page description language (PDL) . Other PDLs include languages like PCL5 and WPL.

tracen
Download Presentation

Adobe PostScript

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Adobe PostScript by Jeffrey Jongko

  2. Introduction • PostScript is a programming language optimized for printing graphics and text (whether on paper, film, or CRT is immaterial). • In the jargon of the day, it is a page description language (PDL). Other PDLs include languages like PCL5 and WPL. • PostScript has several levels indicating what extensions are present since the original. Currently it is at Level 3.

  3. Introduction • The origins of PostScript was in Xerox when it was created by Chuck Geschke and John Warnock as Interpress. • Xerox did not capitalize on it and the creators built the Adobe Company to try and make it commercial.

  4. Introduction • PostScript was introduced by Adobe in 1985 for the Apple LaserWriter. • PostScript allowed the LaserWriter to print out “Typesetter-quality” page output. • PostScript helped catalyze the Desktop Publishing revolution along with Apple’s Macintosh and Aldus Pagemaker.

  5. Introduction • The main purpose of PostScript was to provide a convenient language in which to describe images in a device-independent manner. • This allows a PS document to be printed on any PS-capable printer with little/no modification • PostScript is one of the main PDLs for today’s high-end printers since it is designed to represent a page in the form of vectors rather than bitmaps • allows pages to be printed at any resolution with no loss in quality • “Typesetter-quality” • PostScript is also the basis for many document file formats from Adobe products like • PDF (Acrobat Reader) • PSD (Photoshop) • AI (Illustrator)

  6. PostScript Programming Language • PostScript is • Interpreted • the data comes in as a stream, e.g. from a file, network connection or a printer port • the interpreter does not know when the stream will end • Stack-based • Postfix Notation • A program pushes arguments to an operator onto a stack and then invokes the operator. • The operator will have some result which is left at the top of the stack. • a Page Description Language (PDL) • many functions in PS are related to drawing lines, filled shapes, decoding image data like JPEG, and rendering these on the screen/printer

  7. Main Concepts • The following concepts are important to understanding PostScript (PS) • Stacks • Dictionaries • Names and Numbers

  8. PostScript Stacks • Three main stacks are used in PS • Operand/Operator Stack • Parameters • Procedure calls • Dictionary Stack • Variables • Procedure declarations • Execution Stack • for currently running procedures • not directly accessible by the programmer

  9. Some PS Stack Operations • Since PS is a stack-oriented language it has a number of built-in stack manipulation functions • clear (empty the stack) • dup (put a duplicate of the top element on the stack) • pop (remove the top element of the stack) • exch (exchange the top 2 stack elements) • roll (a way of moving stack elements)

  10. Dictionaries • A dictionary is a table that associates pairs of objects. An English dictionary associates words with their definitions. A POSTSCRIPT dictionary associates an object called a key with another object, the key’s value. • The POSTSCRIPT interpreter can look up a key in a dictionary and obtain the associated value (or discover that the key is not present). • PS implements procedures and variables through the use of dictionaries

  11. Dictionaries • There are 2 dictionaries available to the programmer • System Dictionary – used to contain all the built-in functions and their definitions • User Dictionary – used to contain all user defined procedures and variables • POSTSCRIPT dictionaries are kept on a dictionary stack, which starts out with the system dictionary on the bottom and the user dictionary on top.

  12. Dictionaries • A program may create new dictionaries, which can be placed on top of the dictionary stack. • When the interpreter encounters a name, it searches the dictionaries downward from the top of this stack. • The dictionary on top of the dictionary stack, and thus the first to be searched, is called the current dictionary. • Once a name has been found the search stops • This behaviour can be used to simulate scoping for local variables in procedures • This can also be used to redefine system functions

  13. Dictionaries • PS has no built-in scoping for variables and procedures (everything is global) • Dictionaries are used to “hide” other declarations by placing the “local” version higher in the Dictionary stack

  14. PostScript Data Types • POSTSCRIPT supports many data types common to other languages • ints • reals • booleans (“true” / “false”) • arrays (single dimension defined with [ ] ) • strings (special case array defined with ( ) ) • The types are not pre-declared but are determined on the fly by the PS interpreter

  15. Names and Numbers • Number • PostScript supports integers and reals, e.g. 1, 1.0, 1E10 • Name • A name is seen as being a reference to some value in a dictionary on the dictionary stack. • A name is any sequence of characters that can not be interpreted as a number. With the exception of spaces and certain reserved characters any character may be part of a name. • If a name is preceded by a slash, PostScript will place the name on the stack as an operand (a literal). • If the name has no slash, the interpreter will look up its value in the dictionary stack. • If the value for the name is a procedure object, the procedure will be evaluated. • If the value is not a procedure, the value will be pushed onto the operand stack.

  16. Defining Variables • A variable is defined by placing the variable’s name and value into the current dictionary. This is done with the def operator, as in the following program line: /ppi 72 def /sampleArray [0 0.0 (string)] • The slash preceding these characters indicates that the POSTSCRIPT interpreter should put this name on the stack as a literal and not immediately try to find it in a dictionary. • def takes the last two operands and places them into the dictionary (one operand is the key the other is the value associated to that key)

  17. Defining Variables • To redefine a variable simply re-declare it with a new value /ppi 100 def /ppi ppi 1 add def /sampleArray [1 1.0 (string2)] def • The value in the current dictionary will be replaced with the specified value • Variables can be undefined using the undef operator

  18. Defining Procedures • Procedures in PS are similar to arrays but are defined using curly braces {} • procedures are formally known as executable arrays • A procedure is defined by associating a name with an executable array via the def operator just like with variables • a procedure is used by simply placing the name on the stack. If parameters are needed by the procedure, these must also be placed on the stack prior to calling the procedure

  19. Control Structures • PostScript has a full set of comparison operators. • eq (=), ne (!=) • gt (>), ge (>=) • lt (<), le (<=), • These compare the top two items on the stack, which can be of any matching type, and return an object of type boolean, a true or false, on the stack.

  20. Conditionals • PostScript also has if and ifelse constructs • if takes a boolean value and an executable array • ifelse a boolean value and 2 executable arrays

  21. Loops • PostScript has several loop constructs • repeat • for • loop-exit • forall (specialized for loop for arrays and strings) • The loop body is provided via an executable array just like with conditionals

  22. Common Loop Examples • Repeat operator takes the following parameters • number of iterations • executable array • For operator takes the following parameters • loop counter initial value • loop counter increment • loop counter terminating value • executable array

  23. Loop-Exit • Some loops are meant to run indefinitely until a certain condition is met. • Loop operator takes only an executable array as a parameter • The executable array must have the exit operator present or an infinite loop will occur.

  24. Running PS • In order to run PS you will need a PostScript interpreter usually found in a printer. PS files are typically all ASCII text files. • A free software PS interpreter/viewer is available called GhostScript and it’s GUI is called GSView. • Binaries for most OSes can be found at http://www.ghostscript.com • PostScript specifications can be found at http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf

More Related