Skip to content

pgf with \shade invalid pdf in Acrobat #1434

Description

@linasstonys

Brief outline of the bug

I use latex and texlive 2024.
I have a problem with \shade command:
\shade[left color=green!60, right color=red!70] (0,0) rectangle (10,1);
When PDF is made via acrobat distiller and when I open pdf with acrobat it shows drawing error.
Problem might be in /Domain [0.0 100.00128] value that it is higher then 100. If I change
all these /Domain values to 100 then Acrobat opens pdf normally.

Here is a \shade PS code.

  100.00128 100.00128 0 0 pgfe << /PatternType 2 /Shading << /ShadingType
2 /ColorSpace /DeviceRGB /Domain [0.0 100.00128] /Coords [0 0.0 0 100.00128]
/Function << /FunctionType 3 /Domain [0.0 100.00128] /Functions [ <<
/FunctionType 2 /Domain [0.0 100.00128] /C0 [1 0.3 0.3] /C1 [1 0.3
0.3] /N 1 >>  << /FunctionType 2 /Domain [0.0 100.00128] /C0 [1 0.3
0.3] /C1 [0.7 0.65001 0.34999] /N 1 >>  << /FunctionType 2 /Domain
[0.0 100.00128] /C0 [0.7 0.65001 0.34999] /C1 [0.4 1 0.4] /N 1 >>
<< /FunctionType 2 /Domain [0.0 100.00128] /C0 [0.4 1 0.4] /C1 [0.4
1 0.4] /N 1 >>  ] /Bounds [ 25.00032 50.00064 75.00096] /Encode [0
1  0 1 0 1 0 1] >> >> >> matrix makepattern setpattern fill

I tried to take pgf, pgfornament, pgfplots files form TL2025 but still the same. Maybe it could be fixed to do not put higher value then 100 (if this is the real problem)?
I attached minimal example files.

Minimal working example (MWE)

\documentclass{article}
\usepackage{pgfplots}
\usepackage{xcolor}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
                \shade[left color=green!60, right color=red!70] (0,0) rectangle (10,1);

                \foreach \x/\label in {0/a, 2.5/b, 5/c, 7.5/d, 10/e} {
                                \draw[black] (\x,0) -- (\x,1.2);
                                \node[below] at (\x, -0.1) {\textbf{\label}};
                        }
\end{tikzpicture}
\end{document}

This is bad pdf
test.pdf

UPDATE

I see that everywhere pt is treated as bp and for conversion uses default value 0.99627 (..\tex\generic\pgf\systemlayer\pgfsys.code.tex)
In reality 1 pt = 0.996264009963 bp. So I changes 0.99627 to 0.996264 in that file:

\def\pgf@sys@bp@correct#1{#1=0.996264#1}

\def\pgf@sys@bp#1{%
  {%
    \pgf@x=#1\relax%
    \pgf@x=0.996264\pgf@x%
    \edef\temp{\expandafter\Pgf@geT\the\pgf@x\space}%
    \pgfutil@toks@\expandafter\expandafter\expandafter{\expandafter\pgfsysprotocol@currentprotocol\temp}%
    \xdef\pgfsysprotocol@currentprotocol{\the\pgfutil@toks@}%
  }%
}

And now Acrobat shows images without problems. Could this conversion be changed in the upcoming Texlive?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions