Take the 2-minute tour ×
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.

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
3  
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
add comment

1 Answer 1

up vote 6 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
do
  oname=`basename $i .pdf`-old.pdf
  mv $i $oname
  pdfcrop --margins 0 $oname $i
done

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
add comment

Your Answer

 
discard

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.