Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting %%BoundingBox from postscript variables

13 views
Skip to first unread message

Snark

unread,
Mar 31, 2012, 4:40:45 PM3/31/12
to
Hi everyone,

I wrote a small PS code that generates a skeleton of cardboard box. I
set some basic parameters (height, width etc) at the start of the PS
file and all lines are calculated and drawn.

Once the parameters are set, I can easily calculate the size of the
page needed, but I can't find a way to inject this value to the %
%BoundingBox directive.

In other words, is there a way to insert PS variables into the
comments?

Thanks

luser- -droog

unread,
Apr 1, 2012, 4:53:48 AM4/1/12
to
Not directly. Because the variables don't exist until the program is
running; at which point there's no longer a complete "file" available
(merely a partially-consumed filetype object).

The simplest way is use the ghostscript -sDEVICE=bbox .

From vi, position the cursor on a blank line and

!!gs -q -sDEVICE=bbox -dBATCH -dNOPAUSE %

should insert the `gs`-computed BBox and Hi-ResBBox into the file.

Phillip Helbig---undress to reply

unread,
Apr 2, 2012, 5:09:11 PM4/2/12
to
In article
<914d544b-f190-44ec...@s27g2000yqd.googlegroups.com>,
I have a similar problem: a Fortran program which does everything I need
(for making nice plots) except producing a valid bounding box. There is
a bounding box in the output file but it is approximate since the exact
value changes with the heights of symbols etc. So, I could just produce
such a plot, run the gs command above and it will insert the proper
bounding box into the file?

luser- -droog

unread,
Apr 5, 2012, 1:55:52 PM4/5/12
to
On Apr 2, 4:09 pm, hel...@astro.multiCLOTHESvax.de (Phillip Helbig---
undress to reply) wrote:
> In article
> <914d544b-f190-44ec-8672-aed21223d...@s27g2000yqd.googlegroups.com>,
Yes. Just to be clear, gs just processes the file and prints the
Bounding
Box comments to stderr. It is the vi command which takes this output
and replaces the current line with the contents. Incidentally, it also
sends the current line *to* the command as input. So make sure you're
on a blank line.
0 new messages