• What is PostScript?


    What is PostScript?

    PostScript is a computer language designed explicitly for page description -- for printing graphics and text. It was introduced in 1985 by Adobe and is a great way to describe images in perfect precision and in a device-independent manner.

    The language itself is in ASCII text and can be viewed (though perhaps not comprehended!!) in your text editor. Normally you are not intended to edit PostScript manually, but it is certainly possible, if you know the language. PostScript code, which is typically interpreted, is stack-based in the same manner as an RPN calculator. A program pushes arguments to an operator onto a stack and then invokes the operator. Typically, the operator will have some result which is left at the top of the stack. As an example, let us say we want to multiply 12 and 134. We would use the following PostScript code:

    12 134 mul
    The first two words '12' and '134' push the numbers 12 and 134 onto the stack. 'mul' invokes the multiply operator which pops two values off the stack, multiplies them, and then pushes the result back onto the stack. The resulting value can be left there to be used by another operator later in the program.

    Another example is drawing purple line segments, with a line thickness of 10 points (approx 10/72 inches):

    10 setlinethickness		% self-explanatory
    0.62 0.13 0.93 setrgbcolor	% purple!
    50 50 moveto  300 500 lineto 50 500 lineto stroke
    
    The default coordinate system for an 8.5"×11" page (``letter size'') is 0 0 in the lower left corner to 612 792 in the upper right. Among the top few lines of a well-constructed PostScript file is bounding box information.

    Fonts can be defined in a PostScript file, though it isn't necessary for basic fonts like Times, Helvetica and Courier. Figures and fonts can then be placed on a page using PostScript commands which give concise results with arbitrary resolution. It is also possible to describe bitmap images in PostScript, which results in huge file size and limited resolution.


    TOP

    How do we tell if a file is in PostScript format?

    If you are on a Unix computer, and the name of the file in question is myfilexxx, then use the file command like this:
    newton>  file myfilexxx
    
    Or, if you don't mind taking a peek at the contents of the file, use a text editor (or a Unix command like ``top'') to check the first 2 characters of the top line of the file. PostScript files must always begin with the 2 characters ``%!''.
    In some hp print,PostScript files don't begin with the 2 characters "%!", it will add some other chars like this:
    ....
    %-12345X@PJL JOB
    @PJL SET HOLD=OFF
    @PJL SET RESOLUTION = 600
    @PJL SET BITSPERPIXEL = 2
    @PJL SET ECONOMODE = OFF
    @PJL ENTER LANGUAGE = POSTSCRIPT
    newton>  top -5 myfilexxx
    %!PS-Adobe-2 EPSF-2
    %%BoundingBox: 6 6 606 790
    %%BeginFont
    11 dict begin
    


    TOP

    What is the difference between Encapsulated PostScript and (plain) PostScript?

    An Encapsulated PostScript file is not intended to be printed by itself. It is a single image, not a whole page or multiple pages, and is intended to be included as part of a larger document. In particular, an EPS file won't necessarily include the PostScript command ``showpage'', which is the cue to a printer to actually print the page. That is, an EPS file may not print by itself! Sometimes it will, but don't count on it. After all, by definition, an EPS file is intended to be encapsulated inside a larger document, not stand by itself.

    Because an EPS image is intended to be inserted inside a larger document, it is crucial that it have accurate bounding box information, so that the documentation software knows the size of that image.

    Otherwise, an EPS file is just like any PostScript file; it may consist of a bitmap image, or it may consist of font definitions and drawing commands. Common usage names EPS files with the suffix .eps, and (printable/multipage) PostScript files with .ps. Of course, it is the content of the file which counts; just naming a file ``*.eps'' doesn't make it EPS.


    TOP

    Are EPS files always bitmap images?

    No.

    An EPS file may consist of a bitmap image, but then, any PostScript can contain bitmap images. Bitmapped images are only one of dozens of possible PostScript entities, which include text, lines/polygons, arcs/ellipses and bezier curves.

    Bitmap images only make sense in the case of photographic images. Expressing mathematical images, drawings, graphs and text as rectangular array of pixels -- bitmaps -- is inefficient and crude. Such images are defined more concisely and look better when defined with PostScript commands in terms of arcs, polygons, colors, coordinates, etc.


    TOP

    How do we tell whether a file is Encapsulated-PostScript or just PostScript?

    First, make sure that the file is indeed PostScript (see how, above).

    If the top line of the file says something like ``%!PS-Adobe-3.0 EPSF-3.0'' then it is an Encapsulated PostScript single image. If it just says ``%!PS-Adobe-3.0'' then it is a PostScript (possibly multi-page) document.

    Or, check the number of pages. A standard-conforming PostScript file includes a comment line near the top naming the number of pages, so you could try grepping for the string ``%%Pages'', like this:

    newton>  grep '%%Pages' myfilexxx
    
    If that line says ``%%Pages: 0'' then it's definitely Encapsulated PostScript. If it says ``%%Pages: 1'' then it can serve as Encapsulated, whether or not it was created with that intent. But if the number of pages exceeds 1 then it is definitely *not* EPS. (You could also just preview the file with ghostview to see whether it has only one page or not.)

    Finally, the command ``showpage'' in a PostScript file is what instructs a printer to print a page. Sometimes it works to grep for that word; if it occurs only once (or not at all) in a PostScript file, then that file can be considered Encapsulated.


    TOP

    What is PDF?

    Portable Document Format is a document-description language also created by the Adobe, Inc., and it is based on PostScript. PDF files are typically, but not necessarily, named with a *.pdf suffix. If you run the command ``file'' on such a file, it will be correctly identified:
    newton>  file myfilexxx
    myfilexxx:       Adobe Portable Document Format (PDF) v1.2
    
    You cannot print a PDF file using lp nor can you preview it using ghostview. Instead, use acroread (or Acrobat Reader), a free PDF reader provided by Adobe. With this reader you can display a PDF document at any magnification on the computer, and print selected pages using the menu. (The PDF reader converts pages to PostScript when sending them to a PostScript printer.)

    Since Adobe's PDF reader is of high quality and is free, it is reasonable to expect all of our webpage readers to have it on their computers (certainly all the ITS labs' computers do), so this is an ideal format for posting documents. It combines good quality and resolution when displayed on monitors (using the Adobe reader) with good quality and resolution when sent to the printer, with compact file size. Your PostScript document can be converted to PDF using the command ps2pdf. (In the case of LaTeX documents, bypass PostScript entirely by converting your DVI file directly to PDF using dvipdf.)

  • 相关阅读:
    centos7上以RPM方式安装MySQL5.6
    区别和详解:jQuery extend()和jQuery.fn.extend()
    jQuery笔记总结
    CSS Hack的一些知识
    12种不宜使用的javascript的语法
    64位Win7系统下vs2010调试无法连接oracle解决办法
    HashCode()与equals()深入理解
    Java ArrayList自动扩容机制
    Java基础知识
    MySQL的MVCC机制
  • 原文地址:https://www.cnblogs.com/umlchina/p/printandpostscript.html
Copyright © 2020-2023  润新知