[Tex/LaTex] pdfx package writes into pdf file

pdf-apdfx

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?

Best Answer

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}
Related Question