Path: utzoo!mnetor!uunet!husc6!endor!olson From: olson@endor.harvard.edu (Eric K. Olson) Newsgroups: comp.lang.postscript Subject: Re: Encapsulated PostScript Message-ID: <3608@husc6.harvard.edu> Date: 18 Dec 87 19:19:07 GMT References: <488@tetons.UUCP> Sender: news@husc6.harvard.edu Reply-To: olson@endor.UUCP (Eric K. Olson) Organization: Lexington Software Design Lines: 168 In a recent article Greg Darnell writes: > >Can anyone tell me what "Encapsulated" PostScript is? ... >Any information on the definition, an example or a reference would >be greatly appreciated. Thanks. Description: A set of commenting conventions and additional rules for Postscript procedures. Comments can be figured out from the following example. Other rules include: Don't use banddevice, copypage, erasepage, exitserver framedevice grestoreall, initclip, initgraphics, initmatrix, legal, letter, note, nulldevice, quit, renderbands, setpageparams, setdevice, setsccbatch, setmatrix, or stop. Showpage is permitted, but will be disabled by the importing application. All stacks should end as they started. Do not overnest save/restore and gsave/grestore, since the importing file might already have used a lot of the (limited) nesting levels. EPS files also usually have an optional low-resolution picture in the Resource Fork if they are on a Macintosh. IBM EPS files have a small header: long 'EPSF' long byte position in file for PS start long byte length of PS long byte position in file for MetaFile screen representation long byte length of screen representation long byte position in file of TIFF screen representation long byte length of TIFF short checksum (XOR of bytes 0-27 in file; ignored if FFFF) position and length for MetaFile and TIFF may be 0 and will be ignored. Reference: AltSys Corporation Attn: Jim Von Ehr 720 Ave. F, Suite 108, Dept. EPS Plano, TX 75074 (214) 424-4888 MCI: ALTSYS Example of Encapsulated Postscript: Taken from Adobe Illustrator 1.1; draws a box. %!PS-Adobe-2.0 EPSF-1.2 %%Creator:Adobe Illustrator(TM) 1.1 M00004385N %%For:Eric K. Olson Pixelogic, Inc. %%Title:Box.epsf.mac %%CreationDate:12/18/87 2:09 PM %%DocumentProcSets:Adobe_Illustrator_1.1 0 0 %%DocumentSuppliedProcSets:Adobe_Illustrator_1.1 0 0 %%DocumentFonts:Courier %%BoundingBox:23 -138 144 -21 %%TemplateBox:288 -360 288 -360 %%EndComments %%BeginProcSet:Adobe_Illustrator_1.1 0 0 % Copyright (C) 1987 Adobe Systems Incorporated. % All Rights Reserved. % Adobe Illustrator is a trademark of Adobe Systems Incorporated. /Adobe_Illustrator_1.1 dup 100 dict def load begin /Version 0 def /Revision 0 def % definition operators /bdef {bind def} bind def /ldef {load def} bdef /xdef {exch def} bdef % graphic state operators /_K {3 index add neg dup 0 lt {pop 0} if 3 1 roll} bdef /_k /setcmybcolor where {/setcmybcolor get} {{1 sub 4 1 roll _K _K _K setrgbcolor pop} bind} ifelse def /g {/_b xdef /p {_b setgray} def} bdef /G {/_B xdef /P {_B setgray} def} bdef /k {/_b xdef /_y xdef /_m xdef /_c xdef /p {_c _m _y _b _k} def} bdef /K {/_B xdef /_Y xdef /_M xdef /_C xdef /P {_C _M _Y _B _k} def} bdef /d /setdash ldef /_i currentflat def /i {dup 0 eq {pop _i} if setflat} bdef /j /setlinejoin ldef /J /setlinecap ldef /M /setmiterlimit ldef /w /setlinewidth ldef % path construction operators /_R {.25 sub round .25 add} bdef /_r {transform _R exch _R exch itransform} bdef /c {_r curveto} bdef /C /c ldef /v {currentpoint 6 2 roll _r curveto} bdef /V /v ldef /y {_r 2 copy curveto} bdef /Y /y ldef /l {_r lineto} bdef /L /l ldef /m {_r moveto} bdef % error operators /_e [] def /_E {_e length 0 ne {gsave 0 g 0 G 0 i 0 J 0 j 1 w 10 M [] 0 d /Courier 20 0 0 1 z [0.966 0.259 -0.259 0.966 _e 0 get _e 2 get add 2 div _e 1 get _e 3 get add 2 div] e _f t T grestore} if} bdef /_fill {{fill} stopped {/_e [pathbbox] def /_f (ERROR: can't fill, increase flatness) def n _E} if} bdef /_stroke {{stroke} stopped {/_e [pathbbox] def /_f (ERROR: can't stroke, increase flatness) def n _E} if} bdef % path painting operators /n /newpath ldef /N /n ldef /F {p _fill} bdef /f {closepath F} bdef /S {P _stroke} bdef /s {closepath S} bdef /B {gsave F grestore S} bdef /b {closepath B} bdef % text block construction and painting operators /_s /ashow ldef /_S {(?) exch {2 copy 0 exch put pop dup false charpath currentpoint _g setmatrix _stroke _G setmatrix moveto 3 copy pop rmoveto} forall pop pop pop n} bdef /_A {_a moveto _t exch 0 exch} bdef /_L {0 _l neg translate _G currentmatrix pop} bdef /_w {dup stringwidth exch 3 -1 roll length 1 sub _t mul add exch} bdef /_z [{0 0} bind {dup _w exch neg 2 div exch neg 2 div} bind {dup _w exch neg exch neg} bind] def /z {_z exch get /_a xdef /_t xdef /_l xdef exch findfont exch scalefont setfont} bdef /_g matrix def /_G matrix def /_D {_g currentmatrix pop gsave concat _G currentmatrix pop} bdef /e {_D p /t {_A _s _L} def} bdef /r {_D P /t {_A _S _L} def} bdef /a {_D /t {dup p _A _s P _A _S _L} def} bdef /o {_D /t {pop _L} def} bdef /T {grestore} bdef % group construction operators /u {} bdef /U {} bdef % font construction operators /Z {findfont begin currentdict dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall /FontName exch def dup length 0 ne {/Encoding Encoding 256 array copy def 0 exch {dup type /nametype eq {Encoding 2 index 2 index put pop 1 add} {exch pop} ifelse} forall} if pop currentdict dup end end /FontName get exch definefont pop} bdef end %%EndProcSet %%EndProlog %%BeginSetup Adobe_Illustrator_1.1 begin n %%EndSetup u 0 g 0 G 0 i 0 J 0 j 1 w 10 M []0 d %%Note: 143 -137 m 143 -22 L 24 -22 L 24 -137 L 143 -137 L f 83.5 -79.5 m F U %%Trailer _E end (defun maybe (x) (maybe (not x))) Eric K. Olson olson@endor.harvard.edu harvard!endor!olson D0760 (Name) (ArpaNet) (UseNet) (AppleLink)