[Tex/LaTex] PS to EPS preserving bounding box

conversionepsgraphicspssvg

I have an SVG file and would like to turn that into EPS for embedding into a latex file to be eventually used by dvips. I can use rsvg-convert to turn my SVG into PS. I then can use ps2eps to turn that into EPS. But ps2eps does adjust the bounding box, which means that the resulting EPS will not show the whitespace as instructed by the SVG file.

Is there a way to prevent this, i.e. to convert PS to EPS while maintaining the BoundingBox of the original PS file?

The best I could come up with so far is this:

rsvg-convert -f ps -d 600 -p 600 --background-color=white -o foo.ps foo.svg
ps2eps -f -H foo.ps
sed -i~ "s/^%%BoundingBox:.*/`grep ^%%BoundingBox: foo.ps`/" foo.eps

But I consider this approach pretty hackish.

Best Answer

For the purpose of embedding with latex+dvips, a one-page Postscript file with a %%BoundingBox entry can be safely regarded as encapsulated Postscript and doesn't require further processing. Thus, the output of rsvg-convert can be used directly.