TikZ, transparency and PDF/A

pdf-atikz-pgftransparency

So I am trying to validate my document as PDF/A, and I'm almost there. The last remaining problem concerns graphics generated by TikZ. Consider this MWE:

% !TeX program  = lualatex

\documentclass{article}
\usepackage{fontspec}

\usepackage{tikz}
\usepackage{hyperxmp}
\usepackage[pdfa]{hyperref}   

   \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)
       >> ]
   }

\hypersetup{pdftitle={Foobar},pdfaconformance={U},pdfapart={2}}                               

\pdfvariable suppressoptionalinfo 15
\pdfvariable omitcidset=1

\begin{document}

\def\firstcircle{(0,0) circle (4cm)}
\def\secondcircle{(360:4.5cm) circle (4cm)}
{
\begin{figure}[ht!]
 \centering
 \begin{tikzpicture}[blend group=screen,scale=.667]
  \begin{scope}[fill opacity=0.3,text opacity=1,black,line width=.75pt,
align=center,text width=4cm]
    \draw[fill=blue!60!cyan!60!black] \firstcircle 
    node[align=right,shift={(-1.85,0)},text=blue!50!cyan!60!black]{Foo};
    \draw[fill=violet!60!red] \secondcircle 
    node[align=left,shift={(1.85,0)},text=violet!60!red]{Bar};
    \node[text=black] at (2.15,0){\Large\textbf{Foobar}};
  \end{scope}
\end{tikzpicture} 
 \caption{Source: Some Foobar or Other.}
\end{figure}

\end{document}

(Color profile can be found here.)

enter image description here

When I try to validate the resulting .pdf, I get the following error message:

Specification: ISO 19005-2:2011, Clause: 6.2.10, Test number: 1
Only blend modes that are specified in ISO 32000-1:2008 shall be used for the
value of the BM key in an extended graphic state dictionary.
Failed 1 occurrences
PDExtGState
BM == null || BM == "Normal" || BM == "Compatible" || BM == "Multiply" ||
BM == "Screen" || BM == "Overlay" || BM == "Darken" || BM == "Lighten" ||
BM == "ColorDodge" || BM == "ColorBurn" || BM == "HardLight" ||
BM == "SoftLight" || BM == "Difference" || BM == "Exclusion" ||
BM == "Hue" || BM == "Saturation" || BM == "Color" || BM == "Luminosity"

How can I make TikZ play nicely with PDF/A?

Best Answer

pgf stores the blend mode in an array, that is allowed (but deprecated in pdf 2.0) but the validator seems not to like it. You can patch the command to use only a name:

\usepackage{etoolbox}
\makeatletter
\patchcmd\pgfsys@blend@mode{[ /\pgf@temp ]}{/\pgf@temp}{}{\fail}
\makeatletter

(I opened an issue for this https://github.com/pgf-tikz/pgf/issues/1037)

With a current LaTeX you can set the standard also like this, (it will use sRGB.icc as color profile):

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{
  %uncompress,
  pdfstandard=A-2U,
  }

\documentclass{article}
\usepackage{fontspec}

\usepackage{tikz}
\usepackage{hyperxmp}
\usepackage{hyperref}

\usepackage{etoolbox}
\makeatletter
\patchcmd\pgfsys@blend@mode{[ /\pgf@temp ]}{/\pgf@temp}{}{\fail}
\makeatletter

\hypersetup{pdftitle={Foobar}}

\pdfvariable omitcidset=1

\begin{document}

\def\firstcircle{(0,0) circle (4cm)}
\def\secondcircle{(360:4.5cm) circle (4cm)}

\begin{figure}[ht!]
 \centering
 \begin{tikzpicture}[blend group=screen,scale=.667]
  \begin{scope}[fill opacity=0.3,text opacity=1,black,line width=.75pt,
align=center,text width=4cm]
    \draw[fill=blue!60!cyan!60!black] \firstcircle
    node[align=right,shift={(-1.85,0)},text=blue!50!cyan!60!black]{Foo};
    \draw[fill=violet!60!red] \secondcircle
    node[align=left,shift={(1.85,0)},text=violet!60!red]{Bar};
    \node[text=black] at (2.15,0){\Large\textbf{Foobar}};
  \end{scope}
\end{tikzpicture}
 \caption{Source: Some Foobar or Other.}
\end{figure}

\end{document}