🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #3414

Re: Centering Encapsulated PS Diagrams...

#3414
From: Kenneth Porter
Date: Fri, 19 Oct 1990 18:15
27 lines
1504 bytes

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
Technical Details
Message-ID: <21248@well.sf.ca.us>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!rutgers!sun-barr!apple!well!shiva
References: <2449@ux.acs.umn.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!rutgers!sun-barr!apple!well!shiva
From: shiva@well.sf.ca.us (Kenneth Porter)
Newsgroups: comp.lang.postscript
Subject: Re: Centering Encapsulated PS Diagrams...
Summary: EPS manipulation algorithm
Message-ID: <21248@well.sf.ca.us>
Date: 19 Oct 90 18:15:49 GMT
References: <2449@ux.acs.umn.edu>
Lines: 27