# Could not insert pdf graphics

Using \includegraphics[width=\linewidth]{mypdf} I tried to insert a PDF image to my XeLaTeX document. But instead of the images empty area places in its place.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=\linewidth]{my.pdf}
\end{document}


I got following in console:

** WARNING ** Multiple DecodeFilter not supported.
** WARNING ** Could not handle a content stream.
** WARNING ** pdf: image inclusion failed for "./my.pdf".
)
(see the transcript file for additional information)
Output written on test.pdf (1 page).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.


What may be wrong? What kind of PDFs can be inserted in tex files?

• How did you generate my.pdf? Perhaps you should convert it to PS and then convert back to PDF (see XeTeX cannot include PDF page). – Werner Apr 5 '13 at 6:39
• @Werner I generated pdf from yEd program. I don't have pdf2ps in my texlive dict. – PHPst Apr 5 '13 at 6:49
• @PHPst: Use pdftops instead, not pdf2ps. – Werner Apr 5 '13 at 7:04
• @Werner It solved the issue and the output is far better that pdf2ps. – PHPst Apr 5 '13 at 8:59

This is a result of multiple decoders within the original PDF (as the message clearly states). A solution is to convert the PDF to PostScript and then back again to PDF, which should encode it using a single decoder.

For this you would need Ghostscript and perhaps Xpdf (which provides pdftops, if pdf2ps is not available). The conversion back to PDF should come standard with your TeX distribution in the form of epstopdf.

If this conversions results in a larger PDF than the original, you might consider running the intermediate PS through ps2ps first, before converting back to PDF.

In summary:

pdftops  foo.pdf
epstopdf foo.ps
pdfcrop  foo.pdf

• pdftops is distributed by TeXlive and porvides far better result that pdf2ps'. – PHPst Apr 9 '13 at 2:53
• my original PDF file just includes a vector images, after converting resulting PDF contains a full A4 page that contains the images, is there any option prevent changing page size? – PHPst Apr 9 '13 at 2:57
• @PHPst: You can use pdfcrop to trim your final PDF to the size of the resulting graphic. – Werner Apr 9 '13 at 2:58

use

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[width=\linewidth]{my.pdf}
\end{document}


for multiple pages, or

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=\linewidth,page=<pageNo>]{my.pdf}
\end{document}


for a single page

• Is figure file extension mandatory ? – texenthusiast Apr 5 '13 at 6:35
• no, i copied it only from the mwe – user2478 Apr 5 '13 at 6:37
• I have no problem. Did you tried it with page=1 and are you sure that the included document is in your path? – user2478 Apr 5 '13 at 6:44
• – user2478 Apr 5 '13 at 7:19
• @PHPst: can you provide your pdf for a test? – user2478 Apr 5 '13 at 7:49

I have found a possible solution from

Cropping/Trimming an image with includegraphics by specifying percentages

Trying the following TeX code:

\adjustbox{trim=5cm 5cm 5cm 5cm, clip}{\includegraphics[page=2]{source.pdf}}
`
• Welcome to TeX.SX! While the advice is sound for different kinds of problems, I don't see how it handles the present one. – egreg Dec 26 '14 at 21:19