home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / postscript / faq / part7-10 < prev   
Encoding:
Internet Message Format  |  1995-07-19  |  34.6 KB

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!news.moneng.mei.com!news.ecn.bgu.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!newsfeed.internetmci.com!usenet.eel.ufl.edu!usenet.cis.ufl.edu!purdue!mozo.cc.purdue.edu!staff.cc.purdue.edu!root
  2. From: Allen Braunsdorf <postscript-faq@cc.purdue.edu>
  3. Newsgroups: comp.lang.postscript,comp.answers,news.answers
  4. Subject: PostScript monthly FAQ v2.4 07-18-95 [07-10 of 11]
  5. Followup-To: poster
  6. Date: 18 Jul 1995 22:05:31 GMT
  7. Organization: Purdue University
  8. Lines: 892
  9. Approved: news-answers-request@MIT.Edu
  10. Distribution: world
  11. Message-ID: <3uhb7b$iki@mozo.cc.purdue.edu>
  12. Reply-To: postscript-faq@cc.purdue.edu (PostScript FAQ comments address)
  13. NNTP-Posting-Host: staff.cc.purdue.edu
  14. Summary: Useful facts about the PostScript graphics programming language
  15. Archive-name: postscript/faq/part7-10
  16. Last-modified: 1995/04/20
  17. Version: 2.4
  18. Originator: root@staff.cc.purdue.edu
  19. Xref: senator-bedfellow.mit.edu comp.lang.postscript:34267 comp.answers:13176 news.answers:48775
  20.  
  21.                               -- PostScript -- 
  22.  
  23.                             Answers to Questions 
  24.  
  25.                     (the comp.lang.postscript FAQ v2.4) 
  26.  
  27.                               Allen Braunsdorf 
  28.  
  29.                         postscript-faq@cc.purdue.edu 
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.                      This FAQ is formatted as a digest. 
  37.  
  38.                 Most news readers can skip from one question 
  39.  
  40.                 to the next by pressing control-G. GNUs uses 
  41.  
  42.                    C-c C-n to skip to the next question. 
  43.  
  44.  
  45.     Changes since the last version are marked with a '|' in the table 
  46.     of contents and in the sections in the text-only format of the FAQ. 
  47.  
  48.     Now that there is Linux and NetBSD and BSD 386 UNIX IBM PC (and 
  49.     clone) users can run any of the X-windows and UNIX programs in the 
  50.     utilities section. See any of comp.os.linux.{ 
  51.     admin,development,help,misc}. Also, there is now GhostScript for 
  52.     the Macintosh. 
  53.  
  54.     Many thanks to Dan Carrigan for reformatting the books and 
  55.     publishers section. 
  56.  
  57.     The utilities index from the comp.sources.postscript FAQ will be 
  58.     posted in comp.lang.postscript now too. 
  59.  
  60.     Please help fix the FAQ! All comments should be mailed to 
  61.     postscript@cc.purdue.edu. My favorite way to receive a change 
  62.     suggestion is when it is accompanied by a section of the FAQ that 
  63.     is edited and mailed to me verbatim as an example. If you would 
  64.     like to contribute, please read the section ``about the FAQ'' 
  65.     first. Thank you! 
  66.  
  67.     Books and programs are referred to by name only. See the book 
  68.     sections for book information, and the comp.sources.postscript FAQ 
  69.     for a full list of all PostScript related programs. I have archived 
  70.     a number of the small utilities in 
  71.     wilma.cs.brown.edu:pub/postscript. You can get the 
  72.     comp.sources.postscript FAQ from 
  73.     wilma.cs.brown.edu:pub/comp.sources.postscript. 
  74.  
  75.     Related FAQs: comp.text, comp.text.tex, comp.fonts, comp.graphics, 
  76.     comp.sys.mac.apps, comp.sources.postscript. 
  77.  
  78.     7 Programming in PostScript 
  79.  
  80.  
  81.     7.1 What is PostScript level 2? 
  82.  
  83.     (See the Section 11, ``About PostScript 2''.) 
  84.  
  85.  
  86.     7.2 Should I learn level 2 PostScript? 
  87.  
  88.     Yes, because Level Two will soon become the standard. Application 
  89.     developers using PostScript need to become aware of the new 
  90.     capabilities and how to take advantage of them. 
  91.  
  92.     There are many good books on PostScript 2. (See Section 5, 
  93.     ``Books''.) 
  94.  
  95.  
  96.     7.3 Where can I find examples of PostScript code? 
  97.  
  98.     Many other books on PostScript make example PostScript code 
  99.     available. ``Thinking in PostScript'', by Glenn Reid, is the only 
  100.     book I know of that allows its examples to be freely distributed. 
  101.     (See Section 5, ``Books''.) 
  102.  
  103.     All the examples in ``the blue book'' are available from the Adobe 
  104.     file server (See Section 5, ``Books''.) 
  105.  
  106.     See the question ``How can I browse through PostScript programs?'' 
  107.     in the comp.sources.postscript FAQ. 
  108.  
  109.  
  110.     7.4 What is the physical size of the page? 
  111.  
  112.     This depends on what print medium you are using. Paper comes in a 
  113.     number of standard sizes: 
  114.  
  115.   
  116.           Paper Size                      Dimension (in points)
  117.           ------------------------------  ---------------------
  118.           Comm #10 Envelope               297 x 684
  119.           C5 Envelope                     461 x 648
  120.           DL Envelope                     312 x 624
  121.           Folio                           595 x 935
  122.           Executive                       522 x 756
  123.           Letter                          612 x 792
  124.           Legal                           612 x 1008
  125.           Ledger                          1224 x 792
  126.           Tabloid                         792 x 1224
  127.           A0                              2384 x 3370
  128.           A1                              1684 x 2384
  129.           A2                              1191 x 1684
  130.           A3                              842 x 1191
  131.           A4                              595 x 842
  132.           A5                              420 x 595
  133.           A6                              297 x 420
  134.           A7                              210 x 297
  135.           A8                              148 x 210
  136.           A9                              105 x 148
  137.           B0                              2920 x 4127
  138.           B1                              2064 x 2920
  139.           B2                              1460 x 2064
  140.           B3                              1032 x 1460
  141.           B4                              729 x 1032
  142.           B5                              516 x 729
  143.           B6                              363 x 516
  144.           B7                              258 x 363
  145.           B8                              181 x 258
  146.           B9                              127 x 181 
  147.           B10                             91 x 127
  148.   
  149.     To determine what print mediums are available, check the PPD file 
  150.     for your printer, under the PageSize keyword. 
  151.  
  152.  
  153.     7.5 What is the Imagable Area of the page 
  154.  
  155.     The initial clipping path gives you the size of the imagable area. 
  156.     Use ``clippath pathbbox'' to get these coordinates. If you must 
  157.     know the size of the device's imageable area, use the sequence 
  158.     ``gsave initclip clippath pathbbox grestore'', but this will 
  159.     prevent an enclosing application from using the clippath to achieve 
  160.     some special effects (such as multiple pages per page). 
  161.  
  162.     PPD files (see section 2 of the FAQ, printers) contain information 
  163.     on what paper sizes, as well as the Imagable Area for each, 
  164.     specific to each printer. A Postscript code fragment (called 
  165.     ``?ImageableArea'') is described in a PPD file, which determines 
  166.     the current Imageable Area for that printer. 
  167.  
  168.  
  169.     7.6 Why can't I do a pathforall after a charpath ? 
  170.  
  171.     (See Section 4, ``Fonts'', question ``Why are Adobe fonts 
  172.     hidden?''.) 
  173.  
  174.  
  175.     7.7 How do I center a string of text around a point? 
  176.  
  177.     Level 1 PostScript has two operators that can extract information 
  178.     about the metrics of characters: ``stringwidth'' and ``charpath''. 
  179.  
  180.     The ``stringwidth'' operator returns the advance width of its 
  181.     string operand. This is the distance the current point would be 
  182.     moved by a ``show'' operation on the same string. ``stringwidth'' 
  183.     returns two numbers on the stack, representing the x and y 
  184.     components of the advance width. Usually the y component is zero 
  185.     because most fonts are displayed along a horizontal line, moving 
  186.     the current point only in the x direction. 
  187.  
  188.     Also note that the ``stringwidth'' usually does not give an exact 
  189.     measure of the area of the page that will be touched by its 
  190.     operand. The letters can either project a little over the 
  191.     boundaries or fall a little within (leaving a touch of whitespace). 
  192.  
  193.     If all that an application requires is horizontal centering of a 
  194.     long string of text, the result returned by ``stringwidth'' is 
  195.     sufficient. A common technique is 
  196.  
  197.   
  198.           x y moveto
  199.           (string) dup stringwidth pop 2 div neg 0 rmoveto show
  200.   
  201.     (This code makes the assumption that the y component of advance 
  202.     width is irrelevant.) 
  203.  
  204.     The ``charpath'' operator extracts the graphic shapes of its string 
  205.     operand and appends them to the current path in the graphic state. 
  206.     These shapes can then be processed by other PostScript operators. 
  207.     To get the actual size of the area touched by a character a simple 
  208.     approach is 
  209.  
  210.   
  211.           gsave
  212.           newpath
  213.           0 0 moveto
  214.           (X) false charpath flattenpath pathbbox
  215.           grestore
  216.   
  217.     This code places four numbers on the stack, representing the 
  218.     coordinates of the lower left and upper right corners of the 
  219.     bounding box enclosing the character ``X'' rendered with the 
  220.     current point at (0,0). Leaving the flattenpath out will cause it 
  221.     to be less accurate, but it will take up less memory and be faster. 
  222.  
  223.     There are two things to be careful about when using the code shown 
  224.     above: 
  225.  
  226.  
  227.  
  228.    1. There are severe limits on the size of the string operand, 
  229.       related to the limit on the number of elements in a graphic path. 
  230.       The PostScript Language Reference Manual recommends taking 
  231.       ``charpath''s one character at a time. 
  232.  
  233.  
  234.    2. If user space is rotated or skewed with respect to device space, 
  235.       the result from ``pathbbox'' may be larger than expected; 
  236.       ``pathbbox'' returns a rectangle oriented along the user space 
  237.       coordinate axes, which fully encloses a (possibly smaller) 
  238.       rectangle oriented along the coordinate axes of device space. If 
  239.       user space is rotated at an integer multiple of 90 degrees these 
  240.       two rectangles will be the same, otherwise the rectangle in user 
  241.       space will be larger. 
  242.  
  243.     So, to center text vertically one must get the bounding boxes of 
  244.     all the characters in the string to be displayed, find the minimum 
  245.     and maximum y coordinate values, and use half the distance between 
  246.     them to displace the text vertically. This still may not do a very 
  247.     good job, since this provides centering based on extrema, not on 
  248.     the optical center of the string (which is more related to a sort 
  249.     of ``center of mass'' of the text). 
  250.  
  251.     If an application does this repeatedly, it would be wise to store 
  252.     the bounding boxes in an array indexed by character code, since 
  253.     ``charpath'' is a slow operation. 
  254.  
  255.     Font metric information is available outside of a PostScript 
  256.     printer in font metrics files, available from the font vendor. A 
  257.     program generating PostScript output can obtain metrics from these 
  258.     files rather than extracting the metrics in the printer. 
  259.  
  260.  
  261.     7.8 How can I concatenate two strings together? 
  262.  
  263.   
  264.   %% string1 string2 append string
  265.   % Function: Concatenates two strings together.
  266.   /append {
  267.            2 copy length exch length add  % find the length of the new.
  268.            string dup     % string1 string2 string string
  269.            4 2 roll       % string string string1 string2
  270.            2 index 0 3 index
  271.            % string string string1 string2 string 0 string1
  272.            putinterval    % stuff the first string in.
  273.            % string string string1 string2
  274.            exch length exch putinterval
  275.   } bind def
  276.   
  277.  
  278.     7.9 What do I do when I get stack overflow/underflow? 
  279.  
  280.     These errors are among the most common in PostScript. 
  281.  
  282.     When I get a stack overflow, that is usually a sign that a routine 
  283.     is leaving an object on the stack. If this routine gets called 2000 
  284.     times, it leaves 2000 objects on the stack, which is too many. 
  285.  
  286.     When I get a stack underflow, that is a sign that either: (A) one 
  287.     of the routines in the program doesn't work, and never has or (B) 
  288.     one of the routines in the program works, but expects to be called 
  289.     with some arguments left on the stack. 
  290.  
  291.     There is no such thing as a PostScript debugger right now. For now, 
  292.     the best that you can do to debug your program is to put in lots of 
  293.     print statements. Learn to use the PostScript pstack command, and 
  294.     use an online interpreter so you don't have to run to the printer 
  295.     for each debugging cycle. 
  296.  
  297.     Use an error handler to learn more about what exactly is happening 
  298.     when your program crashes. (see the comp.sources.postscript FAQ for 
  299.     a list of all PostScript related programs.) 
  300.  
  301.     If your code has never worked yet (i.e. you are still writing it) 
  302.     then I find that it helps to put little comments in the margin 
  303.     about the state of the stack. Like this: 
  304.  
  305.   
  306.          Heart pathbbox             % lowerx lowery upperx uppery
  307.          exch 4 -1 roll             % lowery uppery upperx lowerx
  308.   
  309.   
  310.     I generally put these comments in originally, and then take them 
  311.     out when the program works. Maybe this is a bad practice, in case I 
  312.     ever want to go back and look at the code to modify it!! 
  313.  
  314.  
  315.     7.10 How can I print in landscape mode? 
  316.  
  317.     Landscape (the opposite of portrait) means that the page is turned 
  318.     on its side. You can redefine showpage in terms of the current 
  319.     definition of showpage. 
  320.  
  321.     Do something like: 
  322.  
  323.   
  324.   /oldshowpage /showpage load def
  325.   
  326.   90 rotate llx neg ury neg translate   % for the first page
  327.   /showpage
  328.   {
  329.           oldshowpage
  330.           90 rotate llx neg ury neg translate
  331.   } def
  332.   
  333.     This won't work if the PostScript file you're editing uses 
  334.     initgraphics or grestoreall. Also note that the method described 
  335.     (redefining showpage) does not conform to the document structuring 
  336.     conventions. The Adobe recommended method involves performing the 
  337.     transformaton as part of the setup for each page. 
  338.  
  339.  
  340.     8 Computer-specific PostScript 
  341.  
  342.     This section describes PostScript information specific to a 
  343.     particular type of computer or operating system. 
  344.  
  345.  
  346.     8.1 Sun Workstations 
  347.  
  348.     What is NeWS? 
  349.  
  350.     NeWS (R.I.P.) was Sun Microsystems PostScript-based window system 
  351.     for the Sun Workstation. NeWS was a project within Sun (started 
  352.     around 1985) to create a window system to supplant SunView (a very 
  353.     successful kernel-based window system). NeWS was a client-server 
  354.     model window system (like X) but among many of NeWS novel features 
  355.     was the use of PostScript as the language to describe the 
  356.     appearance of objects on the screen. NeWS had many features in 
  357.     common with Display PostScript, but NeWS predates Adobe Display 
  358.     PostScript and was neither connected with Adobe Display PostScript 
  359.     nor endorsed by Adobe. NeWS was not an Adobe product, nor was it a 
  360.     Sun/Adobe joint venture. 
  361.  
  362.     As of October 1992, Sun management signed a deal with Adobe to 
  363.     adopt Display PostScript for the Sun. In 1993, Sun finally dropped 
  364.     NeWS altogether. The Sun window system is supposed to start 
  365.     shipping a Display PostScript environment in late 1993. 
  366.  
  367.     And how does PostScript run on them? 
  368.  
  369.     PostScript runs on NeWS, although NeWS was not a fully-compliant 
  370.     PostScript interpreter. There were incompatibilities between the 
  371.     NeWS PostScript interpreter and ``official'' PostScript 
  372.     interpreters as defined by Adobe and the Apple LaserWriter family 
  373.     of printers, such that many PostScript files which would print fine 
  374.     on a LaserWriter would not render under NeWS. The most critical 
  375.     incompatibility was lack of support for Adobe Type 1 fonts, Sun 
  376.     having gone with their own font format known as F3. F3 fonts have 
  377.     now gone the way of the zumbooruk and will be supplanted by Type 1 
  378.     fonts. 
  379.  
  380.  
  381.     8.2 IBM PC 
  382.  
  383.     You can find nenscript for OS/2 1.x--2.0 and MSDOS on 
  384.     ftp-os2.nmsu.edu in pub/uploads/nensc113.zip. 
  385.  
  386.     Microsoft Word for Windows can produce files with incorrect DSC 
  387.     comments. To fix this, from the Control Panel, select Printers, 
  388.     Options..., Advanced, and then check 'Conform to Adobe Document 
  389.     Structuring conventions'. This is not enough to produce a valid DSC 
  390.     document - you also need to remove the leading Ctrl-D as documented 
  391.     in PRINTERS.WRI. 
  392.  
  393.     There are rumors that Word Perfect and Microsoft Word don't produce 
  394.     ``clean'' PostScript that follows the DSC conventions (See Section 
  395.     9, ``Encapsulated PostScript''). This means that a lot of 
  396.     PostScript utilities like Ghostview and psnup, etc., that require 
  397.     the DSC conventions, will not work on them. 
  398.  
  399.     Creating a PostScript file from MS Word 
  400.  
  401.     Install the LaserWriter driver that comes with Windows.In the 
  402.     printer setup, select a PostScript printer. Then click on the setup 
  403.     button to get that pop-up. Then clik the Options button. Then 
  404.     select the print to Encapsulated PostScript File. If you don't 
  405.     specify a file name, Word will prompt you for one when you tell it 
  406.     to print. 
  407.  
  408.     When printing Microsoft Windows files that have been captured on a 
  409.     PC's LPT port, you mostly need to define two ctrl-d's in a row as 
  410.     well to remove all of them in the document: 
  411.  
  412.   
  413.   (\004\004) cvn {} def
  414.   
  415.  
  416.     8.3 Apple Macintosh 
  417.  
  418.     For more details about printing with the Macintosh, read the 
  419.     comp.sys.mac.apps FAQ. 
  420.  
  421.     How can I convert a PostScript file created with a UNIX program to 
  422.     the Mac? 
  423.  
  424.     A way that is clumsy, but works, is this: 
  425.  
  426.  
  427.  
  428.    1. Display the UNIX-based PostScript file on screen 
  429.  
  430.  
  431.    2. Use window dumping facility to get a bitmap file 
  432.  
  433.  
  434.    3. Convert the above bitmap file to TIFF format and then export it 
  435.       to Adobe Illustrator on the Mac. 
  436.  
  437.     The PostScript section of the FAQ for the Macintosh newsgroup 
  438.     comp.sys.mac.apps (maintained by Elliotte Harold) answers the 
  439.     following questions: 
  440.  
  441.  
  442.  
  443.     * How do I make a PostScript file? 
  444.  
  445.  
  446.     * How do I print a PostScript file? 
  447.  
  448.  
  449.     * Why won't my PostScript file print on my mainframe's printer? 
  450.  
  451.       Full documentation of this process provided with a utility called 
  452.       macps. 
  453.  
  454.  
  455.     * Why are my PostScript files so big? 
  456.  
  457.  
  458.     8.4 NEXTSTEP 
  459.  
  460.     NEXTSTEP, the system software from NeXT Computer, Inc. uses Display 
  461.     PostScript as one of its primary components. Because of this, most 
  462.     PostScript activities are very easy and supported by many 
  463.     applications. 
  464.  
  465.     For more information on NeXT and NEXTSTEP, please see 
  466.     http://www.next.com. 
  467.  
  468.     9 Encapsulated PostScript 
  469.  
  470.  
  471.     9.1 What is Encapsulated PostScript? 
  472.  
  473.     Encapsulated PostScript (EPS) is a standard format for importing 
  474.     and exporting PostScript language files in all environments. It is 
  475.     usually a single page PostScript language program that describes an 
  476.     illustration. The purpose of the EPS file is to be included as an 
  477.     illustration in other PostScript language page descriptions. The 
  478.     EPS file can contain any combination of text, graphics, and images. 
  479.     An EPS file is the same as any other PostScript language page 
  480.     description, with some restrictions. 
  481.  
  482.     EPS files can optionally contain a bitmapped image preview, so that 
  483.     systems that can't render PostScript directly can at least display 
  484.     a crude representation of what the graphic will look like. There 
  485.     are three preview formats: Mac (PICT), IBM (tiff), and a platform 
  486.     independent preview called EPSI. 
  487.  
  488.     An EPS file must be a conforming file, that is, it must conform to 
  489.     the Adobe Document Structuring Conventions (DSC). At a minimum, it 
  490.     must include a header comment,%!PS-Adobe-3.0 EPSF-3.0, and a 
  491.     bounding box comment,%%BoundingBox: llx lly urx ury, that 
  492.     describes the bounds of the illustration. 
  493.  
  494.     (The specification does not require the EPSF version, but many 
  495.     programs will reject a file that does not have it.) 
  496.  
  497.     The EPS program must not use operators that initialize or 
  498.     permanently change the state of the machine in a manner that cannot 
  499.     be undone by the enclosing application's use of save and restore 
  500.     (eg. the operators starting with ``init'' like initgraphics). As a 
  501.     special case, the EPS program may use the showpage operator. The 
  502.     importing application is responsible for disabling the normal 
  503.     effects of showpage. 
  504.  
  505.     The EPS program should make no environment-sensitive decisions (the 
  506.     importing application may be trying to attain some special effect, 
  507.     and the EPS program shouldn't screw this up), although it can use 
  508.     some device-dependent tricks to improve appearance such as a 
  509.     snap-to-pixel algorithm. 
  510.  
  511.     The complete EPS specification is available from Adobe (see the 
  512.     section on Adobe). Read Appendix G (Document Structuring 
  513.     Conventions, V3.0) and Appendix H (Encapsulated PostScript File 
  514.     Format, V3.0) in the new PostScript red book: PostScript Language 
  515.     Reference Manual, Second Edition. 
  516.  
  517.     An optional component of an EPS file is a ``preview'' image of the 
  518.     file's content. The preview image is a bitmapped representation of 
  519.     the image which may be displayed by programs using the EPS file 
  520.     without having to actually interpret the PostScript code. 
  521.  
  522.     The recommended form for a preview image is ``Interchange'' format 
  523.     and is described fully in the ``red book'', second edition. 
  524.     Interchange format represents the image as a series of hex strings 
  525.     placed in the EPS file as PostScript comments. The entire file 
  526.     remains an ASCII file. 
  527.  
  528.     That book contains all of the information that you need to fix your 
  529.     program to correctly output EPS. It is what I use for our software. 
  530.  
  531.     A variation of EPS embeds the preview image and PostScript text in 
  532.     a binary file which contains a header and the preview image in 
  533.     either a TIFF or MetaFile format. The header defines where in the 
  534.     file each section (EPS, TIFF, or MetaFile) starts and ends. On the 
  535.     Macintosh, the preview is stored as a PICT in the file's resource 
  536.     fork. 
  537.  
  538.  
  539.     9.2 What are EPSI and EPSF? 
  540.  
  541.     EPSI is EPS with a device independent bitmap preview. EPSI is an 
  542.     all ASCII (no binary data or headers) version of EPS. EPSI provides 
  543.     for a hexadecimal encoded preview representation of the image that 
  544.     will be displayed or printed. EPSI files were documented by Adobe 
  545.     as a means of providing a preview for EPS files which would be 
  546.     cross-platform. In reality though DOS machines and Windows favour 
  547.     embedding TIFF or even Windows Metafiles in the PostScript. I don't 
  548.     know of any Mac packages that support EPSI files. 
  549.  
  550.     The Macintosh has always favoured EPSF files with the data fork of 
  551.     the file containing the PostScript code, and the resource fork 
  552.     containing a PICT preview of the file. This is how typically when 
  553.     you import an EPSF file into a program (Quark, Persuasion etc.) you 
  554.     get to see the PICT preview from the file. It is still possible to 
  555.     have an EPSF file without a preview though, in this case the 
  556.     imported artwork is displayed usually as a box with diagonal lines 
  557.     running through it. Note the term EPSF really means that the image 
  558.     is independant of an output device, in other words the image would 
  559.     need to be embedded inside other PostScript code to be usable 
  560.     (printable). The old command-lk files from the PS driver on the Mac 
  561.     are not EPSF files as they are produced for a specific output 
  562.     device (LaserWriter). Therefore they cannot be imported into other 
  563.     applications for printing. ESPF must be given resource number 256. 
  564.  
  565.  
  566.     9.3 How do I convert PostScript to EPS? 
  567.  
  568.     Use pstoepsi, or do it by hand. GhostScript's program ps2epsi does 
  569.     this also, as does LaserWriter 8 for the Mac. GhostScript on the 
  570.     Mac can output EPS also, I believe. 
  571.  
  572.     To convert from PostScript to EPS, one must guarantee that the 
  573.     PostScript file meets the above requirements. If the actual program 
  574.     conforms to the programming requirements, then one can simply add 
  575.     the required comments at the top of the file saying that the file 
  576.     is EPS and giving its BoundingBox dimensions. 
  577.  
  578.     Optional comments include font usage (%%DocumentFonts: or%% 
  579.     DocumentNeededResources: font), EPSI preview comments (%% 
  580.     Begin(End)Preview:) extensions (%%Extensions:) and language 
  581.     level (%%LanguageLevel:). 
  582.  
  583.     There are some operators that should not be used within an EPS 
  584.     file: 
  585.  
  586.   
  587.           banddevice     cleardictstack   copypage     erasepage
  588.           exitserver     framedevice      grestoreall  initclip
  589.           initgraphics   initmatrix       quit         renderbands
  590.           setglobal      setpagedevice    setshared    startjob
  591.   
  592.     These also include operators from statusdict and userdict operators 
  593.     like legal, letter, a4, b5, etc. 
  594.  
  595.     There are some operators that should be carefully used: 
  596.   
  597.           nulldevice     setgstate        sethalftone  setmatrix
  598.           setscreen      settransfer      undefinefont
  599.   
  600.     To convert a PostScript file to EPS format, you must edit the file 
  601.     using a text editor or word processor to add lines that will define 
  602.     the file as an EPS-format file. 
  603.  
  604.  
  605.  
  606.    1. Using your normal method of printing, print the PostScript file 
  607.       to a PostScript printer. You can choose to view it on the screen 
  608.       instead, but keep in mind that all the below distance 
  609.       measurements assume that you are printing on a normal-sized piece 
  610.       of paper. 
  611.  
  612.       NOTE: If the PostScript image does not get displayed properly, it 
  613.       probably will not work either once you have converted it to EPS 
  614.       format. Correct the PostScript program so that it works before 
  615.       you convert it to EPS format. 
  616.  
  617.  
  618.    2. Use a tool (see below) to find the bounding box, which shows how 
  619.       much space the PostScript image occupies when printed. You 
  620.       specify the dimensions of the bounding box when you convert the 
  621.       PostScript file to EPS format. 
  622.  
  623.  
  624.    3. If you don't have a bounding box tool, you can just use a ruler 
  625.       and draw one on your printout. With two horizontal lines and two 
  626.       vertical lines, draw a box around the image that includes the 
  627.       entire image while minimizing white space. 
  628.  
  629.       This box represents your bounding box. You may want to leave a 
  630.       small amount of white space around the image as a precautionary 
  631.       measure against minor printing problems, such as paper stretching 
  632.       and paper skewing. 
  633.  
  634.  
  635.    4. Measure distance ``a'' from the lower-left corner of the image to 
  636.       the left edge of the paper. 
  637.  
  638.  
  639.    5. Write the measurement in points. If your ruler does not show 
  640.       points, calculate the total number of points: 1 inch = 72 points, 
  641.       1 cm = 28.3 points, and 1 pica = 12 points. Designate this 
  642.       measurement as ``measurement a.'' 
  643.  
  644.  
  645.    6. Measure distance ``b'' from the lower-left corner of the image to 
  646.       the bottom edge of the paper. 
  647.  
  648.       Designate this measurement in points as ``measurement b.'' 
  649.  
  650.  
  651.    7. Measure distance ``c'' from the upper-right corner of the image 
  652.       to the left edge of the paper. 
  653.  
  654.       Designate this measurement in points as ``measurement c.'' 
  655.  
  656.  
  657.    8. Measure distance ``d' from the upper-right corner of the image to 
  658.       the bottom edge of the paper. 
  659.  
  660.       Designate this measurement in points as ``measurement d.'' 
  661.  
  662.  
  663.    9. Using any text editor, open the PostScript file for editing. 
  664.  
  665.       You'll see several lines of text. These lines are the PostScript 
  666.       description of the image. The lines at the top of the file are 
  667.       the header. 
  668.  
  669.  
  670.   10. Add these lines to, or modify existing lines in, the header (the 
  671.       first group of lines in any PostScript file): 
  672.  
  673.     
  674.             %!PS-Adobe-2.0 EPSF-2.0
  675.             %%Creator: name
  676.             %%CreationDate: date
  677.             %%Title: filename
  678.             %%BoundingBox: a b c d
  679.     
  680.  
  681.       Note: Make sure that the first line in the file is ``% 
  682.       !PS-Adobe-2.0-EPSF-2.0''. Also, do not separate the header lines 
  683.       with a blank line space. The first blank line that PostScript 
  684.       encounters tells it that the the next line begins the body of the 
  685.       program. 
  686.  
  687.       For ``name,'' type your name or initials. For ``date,'' type 
  688.       today's date using any format (for example, MM-DD-YY, MM/DD/YY, 
  689.       July 5, 1987, and so on). For ``filename,'' type the name of the 
  690.       PostScript file. After ``BoundingBox: ,'' type the measurements 
  691.       you took in steps 3, 4, 5, and 6, separating each with a space: 
  692.       ``a'' is the measurement from Step 3, ``b'' is the measurement 
  693.       from Step 4, ``c'' is the measurement from Step 5, and ``d'' is 
  694.       the measurement from Step 6. 
  695.  
  696.  
  697.   11. Save the file in text-only format. 
  698.  
  699.     If you are interested in learning how to further edit your 
  700.     PostScript files, these books are available at most bookstores: 
  701.  
  702.     Understanding PostScript Programming and the green book. 
  703.  
  704.     The Document Structuring Conventions (DSC), version 1.0, are 
  705.     discussed in Appendix C of the old red book. The new red book has a 
  706.     lot of information about Encapsulated PostScript. 
  707.  
  708.     There will be a technical note available from Adobe called 
  709.     ``Guidelines for Specific Operators'' that will talk about why some 
  710.     operators are prohibited and how to use the others. 
  711.  
  712.  
  713.     9.4 How do I get the bounding box of a PostScript picture? 
  714.  
  715.     Use bbfig or epsinfo.ps. 
  716.  
  717.     Or if you would rather construct the bounding box by hand, use 
  718.     Ghostview, which has a continuous readout of the mouse cursor in 
  719.     the default user coordinate system. You simply place the mouse in 
  720.     the corners of the figure and read off the coordinates. 
  721.  
  722.     10 About The Comp.Lang.PostScript FAQ 
  723.  
  724.  
  725.     10.1 The PostScript FAQ: What is it? 
  726.  
  727.     The PostScript FAQ is a set of answers to frequently asked 
  728.     questions (FAQs) that have appeared on the Usenet newsgroup 
  729.     comp.lang.postscript. It is broken into many useful sections. 
  730.  
  731.     There is a companion file which is not posted to USENET called 
  732.     ``Exactly What Does a Transformation Matrix Do?''. You can get it 
  733.     from wilma.cs.brown.edu:pub/comp.lang.postscript/transform.tex. 
  734.  
  735.     I need help writing and revising answers for common questions 
  736.     relating to PostScript. Almost all of the information in the 
  737.     documents has been written by kind volunteers. The answers will be 
  738.     published in either or both documents. A very long answer in the 
  739.     Usenet Guide may be summarized, referred to briefly, or not 
  740.     mentioned at all in the FAQ. 
  741.  
  742.  
  743.     10.2 How to get the FAQ files 
  744.  
  745.     The FAQ is available by anonymous ftp to 
  746.     wilma.cs.brown.edu:pub/comp.lang.postscript/ You can get it 
  747.     formatted in plain text ASCII, LaTeX, or PostScript. 
  748.  
  749.     I would be happy to email a copy of the FAQ in any format to you if 
  750.     you do not have FTP (or a Web browser that supports FTP). 
  751.  
  752.  
  753.     10.3 How to write a FAQ answer 
  754.  
  755.     I greatly appreciate your time and effort to help improve the 
  756.     quality of the FAQ. Thank you for being willing to contribute! 
  757.  
  758.  
  759.     * Please check to see if the topic is already in an FAQ. Perhaps 
  760.       you really mean to submit a revision to an existing section. 
  761.  
  762.     * Start with a clear statement about what problem you are solving. 
  763.  
  764.     * Write for novice users, in ``tutorial format'', even if the 
  765.       answer is meant for experienced programmers. 
  766.  
  767.     * Be specific when you make references. 
  768.  
  769.     * Be complete, and take the time to look over your draft and 
  770.       revise. 
  771.  
  772.     * Answers should not be too wordy, unless you intend to write a 
  773.       long answer for the Usenet Guide and have a shorter summary or a 
  774.       pointer to the description placed in the FAQ. If you want to 
  775.       write the summary yourself, thanks! 
  776.  
  777.     * Obviously, I cannot accept copyrighted material without 
  778.       permission. Don't write the FAQ by paraphrasing from a 
  779.       copyrighted book! 
  780.  
  781.  
  782.     10.4 The FAQ can contain LaTeX and PostScript inserts 
  783.  
  784.     The FAQ is actually written with LaTeX, so feel free to submit with 
  785.     that text formatting language. There is a PostScript version of the 
  786.     FAQ also, so feel free to send along PostScript pictures to 
  787.     include. 
  788.  
  789.  
  790.     10.5 Revising the FAQ 
  791.  
  792.     Suggestions and comments are welcomed. My favorite way of receiving 
  793.     a change suggestion is if you make a copy of the FAQ, edit the 
  794.     copy, and mail me the modification, or a context diff (include the 
  795.     version number). 
  796.  
  797.  
  798.     10.6 How to submit new information 
  799.  
  800.     If you know something that you think is worthwhile to be put in a 
  801.     FAQ, definitely send it to me! 
  802.  
  803.     Don't hold back if your information is very specific. If there's 
  804.     too much information to post I will archive it at an ftp site and 
  805.     place a pointer to it in the FAQ. 
  806.  
  807.  
  808.     10.7 How to add a program description to the FAQ index 
  809.  
  810.     If the program is original, please send it to me, or tell me where 
  811.     I can get it. Please put your name and email address at the top of 
  812.     each file. Your program will be doubly useful if you clean up the 
  813.     program so that other people can use it as an example to learn. 
  814.  
  815.     If the program was written by someone else, please send me just the 
  816.     title, description, and where to get it. I may already have it. 
  817.  
  818.     For programs the FAQ needs to know: 
  819.  
  820.  
  821.     * What is the name of the program? 
  822.  
  823.     * What does it claim to do, and does it do it well? Is it worth 
  824.       using? 
  825.  
  826.     * Where is it available? What ftp sites can I get it from? 
  827.  
  828.     * How much does it cost? Is it free? 
  829.  
  830.     * What kinds of computers does it run on? 
  831.  
  832.     * Who is the author and does the author give an email address? 
  833.  
  834.     * Does it handle PostScript 2? 
  835.  
  836.     * What packages does it rely on? 
  837.  
  838.     If the program is a PostScript interpreter, then the FAQ also needs 
  839.     to know: 
  840.  
  841.  
  842.     * Does it let you go backwards one page? 
  843.  
  844.     * Does it display the number of pages in the document? 
  845.  
  846.     * Does it let you print PostScript to a non-PostScript printer? 
  847.  
  848.     * What formats can it convert to? 
  849.  
  850.  
  851.     10.8 How to add a book description to the FAQ 
  852.  
  853.     For books the FAQ needs to know: 
  854.  
  855.  
  856.     * What is the name of the book or document? 
  857.  
  858.     * What does it claim to do, and does it do it well? Is it worth 
  859.       using? 
  860.  
  861.     * Can I get it on-line? 
  862.  
  863.     * Who wrote it? Does the author give an email address? 
  864.  
  865.     * Who is the publisher, and what is the copyright date? 
  866.  
  867.     * Does the publisher list an address and phone number or fax 
  868.       number? 
  869.  
  870.     * What is the ISBN number of the book? 
  871.  
  872.     * What is the library call number of the book? 
  873.  
  874.     * How much does the book cost? 
  875.  
  876.     * Does it cover PostScript 2? 
  877.  
  878.     * Are coding examples from the book available by email or anonymous 
  879.       ftp? 
  880.  
  881.     * Do the authors sell the coding examples on a diskette? 
  882.  
  883.  
  884.     10.9 Questions that need answers 
  885.  
  886.  
  887.  
  888.    1. Where are ftp sites that have PostScript freeware? 
  889.  
  890.  
  891.    2. What vendors sell fonts for PostScript printers? Where are the 
  892.       free ftp sites for them? 
  893.  
  894.  
  895.    3. Are there any free encapsulated PostScript converters? 
  896.  
  897.  
  898.    4. What is the charter for comp.lang.postscript? 
  899.  
  900.  
  901.    5. What questions should the FAQ have? 
  902.  
  903.  
  904.    6. What book information is wrong or missing in the FAQ? 
  905.  
  906.  
  907.    7. What program information is wrong or missing in the FAQ? 
  908.  
  909.  
  910.    8. What ftp site have good examples of PostScript code? 
  911.  
  912.  
  913.