[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: more form fields (253ae72)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun May 5 15:42:58 CEST 2019


Repository : https://github.com/latex3/pdfresources
On branch  : testlinkstuff
Link       : https://github.com/latex3/pdfresources/commit/253ae72a2cc132cee88b02364a06977f0ef61a46

>---------------------------------------------------------------

commit 253ae72a2cc132cee88b02364a06977f0ef61a46
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun May 5 15:42:58 2019 +0200

    more form fields


>---------------------------------------------------------------

253ae72a2cc132cee88b02364a06977f0ef61a46
 hluatex-experimental.def |  116 ++++++++++++++++++++++++++--------------------
 test-pdfresources.tex    |   15 +++++-
 2 files changed, 80 insertions(+), 51 deletions(-)

diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index fdf72b6..649e5d3 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -26,6 +26,10 @@
   { This~hyperref~driver~ignores~the~pdfversion~key!\\
     Set~the~pdfversion~in~\token_to_str:N \documentsetup}
 
+\msg_new:nnn
+  {hyp}
+  {pdfa-no-push-button}
+  {PDF/A:~Push~button~with~JavaScript~is~prohibited}
 %% I require the bookmark package to get rid of some of the bookmarks code.
 \AtEndOfPackage{% so that we are later than KOMA ...
 \AtBeginDocument
@@ -1216,77 +1220,91 @@
        }
      {  \MakeRadioField{\Fld at width}{\Fld at height} }
      %\pdfendlink
-    \ifnum\Fld at listcount=1 %
-      \HyField at AddToFields
-    \fi
+     \int_compare:nNnT { \Fld at listcount} = { 1 }
+      { \HyField at AddToFields }
     \c_space_tl % deliberate space between radio buttons
+                % to do: --> should be configurable
   }%
 }
-\ExplSyntaxOff
+
 \newcount\Fld at listcount
-\def\@@Listbox#1{%
-  \HyField at PDFChoices{#1}%
-  \leavevmode
+\def\@@Listbox#1
+ {
+  \HyField at PDFChoices{#1}
+  \mode_leave_vertical:
   \HyAnn at AbsPageLabel
   \Hy at escapeform\PDFForm at List
-  \pdfstartlink user {\PDFForm at List}\relax
-  \MakeChoiceField{\Fld at width}{\Fld at height}%
-  \pdfendlink
+  \pdf_link_user:nnn
+       {widget} %perhaps we need more types??
+       {\PDFForm at List}
+       {\MakeChoiceField{\Fld at width}{\Fld at height}}
   \HyField at AddToFields
-}
+ }
+
+
 \def\@PushButton[#1]#2{% parameters, label
   \def\Fld at name{#2}%
-  \begingroup
-    \expandafter\HyField at SetKeys\expandafter{%
-      \DefaultOptionsofPushButton,#1%
-    }%
+  \group_begin:
+    \exp_args:No\HyField at SetKeys
+     {
+      \DefaultOptionsofPushButton,#1
+     }
     \PDFForm at Name
-    \ifHy at pdfa
-      \Hy at Error{%
-        PDF/A: Push button with JavaScript is prohibited%
-      }\@ehc
-      \LayoutPushButtonField{%
-        \leavevmode
-        \MakeButtonField{#2}%
-      }%
-    \else
+    \bool_if:NTF \l__hyp_pdfa_bool
+     {
+      \msg_error:nn { hyp }{ pdfa-no-push-button }
+       \LayoutPushButtonField
+        {
+         \mode_leave_vertical:
+         \MakeButtonField{#2}
+        }
+     }
+     {
       \HyField at FlagsPushButton
       \ifFld at hidden\def\Fld at width{1sp}\fi
-      \LayoutPushButtonField{%
-        \leavevmode
+      \LayoutPushButtonField
+       {
+        \mode_leave_vertical:
         \HyAnn at AbsPageLabel
         \Hy at escapeform\PDFForm at Push
-        \pdfstartlink user {\PDFForm at Push}\relax
-        \MakeButtonField{#2}%
-        \pdfendlink
+        \pdf_link_user:nnn
+         {widget} %perhaps we need more types
+         {\PDFForm at Push}
+         {\MakeButtonField{#2}}
         \HyField at AddToFields
-      }%
-    \fi
-  \endgroup
+       }
+      }
+  \group_end:
 }
-\def\@Submit[#1]#2{%
-  \def\Fld at width{\DefaultWidthofSubmit}%
-  \def\Fld at height{\DefaultHeightofSubmit}%
-  \begingroup
-    \expandafter\HyField at SetKeys\expandafter{%
-      \DefaultOptionsofSubmit,#1%
-    }%
+
+\def\@Submit[#1]#2
+ {
+  \def\Fld at width{\DefaultWidthofSubmit}
+  \def\Fld at height{\DefaultHeightofSubmit}
+  \group_begin:
+   \exp_args:No\HyField at SetKeys
+    {
+      \DefaultOptionsofSubmit,#1
+    }
     \HyField at FlagsPushButton
     \HyField at FlagsSubmit
     \ifFld at hidden\def\Fld at width{1sp}\fi
-    \leavevmode
+    \mode_leave_vertical:
     \HyAnn at AbsPageLabel
     \Hy at escapeform\PDFForm at Submit
-    \pdfstartlink user {%
-      \PDFForm at Submit
-      /AP<</N \SubmitObject/D \SubmitPObject>>%
-    }%
-    \relax
-    \MakeButtonField{#2}%
-    \pdfendlink
+    \pdf_link_user:nnn
+      {widget} %perhaps more types needed
+      {
+        \PDFForm at Submit
+       /AP<</N~\SubmitObject/D~\SubmitPObject>>
+       }
+      { \MakeButtonField{#2} }
     \HyField at AddToFields
-  \endgroup
-}
+  \group_end:
+ }
+
+\ExplSyntaxOff
+
 \def\@Reset[#1]#2{%
   \def\Fld at width{\DefaultWidthofReset}%
   \def\Fld at height{\DefaultHeightofReset}%
diff --git a/test-pdfresources.tex b/test-pdfresources.tex
index 8ae6e5e..9b6571d 100644
--- a/test-pdfresources.tex
+++ b/test-pdfresources.tex
@@ -23,7 +23,7 @@
             pdfversion=1.7,
            % pdfstartpage=3,
            % pdfstartview=
-           pdfview=FitV
+           pdfview=FitV,pdfa
             ]{hyperref}
 
 
@@ -39,7 +39,7 @@
 \hypupdateattribute
 \makeatletter%\tracingmacros=1
 \textwidth=5cm
-\begin{document}
+\begin{document}\parskip=1cm
 %
 %abc\newpage blb\newpage ccc
 %
@@ -52,6 +52,17 @@
 
 \ChoiceMenu[radio]{radio}{aaa,bbb,ccc,dddd}
 
+\ChoiceMenu[combo]{combo}{aaa,bbb,ccc,dddd}
+
+\ChoiceMenu[]{list}{aaa,bbb,ccc,dddd}
+
+\PushButton[
+  name=additem,
+  borderwidth=0.5pt,
+  bordercolor=blue,
+  backgroundcolor=red % why doesn't this work ?
+]{\textcolor{blue}{Add an item}}
+
 
 \TextField{abc}
 \TextField{cde}





More information about the latex3-commits mailing list