Convert EPS to PDF: problem of bounding box

When you save a multiple plots/subfigures figure as an eps file in matlab, the bounding box might not be properly defined. People who use pdflatex need to convert EPS to PDF. The undefined bounding box will cause problems if you use epstopdf to convert EPS to PDF. This problem is shown in the first row in the picture below. The top-left figure is the eps file without properly defined bounding box. Because of this, epstopdf simply printed a letter size pdf file that only contains part of the figure as shown in the top-right figure. You can try to use the option –exact

epstopdf --exact bad.eps

It will probably generate an warning msg like “Warning: BoundingBox not found!” and the resulting pdf is still wrong. One way to fix this problem is to use epstool

epstool --copy --bbox bad.eps --output good.eps

The bbox option tells epstool to generate a (correct) bounding box for the eps file. With a correctly defined bounding box, you can easily convert an eps file to a pdf file.

epstopdf --exact good.eps

The results are shown in the 2nd row of the picture below. epstopdf generated an pdf file in the same size as the eps file.


9 Responses to Convert EPS to PDF: problem of bounding box

  1. hectorpal says:

    I just tried in my ubuntu 8.10 and the last
    “epstopdf –exact good.eps”
    didn’t work, but
    “epstopdf good.eps”
    worked perfectly. Thanks.

    BTW, this also works when you start with a tiny figure in PDF in a huge letter/a4 page by doing first
    “pstopdf -eps bad.pdf bad.eps”

  2. Elizabeth says:

    Thanks! This post is very helpfull!

  3. […] If anyone else is having problems with the boundingbox converting eps files to pdf this page may be of help Convert EPS to PDF: problem of bounding box […]

  4. Mat says:

    great! Thanks a lot for this!!

    If I may ask… any idea how this could be done in a loop? I have aroudn 100 files likes this to convert…


    • chi3x10 says:

      You can used the following script.

      for x in *.eps;
      do epstool –copy –bbox $x –output fixed_$x;

  5. juisoo says:

    I had some weird scaling problems with pdflatex and epstopdf converted graphics: When giving the optional argument height=Xcm to \includegraphics, the correct space would be reserved but the graphic would not be scaled but instead overlapped the text. latex did everything perfectly with the eps graphics.
    I finally figured out that the package “color” interferes with “graphicx” and loading graphicx AFTER color solved this problem. No idea what is now malfunctioning in color though…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: