47

Why do simple PDF files compiled with pdflatex contain so many PDF errors?

The simplest example I can see is "Hello World!" that once compiled,

\documentclass{report}
\begin{document}
    Hello World!
\end{document}

produces a file "hello.pdf" that is fed to PDFbox:

$ java -jar ../preflight-app-1.8.10.jar hello.pdf

The file hello.pdf is not valid, error(s) :
1.2.1 : Body Syntax error, Single space expected
1.2.1 : Body Syntax error, Single space expected
1.2.1 : Body Syntax error, EOL expected before the 'endobj' keyword
1.2.1 : Body Syntax error, Single space expected
1.2.1 : Body Syntax error, Single space expected
1.2.1 : Body Syntax error, Single space expected
7.1 : Error on MetaData, Missing Metadata Key in catalog

LuaLaTeX shows the same problem, but in general with fewer errors.

2 Answers 2

58

The preflight tool of PDFBox validates against the PDF/A-1b standard, more than just PDF.

The first errors regarding PDF/A-1b should be resolved by a recent pdfTeX, I do not get these errors with pdfTeX 1.40.16 (TeX Live).

The last error 7.1 about MetaData comes from the requirement of PDF/A-1b to also embed the meta data in XMP format, see package hyperxmp, the latest version of package pdfx with support for PDF/A, or package xmpincl.

1

The PDF/A standard is meant for optimising archival. This means fonts must be embedded (done automatically), it requires metadata so you find the document in the archive. Last but not least it requires an OutputIntent to specify how the colours were originally intended to look. There are more requirements but those are the most important.

Although PDFBox 1.8 did not complain about missing OutputIntent, newer versions of it would have.

See this minimal example PDF/A document on how to produce PDF/A directly out of pdfTeX. This validates:

java -jar preflight-app-2.0.19.jar hyperxmp.pdf
The file hyperxmp.pdf is a valid PDF/A-1b file

(pdf)TeX cannot guess which colour space you intend to use and it cannot guess what useful metadata is for a particular document. That's why you have to specify those values. Keep in mind validators are just checking the presence of certain values. If i.e. you set the author to «me» or empty chances are high people will not find your document in a library even if it had passed automated validation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .