Problems with epstopdf: Image sizes in pdflatex wrong compared to LaTeX
Okay, this is a note to myself.
I made an EPS (encapsulated PostScript) using gsview (see this post). Then when I run LaTeX everything looks nice. I handed the files off to the collaborator who wanted them (I was just handling the Word to LaTeX process) and they compiled them and got a tiny graphic in a big white space.
What was going on? Well, my colleague’s TeX GUI program (I don’t use one, and I don’t know what they use. Some Windows GUI I think) automagically converted the EPS to PDF — which it did because its default setting (I am guessing) was to use pdflatex — but the conversion was dodgy and it did not keep the EPS bounding box, but put the graphic on an A4 (or letter paper perhaps) page. Now why would it do that?
I took a look at the first few lines of the EPS file. They look like this:
%!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 88 536 446 715 %%HiResBoundingBox: 0 0 595.00 842.00
A-ha (I thought at the time)! The ‘HiResBoundingBox’ is clearly not being set by gsview, and presumably this is the bounding box being used by epstopdf, the command line tool used to convert (I had tried running epstopdf directly on the EPS file but the resulting PDF had the same problem as when the PDF was produced automatically by the GUI). So I copied the ‘BoundingBox’ numbers into the HiRes field and changed them to be reals by putting ‘.0’ on the end (that’s a nought, not the letter ‘o’).
And it did not work. This leads me to suggest that epstopdf has its problems. But, anyway, the solution is… pdfcrop by Heiko Oberdiek. As simple as:
pdfcrop fig1.pdf fig1_crop.pdf
and then use the cropped PDF in the document and all is well!