# PDF/A with CMYK, how?

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}
$$1=1\label{eq.1}$$
\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}

• The boxes around the TOC entries do not comply with the PDF/A-1b standard. You can turn the hyperlink-functionality of the TOC off by adding linktoc=none to the hyperref's package options. – DG' Feb 10 '15 at 11:28
• @DG' Yes, that works! However, I would like to keep the links in the TOC. I tried colorlinks=true, linkcolor=black. This removes the boxes, but does not produce a valid PDF/A-1b. Any idea how I can keep the links? – hal46 Feb 10 '15 at 11:39
• does the pdfx package help? – JPi Jun 9 '15 at 20:40
• pdfx does not help. I think that some solution based on patching of hyperref's link making code needed. For example in hpdftex.def and in hxetex.def there are following lines: \ifx\@urlbordercolor\relax \else /C[\@urlbordercolor]% \fi I think, one need to "remove" them by some patchcmd to get rid of "Annotation C" errors. By the way Word 2010 with it's option to save to pdf/A produces linkable text (links?) that (even colored) either is not annotated or is annotated the way that is causing errors. – Leonid Dec 20 '15 at 10:48
• @hal46 Hi! I'm failing to use pdfbox / preflight, it fails with most files. Could you add in a comment the command you are using to run it? – Keks Dose Jan 10 '18 at 15:33

## 3 Answers

With some dirty patchcmd (from etoolbox) of hyperref commands. Seems to work with pdflatex and lualatex. icc file from pdfx package.

\documentclass{article}
\pdfminorversion 4
\pdfcompresslevel=0
\immediate\pdfobj stream attr{/N 4} file{coated_FOGRA39L_argl.icc}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (Coated FOGRA39)
/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},
}

\makeatletter
% Dirty hack of hyperref to make rgb-like links annotated with C mark become annotated with K mark to work in PDF/A with CMYK
% makeatletter - makeatother needed
\usepackage{etoolbox}
\patchcmd{\hyper@linkfile}{/C[}{/K[}{}{}
\patchcmd{\hyper@linkurl}{/C[}{/K[}{}{}
\patchcmd{\find@pdflink}{/C[}{/K[}{}{}
\patchcmd{\hyper@linkstart}{/C[}{/K[}{}{}
\makeatother

\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}
$$1=1\label{eq.1}$$
\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}

• Dirty in this context means the solution just breaks the colour information resulting in black links and a syntactically incorrect PDF. There is a better hack today, see my answer below. – tanGIS Apr 8 '20 at 7:54

It seems that the question, as originally asked, has been satisfactorily answered. But for the benefit of others who come here by search, let me add some clarifying information:

As a general rule, PDF/A (per the question) is for digital documents. Since the files will be viewed by computers, an RGB color profile is appropriate.

As a general rule, PDF/X is for printed documents. Since the color press almost certainly uses CMYK, a CMYK color profile is appropriate.

It is unlikely that a PDF/A file would use a CMYK profile, unless the same file is used both for digital viewing and print. In this case, when viewed on a computer, the CMYK colors are electronically converted back to RGB.

The most widely-used PDF/X technology requires only CMYK, not RGB. This dates back to a time when an industrial printing machine might not internally perform RGB to CMYK conversion. But for many years, such internal conversion is possible with industrial printers (and is routine for home and office printers). So, sometimes PDF/X with RGB color profile is accepted. The more advanced technologies allow you to mix-and-match different color profile within a single file.

A file can be both PDF/A and PDF/X, as long as the color profile(s) is (are) acceptable to all end users.

The OP linked to several free, online validators for PDF/A. I do not know of any for PDF/X.

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.