# How to include a PDF image into a PDFLaTeX document

I am generating a PDF file using pdflatex and need to include another PDF file. The reason is that I have a graphMl file which I exported from yEd graph editor to a PDF file, named sample.pdf. The TeX code to be compiled with pdflatex is given below. I need to include that file at the start of the document.

\documentclass[a4paper,leqno,twoside]{article}

\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{multirow}

\begin{document}

[% FOREACH st IN Service %]
Name,Id:
[% st.Id %], [% st.Name %]

des:
[% st.Description %]

Customers:
[% FOREACH softservice IN st.Customers %]
[% FOREACH swid IN softservice.SW %]
[% swid.Service %]
[% FOREACH st IN Service %][% IF swid.Service == st.Id %]
([% st.Name %])

[% END %] [% END %][% END %][% END %]

Suppliers:

[% FOREACH shservice IN st.Suppliers %]
[% FOREACH sw IN shservice.SW %][% sw.Service %]
[% FOREACH st IN Service %][% IF sw.Service == st.Id %]([% st.Name %])
[% END %][% END %][% END %]

[% FOREACH hw IN shservice.HW %][% hw.Type %][% hw.Nr %][% END %]
[% END %]
\newpage
[% END %]
\end{document}

• I'm curious: That code looks badly broken and doesn't make much sense (most of it is commented out). Is yEd that bad? – Reinstate Monica - M. Schröder Dec 28 '11 at 11:21

Have a look at the pdfpages package

\documentclass{article}

\usepackage{pdfpages}

\begin{document}
\includepdf[<options>]{<file>}

\end{document}


Edit Miguel suggested graphicx to include a graphic which is correct, the difference between graphicx and pdfpages is that graphicx puts the PDF as a graphic on a text page (maybe inside a {figure} float environment, whereas pdfpages inserst the pages of a given PDF between the pages of your document.

• I have small problem when I try to insert external pdf image into my pdflatex document on page 13 and one more image on page 14, I am not able to insert external pdf images on specific page number.my problem is I need to insert exteranl pdf images on bottom side of page 13 and page 14. Can you help me with that.I tried to insert but it inserting on starting page of latex generated pdf. – pavani Jan 2 '12 at 15:57
• @pavani: I’m not sure if I understood you right (please add a new MWE to your question showing the problem) … If you want to include the external PDF as part of a LaTeX-page use \includegraphics instead of \pdfpages – Tobi Jan 2 '12 at 17:35
• If I want to insert vector graphics in a larger latex document is it better to use svg images or pdf images? – skan Feb 5 '17 at 21:27
• @skan: only PDF is supported natively and furthermore SVG is mir for web than print. Thus I'd use a PDF file ... – Tobi Feb 6 '17 at 22:30
• If I use a software such as inkscape to create a vector graphic and I export it as pdf... Will the result still be a vector graphic (converted to pdf graphic)? Or is better if I create a svg? – skan Feb 7 '17 at 10:25

Loading the graphicx package in the preamble it is possible to import PDF images in the document:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\includegraphics[<options>]{filename.pdf}

\end{document}


Here <options> can be e.g. width=<width>, height=<height or page=<page number>. See the Graphics Guide for more details.

• I have small problem when I try to insert external pdf image into my pdflatex document on page 13 and one more image on page 14, I am not able to insert external pdf images on specific page number.my problem is I need to insert exteranl pdf images on bottom side of page 13 and page 14. Can you help me with that.I tried to insert but it inserting on starting page of latex generated pdf. – pavani Jan 2 '12 at 15:59
• +1 This is the best answer here! Includegraphics much better to use than a new command. – Léo Léopold Hertz 준영 Oct 29 '14 at 21:09
• Great solution. I add some details that I got stuck with. The latex command will not compile the code with a pdf image. However, pdflatex and xelatex will. – Wizzerad Jul 17 '15 at 15:28
• This is the correct and most useful answer to the question. – gustafbstrom Nov 10 '16 at 15:06
• Will they be imported as vector graphic or will they be rasterized by the graphicx package? – skan Feb 7 '17 at 10:15

I use the package epstopdf to insert graphic in format different than those that Latex commonly processes. It works for .pdf, .tiff, etc.

\documentclass{article}

\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.pdf}{png}{.png}{convert #1 \OutputFile}
\AppendGraphicsExtensions{.pdf}

\begin{document}

\includegraphics[<options>]{filename.pdf}

\end{document}