5

I am trying to use \includepdf with about 20 different PDFs. The first 19 have worked fine, but the last one which can be found below

http://math.unc.edu/for-grad-students/analysiscompsSprJan2011.pdf

will not load properly. However, there are no errors - the PDF produced just has a blank page with a couple of black lines in the middle. I converted the PDF to JPG and used \includegraphics and it loaded properly but then I could not add it to my table of contents in the way I wanted.

Any thoughts on why it won't load as a .pdf but will as .jpg?

Here's a minimal document that shows the problem:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf{analysiscompsSprJan2011.pdf}
\end{document}
6

It seems pdfTeX has trouble with the font encodings in analysiscompsSprJan2011.pdf that was generated by dvipdfm 0.13.2d.

Workarounds:

  • The example works with LuaTeX.

  • It seems to work, if the PDF file is preprocessed by pdfcrop. Usually pdfTeX tries to detect the fonts in embedded PDF files and if the fonts are known, then pdfTeX uses the fonts directly ignoring the embedded fonts. Because of merging effects the file size can decrease. But the risk is that the embedded fonts and the fonts found by pdfTeX on its system might differ. pdfcrop disables all fonts, thus pdfTeX just copies the fonts from the included PDF file.

    pdfcrop analysiscompsSprJan2011.pdf
    

    generates analysiscompsSprJan2011-crop.pdf with removed white margins. The margins can also be kept. Then the /MediaBox inside the PDF file tells the dimension of the page:

    /MediaBox[0 0 612 792]
    

    that can be used as new bounding box for pdfcrop:

    pdfcrop -bbox "0 0 612 792" analysiscompsSprJan2011.pdf
    

    Finally analysiscompsSprJan2011-crop.pdf is used for embedding the file:

    \includepdf{analysiscompsSprJan2011-crop}
    

BTW, package pdfpages can also handle .jpg or .png files. Then the extension needs to be specified:

\includepdf{foobar.jpg}

However JPEG/PNG are bitmaps and JPEG is not a lossless compression, it is better to avoid them, if the original file is vector based like in this case.

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.