1

I want to use a PDF image embedded as a figure. I am using the following code. The result is a blank page followed by a page without any figure at all. Just the text appears on the second page.

\documentclass{article}
\usepackage{pdfpages}

\begin{document}
   \includepdf[width=0.4\textwidth, angle = 0]{image1.pdf}
   Here goes the text
\end{document}
  • 5
    \includegraphics, not \includepdf. You need the graphicx package, however! – user31729 Jan 11 '16 at 20:37
  • 1
    that or just graphicx package and \includegraphics{image1} should be enough to include a one page pdf. – David Carlisle Jan 11 '16 at 20:38
  • @DavidCarlisle: This is a duplicate, surely? – user31729 Jan 11 '16 at 20:39
  • 1
    I dont want to include full PDF Page....instead I need only the image. In case if has to be a page, then I need to define the bounding limits for PDF to fit within. Presently upon using {\includegraphics} I am getting following error. ! LaTeX Error: Cannot determine size of graphic in image1.pdf (no BoundingBox). – Rehan Jamshed Jan 11 '16 at 20:46
4

Assuming you are using pdfTeX (which is included with MiKTeX), just use the graphicx package, and \includegraphics:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
   \includegraphics[width=0.4\textwidth, angle=0]{image1.pdf}
   Here goes the text
\end{document}

Looking into the comments, the question appears to ask how to clip part of a PDF image. This can be done with trim={<left> <lower> <right> <upper>} and clip options:

\includegraphics[width=0.4\textwidth, trim={0.5cm 0.5cm 0.5cm 11.3cm}, clip]{image1.pdf}
  • P.S. I am using MikTex – Rehan Jamshed Jan 11 '16 at 20:47
  • @RehanJamshed: MikTeX is a distribution that contains pdflatex ;-) – user31729 Jan 11 '16 at 20:49
  • 2
    MikTeX is not what you are using to compile. MikTeX is just a TeX distro, that is a way to fetch latex packages and binaries on the CTAN repository and to install them on your computer. pdfTeX is probably what your are using to compile when launching a latex command. It might be xetex, but Mike T's answer also matches. – sztruks Jan 11 '16 at 20:49
  • @RehanJamshed See seanallred.com/tex/2015/05/25/tex-terminology.html – Sean Allred Jan 11 '16 at 22:40
2
\includegraphics[page=1, trim = 18mm 100mm 18mm 5mm, clip, width=14.35cm]{file.pdf}

Here you can decide pagenumber, trim is the bounding box and you have to clip. This should work.

EDIT: After further investigation I can conform. You are calling latex .tex

But as the documentation of pdfpages you can see, that calling latex in dvi mode it will only include a pdf dummy, so you cannot see any image in this way.

You have two options:

Option 1: You can convert your pdf image to an eps file, so latex can handle this. Option 2: You call your file via pdflatex and all will be fine, /maybe you have to replace your command and use includegraphics instead.

calling latex and include pdf images seems to be impossible.

I am sure that you call latex instead of pdflatex, in this case I am able to reproduce this error.

  • 1
    Note to OP: all options are optional; you do not need page, trim, clip, or width to make this work. Also, Peter: you should avoid using absolute lengths for width :-) – Sean Allred Jan 11 '16 at 22:39
  • @SeanAllred you are alright. But I thought, that I can handle the error of OP LaTeX Error: Cannot determine size of graphic in image1.pdf in this way. – Peter Ebelsberger Jan 11 '16 at 22:42
  • Thanks @PeterEbelsberger but I am still getting the error as follows: Package pdfpages Warning: I will use a dummy \includepdf command which (pdfpages) will insert empty pages instead of the actual PDF, (pdfpages) because we are running in DVI mode or with (pdfpages) dvips driver. ))) (C:\Work\Latex\PDF_Image.aux) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\pdflscape.sty" ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\lscape.sty") ("C:\Program Files\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty")) ! Package keyval Error: page undefined. – Rehan Jamshed Jan 12 '16 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.