[comp.lang.postscript] Centering Encapsulated PS Diagrams...

eric@ux.acs.umn.edu (Eric D. Hendrickson) (10/16/90)

Hello, I have a program that produces flow charts in EPS.  They can be
larger than a page.  What I want to do is print these EPS flow charts out
on a laserwriter with the chart centered (or at least positioned relative
to the upper left corner correctly) on a page, and have it handle charts
that are larger than a page neatly, with the point size(s) configurable.

Has anyone done something like this before?  I'm going to go dive into my
postscript books, but I am hoping someone can save me some time if its 
already been done.

Thanks much!
		Eric Hendrickson
-- 
/----------"Oh carrots are divine, you get a dozen for dime, its maaaagic."--
|Eric (the "Mentat-Philosopher") Hendrickson	      University of Minnesota
|eric@ux.acs.umn.edu	ehend@hp370b.cfsmo.honeywell.com   The game is afoot!
\---"What does 'masochist' and 'amnesia' mean?   Beats me, I don't know."----

shiva@well.sf.ca.us (Kenneth Porter) (10/20/90)

I've written my own filter in C to do this, but it's not quite
what you want as it will also rotate the picture to fill the
page if it's wider than it is tall.
 
The general idea is to scan the EPS file for a line starting
with "%%BoundingBox: llx lly urx ury" where the llx, lly, urx,
and ury are the extents of the printed image in points (lower
left and upper right).  Parse these four numbers, then write a
new EPS file with a new BoundingBox calculated from the old
one.  Put appropriate scale and translate commands at the top
to put the image where you want it.  In the code below, <>
means a number that your filter must calculate.  The numbers in
the comment must be integers.  The others can be floats.  You
have to calculate the scale factor, <sf>, to make the image fit
the space you want it in.
 
%!PS-Adobe-1.0
%%BoundingBox: <nllx> <nlly> <nurx> <nury>
<nllx> <nlly> translate		% new lower left corner
<sf> <sf> scale			% <sf> is calculated scale factor
<-ollx> <-olly> translate	% move original lower left to origin
%%BeginDocument: <original file name here>
<original file goes here>
%%EndDocument
%%EOF