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.

I'm having an issue inserting a .pdf image into my .tex file (an .eps works fine). A description of my problem is below.

When I insert an .eps figure by doing:

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\includegraphics[angle=90,bbllx=113bp,bblly=67bp,bburx=506bp,bbury=741bp,width=0.8\textwidth]{lipari-plot.eps}
\caption[]{}
\label{fig:liparieps}
\end{figure}
\end{document}

and compile my latex test.tex file using latex (i.e. by doing "latex test.tex; dvipdf test.dvi test.pdf;" on the command line) the figure looks as expected.

However, I need to compile my test.tex file using pdflatex (as my images need to be .pdf instead of .eps).

Unfortunately, I can't find an equivalent to a bounding box that will work with pdflatex. I have tried using viewport (as suggested by websites and the compiler), but the image doesn't appear correctly. (I compile it by doing "pdflatex test.tex;" on the command line.)

The code I have tried, for example, is

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\includegraphics[angle=90,viewport=113bp 67bp 506bp 741bp, clip, width=0.8\textwidth]{lipari-plot.pdf}
\caption[]{Caption}
\label{fig:liparipdf}
\end{figure}
\end{document}

(The files lipari-plot.eps and lipari-plot.pdf are uploaded on this website: http://latex-community.org/forum/viewtopic.php?f=45&t=23286 . Sorry, I can't figure out how to upload them here)

Does anyone know a way to make the compiled version of my .pdf image look like the .eps version?

share|improve this question
1  
Welcome to TeX.SX! You may have a look on our starter guide. It is advisable not to Post on two forums at same time. –  texenthusiast May 22 '13 at 21:33
1  
Welcome to TeX.sx! The main problem seems to be in the fact that the conversion from EPS to PDF has cut the picture, so that the text on the top of the unrotated picture is not present in the PDF. Try without any bounding box or viewport option and you'll see. –  egreg May 22 '13 at 21:33
    
I have tried converting the EPS to PDF myself, but the top gets mangled. There seems to be something wrong in the EPS file: the bounding box data inside it are wrong. If I increase the ury component, the EPS to PDF conversion shows the missing part. –  egreg May 22 '13 at 21:41
add comment

2 Answers

up vote 5 down vote accepted

As @egreg says in the comments, the original eps file is defective, and gets cropped when it is converted to pdf. The bounding box is wrong, but you probably won't see this in a viewer because the first line is also wrong, causing the file to be displayed as ordinary (non-encapsulated) postscript (so the bounding box will be ignored and you will see a lot of white space around the edges). Luckily, these problems are fairly easy to fix.

Method 1

Rename 'lipari-plot.eps' as 'lipari-plot.ps', and in the terminal, do

ps2eps --ignoreBB lipari-plot.ps

Method 2

Open the eps file in your favourite text editor. Delete the first six lines (those starting with %), and replace them with the following.

%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 124 78 479 735
%%HiResBoundingBox: 124.000000 78.500000 479.000000 735.000000
%%EndComments

Either of these should produce an eps file that can be converted to pdf without any problems.

share|improve this answer
    
I went with Method 2 and it worked :) Thanks! –  Sam Short May 23 '13 at 8:44
    
I have this same problem, except that the PDF I'm trying to insert was not made from an EPS -- but from an SVG (which I may not have any longer). Is there any way to get a bounding box added? –  mohawkjohn Sep 22 '13 at 6:00
    
@mohawkjohn --- It's best to ask a new question in situations like this; I got a notification about your comment but few others will see it. Have a look at pdfcrop. –  Ian Thompson Sep 22 '13 at 14:41
add comment

Your EPS file doesn't tell the truth about its bounding box. It says

%!PS-Adobe
%%Creator: The Mighty Setlink.
%%BoundingBox: 58 35 612 525
%%EndComments

while you computed a bounding box equivalent to

%%BoundingBox: 113 67 506 741

and it's the missing 216bp from the top that are the culprit.

If I edit the EPS file so that it reads

%!PS-Adobe
%%Creator: The Mighty Setlink.
%%BoundingBox: 113 67 506 741
%%EndComments

at the start, the conversion is made correctly and you'll need no bounding box statement in the LaTeX file (with EPS) or viewport in the pdfLaTeX file.

share|improve this answer
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.