[Tex/LaTex] PDF/A with CMYK, how

hyperrefpdf-a

Using https://tex.stackexchange.com/a/99666 and https://tex.stackexchange.com/a/136653 I think I have been able to generate (using TeX Live 2014, pdfTeX 3.14159265-2.6-1.40.15) a PDF/A-1b compliant pdf as:

\documentclass{article}
\pdfminorversion 4
\immediate\pdfobj stream attr{/N 3} file{sRGBIEC1966-2.1.icm}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (sRGB IEC61966-2.1)
/Info(sRGB IEC61966-2.1)
>> ]
}
\usepackage{xcolor}
\usepackage{hyperxmp}
\usepackage[pdftex, pdfa]{hyperref}
\hypersetup{%
    pdfauthor          = {a},
    pdfkeywords        = {a, b, c},
    pdflang            = {en},
    pdftitle           = {a},
    pdfsubject         = {a},
  pdfcaptionwriter   = {a},
  pdfcontactaddress  = {a},
  pdfcontactcity     = {a},
  pdfcontactcountry  = {a},
  pdfcontactemail    = {a},
  pdfcopyright       = {a},
  pdfmetalang        = {en}
}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\section {A}
{\color{blue}Hello} World!
\[1+2=3\]

\section {B}
\lipsum
\(1+2=3\)
\begin{align*}
A &= B\\
  &= C\\
  &= E
\end{align*}

\newpage

\section {C}
\lipsum
\[1+2=3\]
\end{document}

At least, PDFBox Preflight (http://en.wikipedia.org/wiki/Apache_PDFBox) says

The file test.pdf is a valid PDF/A-1b file

And also 3-Heights PDF Validator Online Tool (http://www.pdf-tools.com/pdf/validate-pdfa-online.aspx) is happy.

Now, I would like to use CMYK-colors.
So I downloaded an icc profile from http://www.eci.org/en/downloads
and tried this modification:

\documentclass{article}
\pdfminorversion 4
\immediate\pdfobj stream attr{/N 4} file{ISOcoated_v2_eci.icc}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (FOGRA39L)
/Info(FOGRA39L)
>> ]
}
\usepackage[cmyk]{xcolor}
\usepackage{hyperxmp}
\usepackage[pdftex, pdfa]{hyperref}
\hypersetup{%
    pdfauthor          = {a},
    pdfkeywords        = {a, b, c},
    pdflang            = {en},
    pdftitle           = {a},
    pdfsubject         = {a},
  pdfcaptionwriter   = {a},
  pdfcontactaddress  = {a},
  pdfcontactcity     = {a},
  pdfcontactcountry  = {a},
  pdfcontactemail    = {a},
  pdfcopyright       = {a},
  pdfmetalang        = {en}
}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\section {A}
{\color{blue}Hello} World!
\[1+2=3\]

\section {B}
\lipsum
\(1+2=3\)
\begin{align*}
A &= B\\
  &= C\\
  &= E
\end{align*}

\newpage

\section {C}
\lipsum
\[1+2=3\]
\end{document}

Now, PDFBox Preflight complains:

5.2.3 : Forbidden field in an annotation definition, Annotation uses a Color pro
file which isn't the same than the profile contained by the OutputIntent

And 3-Heights PDF Validator Online Tool says:

A device-specific color space (Annotation C or IC) without an appropriate output intent is used.
The document does not conform to the requested standard.
The document contains device-specific color spaces.

However, If I remove the tableofcontents a valid (according to PDFBox Preflight) PDF/A-1b seems to be generated.

What is the problem, and how do I fix it?


UPDATE:

The problem appears to be with hyperref. See the comments.
Is it possible to redefine some part of hyperref to avoid the problems?

I would like something like this to work:

\documentclass{article}
\pdfminorversion 4
\pdfcompresslevel=0
\immediate\pdfobj stream attr{/N 4} file{ISOcoated_v2_eci.icc}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (FOGRA39L)
/Info(FOGRA39L)
>> ]
}
\usepackage[cmyk]{xcolor}
\usepackage{hyperxmp}
\usepackage[pdftex, pdfa]{hyperref}
\hypersetup{%
  colorlinks = true,
    pdfauthor          = {a},
    pdfkeywords        = {a, b, c},
    pdflang            = {en},
    pdftitle           = {a},
    pdfsubject         = {a},
  pdfcaptionwriter   = {a},
  pdfcontactaddress  = {a},
  pdfcontactcity     = {a},
  pdfcontactcountry  = {a},
  pdfcontactemail    = {a},
  pdfcopyright       = {a},
  pdfmetalang        = {en},
}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsrefs}
\usepackage{lipsum}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\tableofcontents
\section {A}
{\color{blue}Hello} World!
\begin{theorem}
\label{thm.1}
\begin{equation}
1=1\label{eq.1}
\end{equation}
\end{theorem}
\begin{proof}
By reflexivity of \(=\).
\end{proof}
Theorem \ref{thm.1} is about the equation \eqref{eq.1}.
See also \cite{MR1727844}.
\begin{bibdiv}
\begin{biblist}
\bib{MR1727844}{book}{
   author={Bourbaki, Nicolas},
   title={Algebra I. Chapters 1--3},
   series={Elements of Mathematics (Berlin)},
   note={Translated from the French;
   Reprint of the 1989 English translation [ MR0979982 (90d:00002)]},
   publisher={Springer-Verlag, Berlin},
   date={1998},
   pages={xxiv+709},
}
\end{biblist}
\end{bibdiv}
\end{document}

Best Answer

Is it possible to redefine some part of hyperref to avoid the problems?

Short answer: yes.

A few years later there is now a cleaner way to produce CMYK PDF/A. One advantage of CMYK is that it's possible to produce documents which validate PDF/A and PDF/X at the same time.

Since links are forbidden in PDF/X up to 5 this means you must disable them. Or you leave them active and «risk» a validation error. This has been accepted as a problem in the standard so the draft for PDF/X-6 allows hyperlinks officially.

minimal example

%\pdfobjcompresslevel=0 %uncomment for Texlive
\documentclass{article}
\usepackage{lipsum}
\usepackage[pdfa,bookmarks=false]{hyperref} %bookmarks are incompatible with PDF/X<6
\usepackage[latin]{babel}
\usepackage{hyperxmp}[2020/06/15]
\usepackage{mmap} %only needed for pdfTeX, does not harm LuaTeX
\usepackage[cmyk,hyperref]{xcolor}

% Which paper did the authors have in mind when they created the document?
\immediate\pdfobj stream attr{/N 4} file{PSO_Uncoated_ISO12647_eci.icc}
\pdfcatalog{%
  /OutputIntents [ <<
    /Type /OutputIntent
    /S /GTS_PDFX
    /DestOutputProfile \the\pdflastobj\space 0 R
    /Info(PSO Uncoated ISO12647 (ECI))
    /OutputCondition(Offset printing, according to ISO 12647-2:2004/Amd1, OFCOM, paper type 4 = uncoated white, 115 g/m2, tone value increase curves C (CMY) and D (K))
    /OutputConditionIdentifier (Uncoated FOGRA47)
    /RegistryName(http://www.color.org)
  >>
  <<
    /Type /OutputIntent
    /S /GTS_PDFA1
    /DestOutputProfile \the\pdflastobj\space 0 R
    /Info(PSO Uncoated ISO12647 (ECI))
    /OutputCondition(Offset printing, according to ISO 12647-2:2004/Amd1, OFCOM, paper type 4 = uncoated white, 115 g/m2, tone value increase curves C (CMY) and D (K))
    /OutputConditionIdentifier (Uncoated FOGRA47)
    /RegistryName(http://www.color.org)
  >> ]
}

\makeatletter
% Bugfix of hyperref to produce CMYK links
\let\HyColor@HyperrefBorderColor\HyColor@XZeroOneThreeFour
\makeatother

\makeatletter
%we need to tell PDF/X the final format of the paper. This needs adjustment if you want graphics on the page border, called bleeding
\@tempdima=0.99626400996264009962\paperwidth
\edef\boxwd{\strip@pt\@tempdima}
\@tempdima=0.99626400996264009962\paperheight
\edef\boxht{\strip@pt\@tempdima}
\makeatother
\edef\next{%
  \protect\pdfpageattr{
    /TrimBox[0.0 0.0 \boxwd\space \boxht]
  }%
}
\next

\title{PDF/A-2b dummy document}
\author{anonymus}

\hypersetup{%
    pdfdisplaydoctitle=true,
    pdfversionid=1,
    pdftrapped=False,
    pdfapart=2,
    pdfaconformance=B,
    pdfstartpage={},
    pdfxstandard={PDF/X-4},
    urlbordercolor=red
}

\begin{document}
%\begin{NoHyper} %comment out to avoid links

\tableofcontents

\section {A}
\lipsum[1-2]
\url{http://tex.stackexchange.com/}

%\end{NoHyper} % comment out to avoid links
\end{document}

This example uses the rather new version of hyperxmp. It validates in Acrobat DC, VeraPDF and 3-Heights when compiled either in pdfLaTeX or LuaLaTeX. The hyperref workaround is from it's issue tracker.

I used FOGRA47 as the colour profile because it is small and thus safe. You don't easily risk colours which cannot be printed or displayed on screen. The profile is available from European Color Initiative.