TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Apparently, it's possible to use gs to automatically find the bounding box of a PDF. See http://stackoverflow.com/questions/10962235/how-to-find-blank-page-in-pdf-file/11274720#11274720.

What I would like to do is to have a way of including a bunch of images such as the bounding box is scaled to the box in which I want the image to be shown.

Any thoughts on how to do that?

share|improve this question
Just to be clear: Your included image has some surrounding white space that you want to automatically trim and insert into your document constrained to some fixed width and height? Why not just pre-process the (all) image(s) to have tight bounding boxes before you include them? – Werner Jul 5 '13 at 1:52
up vote 8 down vote accepted

Instead of doing this using \includegraphics{}, I would suggest a workaround to achieve the desired goal. If you are running on Linux/CygWin you can do the following in command line prompt:

for i in *.pdf
  oname=`basename $i .pdf`-old.pdf
  mv $i $oname
  pdfcrop --margins 0 $oname $i

After doing this, all the PDFs that were already in the directory will be renamed to *-old.pdf and the newly generated PDFs will be cropped tightly without white margin. Then you can use these PDFs in the TeX file without any trim option in \includegraphics{}.

share|improve this answer
This method is as per Werner's comment. – Jagath AR Jul 5 '13 at 2:47
Wow. That's great. I didn't know about pdfcrop. Thanks. – vy32 Jul 6 '13 at 1:08
Ps - as an aside, pdfgcrop is a perl script that runs GhostScript – vy32 Jul 6 '13 at 3:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.