Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!mintaka!snorkelwacker.mit.edu!spool.mu.edu!sdd.hp.com!wuarchive!udel!ee.udel.edu From: new@ee.udel.edu (Darren New) Newsgroups: comp.sys.next Subject: Re: PS to EPS: HELP! Message-ID: <45850@nigel.ee.udel.edu> Date: 26 Feb 91 19:24:29 GMT References: <1991Feb26.021202.5712@casbah.acns.nwu.edu> <1366@toaster.SFSU.EDU> <1991Feb26.110147.22371@agate.berkeley.edu> Sender: cranor@ee.udel.edu Organization: University of Delaware Lines: 338 Nntp-Posting-Host: estelle.ee.udel.edu In article <1991Feb26.110147.22371@agate.berkeley.edu> izumi@fugitive.berkeley.edu (Izumi Ohzawa) writes: >Print the page out, use a ruler and measure the bounding box. Or prepend the following postscript code to the file before printing it. >If the above fails, get the EPS file specification from >Adobe (send mail to ps-file-server@adobe.com with Subject: help, >and another mail with Subject: index Documents). Nothing I know of on the file server actually has the EPS specs. Rather, the EPS documents say which comments are required for which functions without saying what the semantics of the comments are. For example, they will say "Always have BoundingBox, have IncludeFile for included files, ..." -- Darren %! % bb.ps -- % % Prints a file, but keeps track of bounding box info, and prints the box at % the end (around the figure.) % 50 dict dup /$BoundingBox exch def begin /xdef { exch def } def /xstore { exch store } def /bb-pt+ { exch 4 -1 roll add 3 1 roll add } def % % Stubs of old functions. % /-stroke /stroke load def /-fill /fill load def /-eofill /eofill load def /-image /image load def /-show /show load def /-awidthshow /awidthshow load def /-showpage /showpage load def % % New Functions. % /stroke { gsave { flattenpath strokepath % Make sure to take line width into account. } stopped { % strokepath often hits a limitcheck. grestore % Restore the original path gsave } if bb-path % Accumulate it into our box. grestore -stroke } def /fill { gsave bb-path grestore -fill } def /eofill { gsave bb-path grestore -eofill } def % % Text is implemented by reducing everything to an `awidthshow'. % /show { 0 0 0 0 0 % Extra parameters for awidthshow 6 -1 roll % Bring the string back up awidthshow } def /widthshow { 0 0 % Extra parameters for awidthshow 3 -1 roll % Bring the string back up. awidthshow } def /ashow { 0 0 0 6 3 roll awidthshow } def /awidthshow { 5 dict begin gsave currentpoint 2 copy /@starty xdef /@startx xdef 2 index stringwidth % Get the natural length of the string bb-pt+ % Add to the start to get the end. 2 index length % How many characters? dup % Add the offsets to each character 6 index mul exch 5 index mul bb-pt+ 5 index 3 index bb-chcount % How many padding characters? dup % Add the offsets for each pad. 9 index mul exch 8 index mul bb-pt+ /@endy xdef /@endx xdef bb-fontheight % Get the height and depth of the current font. 4 copy @startx @starty bb-pt+ bb-point @startx @starty bb-pt+ bb-point @endx @endy bb-pt+ bb-point @endx @endy bb-pt+ bb-point newpath % $Debug @startx @starty moveto % $Debug @endx @endy lineto % $Debug bb-bwstroke % $Debug grestore end -awidthshow } def % % `image': % % Assume here that the image lands in the unit square. % /image { 0 0 bb-point 1 1 bb-point -image } def % % `showpage': % % Just draw the box around the figure and print the page, and then initialize % the bounding box variables again. % /bb-string 10 string def /showpage { initgraphics bb-llx bb-lly itransform % Convert them into default coords. bb-urx bb-ury itransform /bb-lly xstore /bb-urx xstore /bb-ury xstore /bb-llx xstore bb-llx bb-lly moveto % Make the box bb-llx bb-ury lineto bb-urx bb-ury lineto bb-urx bb-lly lineto closepath bb-bwstroke % Draw the box. 0 setgray /Courier findfont 10 scalefont setfont bb-llx bb-lly 12 sub moveto bb-llx bb-string cvs -show ( ) -show bb-lly bb-string cvs -show ( ) -show bb-urx bb-string cvs -show ( ) -show bb-ury bb-string cvs -show bb-init -showpage } def % % BoundingBox functions: % % We accumulate the information about the bounding box into four variables. % The data is stored in device coordinates. % /bb-init { /bb-llx 99999 store /bb-lly 99999 store /bb-urx -99999 store /bb-ury -99999 store } def /bb-llx 0 def /bb-lly 0 def /bb-urx 0 def /bb-ury 0 def % % x y `bb-point' - % % Takes a point in user coordinates and adds it into the bounding box info. % /bb-point { transform % Convert to device coords. dup dup bb-lly lt { /bb-lly xstore } { pop } ifelse dup bb-ury gt { /bb-ury xstore } { pop } ifelse dup dup bb-llx lt { /bb-llx xstore } { pop } ifelse dup bb-urx gt { /bb-urx xstore } { pop } ifelse } def % % - `bb-path' - % % Incorporates the bounding box of the path into the bounding box info. % /bb-path { gsave { 0 setlinejoin flattenpath } stopped { grestore gsave } if pathbbox bb-point bb-point grestore } def % % A nice black-and white line drawing function. % /bb-bwstroke { 0 setlinewidth % Thinnest possible lines 1 setgray % White first [5] 0 setdash % Only half the line gsave -stroke grestore 0 setgray % Then black [5] 5 setdash % On the other half -stroke } def % % Stuff for text. % % % char-code string `bb-chcount' occurs % % Counts the number of times a character appears in a string. % /bb-chcount { 0 exch { 2 index eq { 1 add } if } forall exch pop } def % % - `bb-fontheight' heightx heighty depthx depthy % % Returns the offsets to the lowest point and highest point in the current % font. % /bb-fontheight { currentfont begin FontBBox exch pop 0 exch FontMatrix transform 4 2 roll exch pop 0 exch FontMatrix transform end } def % Start it up. bb-init % end of bb.ps -- --- Darren New --- Grad Student --- CIS --- Univ. of Delaware --- ----- Network Protocols, Graphics, Programming Languages, Formal Description Techniques (esp. Estelle), Coffee, Amigas ----- =+=+=+ Let GROPE be an N-tuple where ... +=+=+= Brought to you by Super Global Mega Corp .com