3

Compiling a form with the hyperref package and in the presence of the animate package fails with LuaLaTeX one in two while it always works with PDFLaTeX.

Moreover, for an unknown reason (JavaScript implementation of Okular or of hyperref package?), that works only with Adobe Reader DC (on Linux via Wine/Snapd) and not with Okular.

Is there something I have missed?

\documentclass{article}

\usepackage{animate}
\usepackage{hyperref}


\begin{document}

\begin{Form}
  \PushButton[name=myButton,
    borderwidth=1px,bordercolor={0 0 0},
    onclick={
      this.getField("myTextBox").value += 1;
    }
  ]{CLICK ME}
  \TextField[name=myTextBox,
    borderwidth=1px,bordercolor={0 0 0},readonly=true]{Counter}
\end{Form}

\end{document}
6
  • Okular support for JavaScript is very limited, just to make animate animations work, as far as I know.
    – AlexG
    Mar 17, 2022 at 13:51
  • @AlexG Thanks. Unfortunately that was what I guessed. Have you an idea about the main issue of the question?
    – ejazz
    Mar 17, 2022 at 14:01
  • Yes, I am working out an answer ;).
    – AlexG
    Mar 17, 2022 at 14:02
  • @AlexG Wonderful! ;-)
    – ejazz
    Mar 17, 2022 at 14:04
  • @AlexG your definition of \pdfpageref in pdfbase is wrong. You should use \def\pdfpageref {\pdffeedback pageref} as in the luatex85 package. Mar 17, 2022 at 14:17

2 Answers 2

4

It is a bug in pdfbase. It gives \pdfpageref a faulty definition. (It is also a bug in hyperref, it shouldn't use \pdfpageref with lualatex but directly the luatex primitive)

\documentclass{article}

\usepackage{animate}
\def\pdfpageref{\pdffeedback pageref}
\usepackage{hyperref}

\begin{document}


\begin{Form}
\tracingmacros=1
  \PushButton[name=myButton,
    borderwidth=1px,bordercolor={0 0 0},
    onclick={
      this.getField("myTextBox").value += 1;
    }
  ]{CLICK ME}
  \TextField[name=myTextBox,
    borderwidth=1px,bordercolor={0 0 0},readonly=true]{Counter}
\end{Form}

\end{document}
9
  • I copied that code in pdfbase.sty from the luatex manual. Thus, the luaTeX manual is wrong about this?
    – AlexG
    Mar 17, 2022 at 14:24
  • @AlexG I would say yes. \numexpr there looks like nonsense. You could ask David in the chat, he will know why he didn't use that in luatex85. Mar 17, 2022 at 14:33
  • Maybe because pdfTeX's \pdfpageref expands immediately and the luaTeX manual's version requires \the before?
    – AlexG
    Mar 17, 2022 at 14:36
  • \pdffeedback pageref 1 works fine and does the same as \pdfpageref. Mar 17, 2022 at 14:37
  • 1
3

If PDF forms are involved, hyperref and animate want to write on a number of global PDF objects concurrently.

Similar clashes may exist between other LaTeX packages that implement interactive PDF stuff. In order to resolve this, the LaTeX3 team is developing a common interface for package authors that enables them to write compatible PDF related code: pdfmanagement-testphase. It is not yet included in the default LaTeX kernel and must be explicitly enabled:

\RequirePackage{pdfmanagement-testphase} % load the package
\DeclareDocumentMetadata{} % activates the PDF management interface
\documentclass{article}

\usepackage{animate}
\usepackage{hyperref}

\begin{document}

\begin{Form}
  \PushButton[name=myButton,
    borderwidth=1px,bordercolor={0 0 0},
    onclick={
      this.getField("myTextBox").value += 1;
    }
  ]{CLICK ME}
  \TextField[name=myTextBox,
    borderwidth=1px,bordercolor={0 0 0},readonly=true]{Counter}
\end{Form}

\end{document}
4
  • Thank you for your quick answer. It's a dilemma to choose between Ulrike Fischer answer and yours. Both of them are working for this post but not for my actual intermediate case. Your solution fails and the one of Ulrike works. Do have I to post a new question?
    – ejazz
    Mar 17, 2022 at 18:33
  • I think that @Ulrike's answer fixes the real cause. I'd accept hers ;-)
    – AlexG
    Mar 17, 2022 at 19:31
  • @ejazz New version of pdfbase has arrived at CTAN. May take a day or so to show up in TeXLive.
    – AlexG
    Mar 18, 2022 at 9:56
  • Great news and useful as usual :-)
    – ejazz
    Mar 18, 2022 at 10:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .