Discussion:
Calculate the bounding box
(too old to reply)
Arnd Iffland
2005-11-17 07:16:51 UTC
Permalink
Hi,

i need to get the "real" bounding box of an postscript file.

Background information:
I have developed a system where text in a postscript file could be
replaced. I want to display a warning if the text is to long to fit.

If the the is black on white background, this could be easily done with
ghostscript (gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox) and the bbox
device. But what do i have to do when the text is white on black
background? Because white is used for transparency, the bbox device
always returns the black box where the text is written on as the
bounding box, which is to small.

In http://www.cs.wisc.edu/~ghost/doc/cvs/Devices.htm is descriped, that
option "WhiteIsOpaque" has to be set. But if i put the statement "<<
/WhiteIsOpaque true >> setpagedevice " into my postscript file, the
bbox device returns a box that is far to large.

Is there a way to fix this?

Regards,

Arnd


--
Helge Blischke
2005-11-17 12:09:15 UTC
Permalink
Post by Arnd Iffland
Hi,
i need to get the "real" bounding box of an postscript file.
I have developed a system where text in a postscript file could be
replaced. I want to display a warning if the text is to long to fit.
If the the is black on white background, this could be easily done with
ghostscript (gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox) and the bbox
device. But what do i have to do when the text is white on black
background? Because white is used for transparency, the bbox device
always returns the black box where the text is written on as the
bounding box, which is to small.
In http://www.cs.wisc.edu/~ghost/doc/cvs/Devices.htm is descriped, that
option "WhiteIsOpaque" has to be set. But if i put the statement "<<
/WhiteIsOpaque true >> setpagedevice " into my postscript file, the
bbox device returns a box that is far to large.
Is there a way to fix this?
Regards,
Arnd
--
Have you tried to invert the colors for getting the bounding box?

Helge
--
Helge Blischke
Softwareentwicklung
SRZ Berlin | Firmengruppe besscom
http://www.srz.de
Arnd Iffland
2005-11-17 13:59:14 UTC
Permalink
Post by Helge Blischke
Post by Arnd Iffland
Hi,
i need to get the "real" bounding box of an postscript file.
I have developed a system where text in a postscript file could be
replaced. I want to display a warning if the text is to long to fit.
If the the is black on white background, this could be easily done
with ghostscript (gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox) and
the bbox device. But what do i have to do when the text is white on
black background? Because white is used for transparency, the bbox
device always returns the black box where the text is written on as
the bounding box, which is to small.
In http://www.cs.wisc.edu/~ghost/doc/cvs/Devices.htm is descriped,
that option "WhiteIsOpaque" has to be set. But if i put the
statement "<< /WhiteIsOpaque true >> setpagedevice " into my
postscript file, the bbox device returns a box that is far to large.
Is there a way to fix this?
Regards,
Arnd
--
Have you tried to invert the colors for getting the bounding box?
Helge
A good idea that would work. The disadvantage is some overhead to
change the color by the program.

Regrads,

Arnd

--
Helge Blischke
2005-11-17 15:55:20 UTC
Permalink
Post by Arnd Iffland
Post by Helge Blischke
Post by Arnd Iffland
Hi,
i need to get the "real" bounding box of an postscript file.
I have developed a system where text in a postscript file could be
replaced. I want to display a warning if the text is to long to fit.
If the the is black on white background, this could be easily done
with ghostscript (gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox) and
the bbox device. But what do i have to do when the text is white on
black background? Because white is used for transparency, the bbox
device always returns the black box where the text is written on as
the bounding box, which is to small.
In http://www.cs.wisc.edu/~ghost/doc/cvs/Devices.htm is descriped,
that option "WhiteIsOpaque" has to be set. But if i put the
statement "<< /WhiteIsOpaque true >> setpagedevice " into my
postscript file, the bbox device returns a box that is far to large.
Is there a way to fix this?
Regards,
Arnd
--
Have you tried to invert the colors for getting the bounding box?
Helge
A good idea that would work. The disadvantage is some overhead to
change the color by the program.
Regrads,
Arnd
--
Remember that you may feed a sequence of files into Ghostscript which will be treated as one
single PostScript job. Thus, hack a small ps file that simply redefines the color operators as needed
and call gs to prepend it to your original job - no need "to change the color by the program".

Helge
--
Helge Blischke
Softwareentwicklung
SRZ Berlin | Firmengruppe besscom
http://www.srz.de
Russell Lang
2005-11-19 08:55:18 UTC
Permalink
Post by Arnd Iffland
Post by Helge Blischke
Have you tried to invert the colors for getting the bounding box?
A good idea that would work. The disadvantage is some overhead to
change the color by the program.
I think the ghostscript bbox device ignores the colour when
determining where painting occurs. Filling the page with
white or black would both set the bounding box to the page
size.

Continue reading on narkive:
Loading...