Skip to content

includegraphics with pdf can create XObject with multiple transparency groups #47

@lukas-code

Description

@lukas-code

steps to reproduce

Step 1: Obtain a PDF that specifies a transparency group in the page dictionary.

In my case this was a file created by cairo (via Firefox' print to PDF feature), but we can also create one with LaTeX as follows:

% file foo.tex

\RequirePackage{pdfmanagement}
\SetKeys[document/metadata]{
    pdfversion=1.7,
    lang=en-US,
    uncompress,
}

\documentclass{standalone}

\ExplSyntaxOn
\pdfmanagement_add:nnn{Page}{Group}{<<~/S~/Transparency~/CS~/DeviceRGB~/I~true~>>}
\ExplSyntaxOff

\begin{document}
    foo
\end{document}

compile with pdflatex foo.tex to get a foo.pdf with

7 0 obj
<<
  /Type /Page
  % ...
  /Group << /S /Transparency /CS /DeviceRGB /I true >> 
  % ...
>>

Step 2: Include foo.pdf via \includegraphics.

% file bar.tex

\RequirePackage{pdfmanagement}
\SetKeys[document/metadata]{
    pdfversion=1.7,
    lang=en-US,
    uncompress,
}

\documentclass{article}
\usepackage{graphicx}

\begin{document}
    bar

    \includegraphics{foo.pdf}
\end{document}

compile with pdflatex bar.tex (twice) and we get a PDF with an XObject that specifies multiple transparency groups:

5 0 obj
<<
  /Group<</S/Transparency/K false/I false>>
  /Type /XObject
  % ...
  /Group 11 0 R
  % ...
>>
% ...
11 0 obj
<< /S /Transparency /CS /DeviceRGB /I true >>

When using lualatex instead of pdflatex the order of the /Group entries changes.


This causes tools like qpdf or verapdf to complain, but for some reason the PDF still validates.

$ qpdf bar.pdf /dev/null
WARNING: bar.pdf (object 5 0, offset 374): dictionary has duplicated key /Group; last occurrence overrides earlier ones
$ ~/verapdf/verapdf bar.pdf
WARNING: Dictionary/Stream contains duplicated key /Group(object key = 5 0 obj, offset = 875)

likely regressed in: latex3/latex3@4c017aa

likely related: https://tex.stackexchange.com/questions/755198/latex-verapdf-dictionary-stream-contains-duplicated-key-group https://tex.stackexchange.com/questions/758882/latex-verapdf-warning-duplicated-key-group

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions