6

I want to create a pdf/a-compatible file in LaTeX using the pdfx package. Unfortunately, instead of using the correctly created xmp file to convert the file into pdf/a, some lines of cryptic text are written directly into the pdf file. My minimal example (largely based on http://www.golatex.de/pdfx-bzw-pdf-a-oder-pdf-x-t4427.html) is

\begin{filecontents*}{\jobname.xmpdata}
    \Keywords{pdfTeX\sep PDF/X-1a\sep PDF/A-b}
    \Title{Sample LaTeX input file}
    \Author{Das war KOMA}
    \Org{goLaTeX}
\end{filecontents*}

\documentclass{article}
\usepackage[a-1b]{pdfx}
\usepackage[pdfa]{hyperref}

\begin{document}
Hello world!
\end{document}

This produces the error ! LaTeX Error: Missing \begin{document}, although I have a \begin{document} in the file, and the following file:

enter image description here

Any ideas where the problem lies?

  • 1
    Your MWE throws no errors and compiles fine, BUT it does not produce a PDF/A-1b compliant pdf file. More on that here. – DG' Mar 12 '15 at 19:23
7

You need eciRGB_v2.icc in the working directory.

\documentclass{article}

% ===============================
% Embedding the color profile.
% Requires eciRGB_v2.icc in the working directory
% http://www.eci.org/_media/downloads/icc_profiles_from_eci/ecirgbv20.zip


\pdfminorversion 4
\immediate\pdfobj stream attr{/N 3}  file{eciRGB_v2.icc}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (eciRGB v2)
/Info(eciRGB v2)
>> ]
}

\usepackage{xcolor}
\usepackage{hyperxmp}
\usepackage[pdftex, pdfa, linktoc=none]{hyperref}

% ----------------------------------------------
% Add metadata

\hypersetup{%
       pdftitle={Sample LaTeX input file},
       pdfauthor={Das war KOMA},
       pdfsubject={Thema},
       pdfkeywords={pdfTeX, PDF/X-1a, PDF/A-b},
       pdflang={de},
       bookmarksopen=true,
       bookmarksopenlevel=3,
       hypertexnames=false,
       linktocpage=true,
       plainpages=false,
       breaklinks
     }

\begin{document}
    Hello world!
\end{document}
1

The error:

LaTeX Error: Missing \begin{document}

is triggered whenever something ends up in TeX's typesetting lists before the real \begin{document} command has been encountered. This can happen when bytes end up in the .xmpdata file, not contained as arguments of its special macros \Title, \Author, \Subject, etc. This can include invisible characters.

Have you, by any chance, copied a Byte-order marker (BOM) into the filecontents* environment, having produced its content in another editor? Having just become acquainted with this kind of problem, the next version of pdfx.sty has coding to prevent any such extraneous bytes making it into TeX's lists.

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.