95

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}
Martin Scharrer
  • 262,582
pavani
  • 2,973

3 Answers3

150

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.

Martin Scharrer
  • 262,582
gypaetus
  • 3,162
  • 1
    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 02 '12 at 15:59
  • To include a figure in the bottom of the page you could use a figure environment in the document where you want to have the figure: \begin{figure}[b]\includegraphics[]{filename.pdf} \end{figure} . For more information about positioning of figures see https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Floats – gypaetus Jan 04 '12 at 15:03
  • 4
    +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
  • 1
    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
  • 1
    This is the correct and most useful answer to the question. – gustafbstrom Nov 10 '16 at 15:06
  • 2
    Will they be imported as vector graphic or will they be rasterized by the graphicx package? – skan Feb 07 '17 at 10:15
  • 2
    The graphicx package supports importing PDFs in both vector graphics and raster images formats. – gypaetus Feb 08 '17 at 16:16
  • Can I include multiple pages at one go using includegraphics? – hola May 27 '21 at 12:15
  • It seems that the solution by \usepackage{graphicx} can not work in https://www.overleaf.com/project/. Any idea? – MathArt May 22 '23 at 06:14
51

Have a look at the pdfpages package

\documentclass{article}

\usepackage{pdfpages}

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

   Your Text
\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.

Peter Grill
  • 223,288
Tobi
  • 56,353
  • 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 02 '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 02 '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 05 '17 at 21:27
  • 1
    @skan: only PDF is supported natively and furthermore SVG is mir for web than print. Thus I'd use a PDF file ... – Tobi Feb 06 '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 07 '17 at 10:25
  • Degens on how you export the PDF, but in general Inkscape should export as vectors. You can test it by zooming in as much as possible if all lines/edges are still sharp it is a vector graphic … / Another reason for PDF ist that SVG doesn’t support CMYK (only RGB) color space, while CMYK is required for (professional) printing. But I’m not sure about the status of Inkscape’s CMYK support, seems like one needs an extension to export CMYK PDFs. – Tobi Feb 11 '17 at 13:33
2

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}