2

I want to test the Form environment provided by hyperref, especially \CheckBox and \PushButton and encountered errors in behavior when babel is used with the ngerman language option.

The purpose of the \PushButton is to provide a activate all checkboxes at once and uses some JavaScript code, I am no expert in JavaScript however.

As long as ngerman is not used as the language option, the code works as expected, I tested with Adobe Acrobat DC 11 on Windows 10 and with PdfStudio Pro 2019 on Linux.

Clicking on the pushbutton with ngerman activated does provide nothing, i.e. the JavaScript code fails, but I suspect there is a problem with label names needed by hyperref.

I use pdflatex with TeXLive 2020 on Linux, last updated this day.

Is there a solution to this problem? I want to keep babel since many of my documents rely on ngerman and the 'interactive' Form would be nice to have in some of my older documents, after changing some other code of course.

The following code is minimal, I think and shows the feature. The included screenshot shows the desired feature, at the moment only achievable by dropping ngerman as option.

\documentclass[11pt,ngerman]{article}

\usepackage{babel}
\usepackage{hyperref}
\begin{document}
\parindent=0em
\begin{Form}
  \begin{tabular}{l}
    \CheckBox[name=abox]{A} \tabularnewline    \tabularnewline
    \CheckBox[name=bbox]{B} \tabularnewline    \tabularnewline
    \CheckBox[name=cbox]{C} \tabularnewline    \tabularnewline
    \CheckBox[name=dbox]{D} \tabularnewline    \tabularnewline
  \end{tabular}
\bigskip

\PushButton[name=activateall,onclick={%
  this.getField("abox").value="Yes";
  this.getField("bbox").value="Yes";
  this.getField("cbox").value="Yes";
  this.getField("dbox").value="Yes";
}]{Activate all}
\end{Form}

\end{document}

enter image description here

2
  • 3
    deactivate the shorthand before the pushbottom with \shorthandsoff{"} Jul 14 '20 at 18:11
  • @UlrikeFischer: Oh, that easy, with \shorthandoff{"}? It works, thanks a lot. If you add it as answer, I will accept it.
    – user220449
    Jul 14 '20 at 18:14
1

Deactivate the shorthand locally:

\documentclass[11pt,ngerman]{article}

\usepackage{babel}
\usepackage{hyperref}
\begin{document}
\parindent=0em
\begin{Form}
  \begin{tabular}{l}
    \CheckBox[name=abox]{A} \tabularnewline    \tabularnewline
    \CheckBox[name=bbox]{B} \tabularnewline    \tabularnewline
    \CheckBox[name=cbox]{C} \tabularnewline    \tabularnewline
    \CheckBox[name=dbox]{D} \tabularnewline    \tabularnewline
  \end{tabular}
\bigskip

\shorthandoff{"}
\PushButton[name=activateall,onclick={%
  this.getField("abox").value="Yes";
  this.getField("bbox").value="Yes";
  this.getField("cbox").value="Yes";
  this.getField("dbox").value="Yes";
}]{Activate all}
\end{Form}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy