# TikZ shade not being drawn on first page with xelatex

Look at this example:

%! TEX program = xelatex
\documentclass{article}
\usepackage{tikz}

\begin{tikzpicture}[remember picture,overlay]
\shade[left color=green,right color=red] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}%
}

\usepackage{blindtext}
\begin{document}
\blindtext[10]
\end{document}


Run it with xelatex, the rectangle is not drawn on the first page. But with pdflatex, everything is fine.

Is there any fix to this?

• Ah sorry, I thought you had a new problem. But this is the same as in tex.stackexchange.com/q/581394/2388. Give the shade a label (you can use the same: \AddToHook{shipout/background}[jinwen/opac]... and use the rule. Feb 1 '21 at 11:08
• @UlrikeFischer No, even with this rule, the shade on first page is still not drawn. Feb 1 '21 at 11:14
• Well actually it works for me without any changes. Is your system up-to-date? There was a pgf bug which affected xelatex. Feb 1 '21 at 11:26
• @UlrikeFischer I just got all my texlive packages updated, but the problem remains. It still occurs with xelatex. Feb 1 '21 at 11:44
• I think it is a bug in xdvipdfmx, see my answer. Feb 1 '21 at 13:21

It works for me. But I'm on windows, and I have a newer xdvipdfmx (in texlive and miktex, my version is "Version 20210109").

If I use an older xdvipdfmx from texlive 2019 I get various errors connected to the shade and the shade is missing:

xdvipdfmx:warning: Error locating image file "pgfshade1"
xdvipdfmx:warning: Specified (image) object doesn't exist: pgfshade1
xdvipdfmx:warning: Interpreting special command uxobj (pdf:) failed.
xdvipdfmx:warning: >> at page="1" position="(-50, 742)" (in PDF)

\begin{document}