Epstopdf conversion cuts off eps graphics on right side

conversionepsepstopdfpdftex

I am almost done with my thesis and I include a lot of Matlab generated .eps files. I noticed that on some of those the image in the resulting document is cut off on the right hand side just enough to look bad.

When I searched the forums I saw some people had seemingly similar problems in the past but their solutions (don't use a vector format for a photographic image, use the epstopdf package to include the eps file) did not work for me or did not apply to my case.

The eps file is fine when viewed but the resulting "-eps-converted-to.pdf" file is cut off. I would like to include a minimal working example but I don't know where to put the eps file?

For my document I am using Texmaker with the "fast compile" setting: PdfLaTeX + Bib(la)tex + PdfLaTeX (x2) + View Pdf.
For the MWE I just pressed PdfLaTeX a few times before viewing.

What I would like as a solution: Have epstopdf not cut off my eps files!

What I would not like to do: Convert every eps file by hand or re-plot/re-export all my images from Matlab!

I hope you can help me get this resolved! Thanks a lot! 🙂

EDIT: Marjin pointed out that changing the BoundingBox in the eps file (in a text editor) could solve the problem, and it did! This solution falls into the 'edit all eps files by hand' category, so any idea to automate the process would be much appreciated!

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{figure}
\begin{center}
  \includegraphics[width=0.65\linewidth]{dhdt_mess_bericht.eps}
\end{center}
\end{figure}

\end{document}

Best Answer

With the information from the comments, I now have the following solution:

The Matlab generated eps files should all have the same size (width and height) but they all have slightly different boundary boxes when opened in a text editor, for example:

%%BoundingBox:     3     0   338   252

I changed that line for all files to:

%%BoundingBox:     0     0   340   255

The pdf file generated by epstopdf does not have any cut off parts now. Now I just need to find out how to make Matlab generate the correct boundary boxes...

Thank you all for your help!