Obey the MediaBox/CropBox in PDF when using ghostscript to render a PDF to a png

Posted by gordonwatts on Stack Overflow See other posts from Stack Overflow or by gordonwatts
Published on 2010-04-17T06:09:53Z Indexed on 2010/04/17 6:13 UTC
Read the original article Hit count: 316

Filed under:
|
|
|

I've been using ghostscript to convert my single figure plots rendered in PDF to png:

gswin32c -sDEVICE=png16m -r300x300 -sOutputFile=junk.png -dBATCH -dNOPAUSE Figure_001-a.pdf

This works in the sense I get a png out and it contians the plot. But it contains a huge amount of white space as well (an example source image: http://cdsweb.cern.ch/record/1258681/files/Figure_001-a.pdf). If you view it in Acrobat you'll note there is no white space around the plot. If you use the above command line you'll find the plot is only about 1/3 of the space.

When doing the same thing with an eps file I run into the same problem. However, there is the command-line parameter -dEPSCrop that one can pass to get the PS rendering engine to pay attention to the BoundingBox.

I need the similar argument for rendering PDF's. I was not able to find it in docs (nor even the EPSCrop, actually).

© Stack Overflow or respective owner

Related posts about ghostscript

Related posts about png