4

This piece of code:

\documentclass[12pt]{article}
\usepackage{graphicx}

\begin{document}
\section{a}
b
\includegraphics{Nomogram3d_v05a.pdf}
c

\end{document}

Crashes pdflatex with the following error message:

Command Line:   pdflatex.exe --interaction=errorstopmode --synctex=-1 "tst.tex"
Startup Folder: D:\klad

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9)
entering extended mode
(D:\klad\tst.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic,
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2013-05-26, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, latin, latvian,
 lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerman, n
german-x-2013-05-26, nynorsk, oriya, panjabi, pinyin, polish, portuguese, roman
ian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swissgerm
an, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, usengl
ishmax, welsh, loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size12.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\graphics.cfg")
("C:\Program Files\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"))))
No file tst.aux.
("C:\Program Files\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
)Syntax Error: Kid object (page 1) is not an indirect reference (dictionary)

If I comment out the \includegraphics statement, i.e. if I run:

\documentclass[12pt]{article}
\usepackage{graphicx}

\begin{document}
\section{a}
b
c

\end{document}

Everything works and produces output. I checked that the file Nomogram3d_v05a.pdf exists and renders without problems in Sumatrapdf viewer.

  • And yes, before anyone asks, the include file is in the same directory as the .tex file. – latexconfused Aug 16 '15 at 18:58
  • Try with some other graphic. – Ulrike Fischer Aug 16 '15 at 19:10
  • Did that, same result. In fact this nomogram graphic is the fourth .pdf graphic I tries. All crashed with the exact same error message. If you can point me to a guaranteed "proper" pdf file on the web I'm happy to try that. – latexconfused Aug 16 '15 at 19:13
  • Try with one of the graphics of the mwe-package, e.g. example-image.pdf – Ulrike Fischer Aug 16 '15 at 19:20
  • 1
    Also try renaming the pdf to remove the underscore. – Aubrey Blumsohn Aug 16 '15 at 19:37
6

I do not see a reason not to believe the error message, that the included PDF file is invalid. The application that has created the PDF file is buggy. Try

pdfinfo Nomogram3d_v05a.pdf

to get a hint, which program might be the culprit.

Description of the error

Pages are organized as page tree with a pages object as root, intermediate nodes and leaves, the pages. All these objects must be numbered objects (aka indirect object), because some PDF features references page dictionary objects. If this object is directly embedded in the page tree, then it does not have a number.

How to reproduce

I created such a faulty PDF file. Inside /Kids [...] there should be an indirect reference 2 0 obj, which contains the contents <</Type/Page...>>. In this case, the latter object is directly put into the /Kids array making the PDF file invalid.

%PDF-1.5
%ÐÔÅØ
3 0 obj
<<
/Length 37
>>
stream
1 0 0 1 40 40 cm
0 0 20 20 re f
endstream
endobj
1 0 obj
<<
/ProcSet [ /PDF ]
>>
endobj
4 0 obj
<<
/Type /Pages
/Count 1
/Kids [
  <<
    /Type/Page
    /Contents 3 0 R
    /Resources 1 0 R
    /Parent 4 0 R
    /MediaBox[0 0 100 100]
  >>
]
>>
endobj
5 0 obj
<<
/Type /Catalog
/Pages 4 0 R
>>
endobj
xref
0 6
0000000002 65535 f
0000000096 00000 n
0000000000 00000 f
0000000015 00000 n
0000000135 00000 n
0000000299 00000 n
trailer
<< /Size 6
/Root 5 0 R
>>
startxref
348
%%EOF

Hint: The lines ending with f or n after xref must either end with DOS line ends ("\r\n" = bytes 13 and 10) or end with a space and new line ("␣\n" = bytes 32 and 10).

Results with some PDF programs

  • MiKTeX's pdfTeX 1.40.16, MiKTeX's pdfinfo 0.32.0, TeX Live's pdfinfo 0.30.0 show the error:

    Syntax Error: Kid object (page 1) is not an indirect reference (dictionary)
    
  • SumatraPDF v3.0 displays the document.

  • Adobe Acrobat Reader DC 2015 displays the document, but cannot save it because of an unspecified reading error.

  • pdftk 2.02 breaks with:

    Unhandled Java Exception in create_output():
    ExceptionConverter: java.io.IOException: The document has no pages.
    
  • TeX Live's pdfTeX 1.40.16 and xpdf 3.03 break with:

    Syntax Error: Page tree reference is wrong type (dictionary)
    Syntax Error: Invalid page count in page tree
    
  • Ghostscript's ps2pdf 9.15 and 9.16 work.

Repair of the PDF file

For the repair a program is needed, which is tolerant enough to read and understand the file and corrects the error, when the file is saved.

  • (-) Saving the file via SumatraPDF just copies the file, but does not repair it.

  • (-) AR or pdftk fail to read and/or save the file.

  • (+) Ghostscript succeeds:

    ps2pdf Nomogram3d_v05a.pdf Nomogram3d_v05a-fixed.pdf
    
  • I do not see a reason not to believe the error message, that the included PDF file is invalid. I'm confused by this. The OP describes this as a "crash," and the output does not have an error message in it. – Ben Crowell Aug 17 '15 at 0:02
  • @BenCrowell See the last line of the console output. – Heiko Oberdiek Aug 17 '15 at 3:52
  • Oops, now I see it. The final line was hidden in my browser, and I needed to scroll down to see it. – Ben Crowell Aug 17 '15 at 15:36
  • @Heiko: pdfinfo came up with the same error info but the pdf file didn't contain any further information. I know what software produced them though. I was able to correct some of my .pdf files by updating Scribus (from 1.4.0 to 1.4.5) and I'm working on the rest. Perhaps a suggestion to the writers of pdflatex: the error message gave me no clue that it was complaining about a .pdf file and not e.g. the latex file or some intermediary file. If possible the error message should tell where (in what file) it found something amiss. – latexconfused Aug 17 '15 at 15:49
  • @latexconfused I think, the error message and abortion was issued by the library, which is used by pdfTeX to include the PDF file. Thus, it might not be in the full control of pdfTeX. – Heiko Oberdiek Aug 17 '15 at 15:57

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.