[latex3-commits] [git/LaTeX3-latex3-pdfresources] test-new-hooks: testing fields (b1aa0b6)
Ulrike Fischer
fischer at troubleshooting-tex.de
Thu May 21 01:00:26 CEST 2020
Repository : https://github.com/latex3/pdfresources
On branch : test-new-hooks
Link : https://github.com/latex3/pdfresources/commit/b1aa0b62c1c29e7910cdf8de468e065e4c634f90
>---------------------------------------------------------------
commit b1aa0b62c1c29e7910cdf8de468e065e4c634f90
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Thu May 21 01:00:26 2020 +0200
testing fields
>---------------------------------------------------------------
b1aa0b62c1c29e7910cdf8de468e065e4c634f90
experiments/{checkbox-test.tex => field-test.tex} | 90 ++++++++++++++---------
1 file changed, 57 insertions(+), 33 deletions(-)
diff --git a/experiments/checkbox-test.tex b/experiments/field-test.tex
similarity index 68%
copy from experiments/checkbox-test.tex
copy to experiments/field-test.tex
index b881fb8..fdb8382 100644
--- a/experiments/checkbox-test.tex
+++ b/experiments/field-test.tex
@@ -81,9 +81,9 @@
\newcheckboxappearance {checkbox/Off/unicode}
- {\normalfont ☐}
+ {\normalfont \iftutex ☐\else U\fi}
\newcheckboxappearance {checkbox/Yes/unicode}
- {\normalfont ☑}
+ {\normalfont \iftutex ☑\else D\fi}
\newcheckboxappearance {checkbox/Off/tikz}
{
@@ -127,38 +127,58 @@
{ \dim_max:nn { \pdf_xform_dp:e {\l__uf_normal_off_tl} }{ \pdf_xform_dp:e {\l__uf_normal_yes_tl} } }
}
+\cs_new_protected:Npn \pdfannot_field:nn #1 #2 %#1 type e.g. Btn. #2 name
+ {
+ \pdf_object_if_exist:nTF {pdf/annot/Field/#1/#2}
+ {
+ %debug info?
+ }
+ {
+ \group_begin:
+ \pdf_object_new:nn {pdf/annot/Field/#1/#2} {dict}
+ \pdf_object_new:nn {pdf/annot/Field/#1/#2/Kids} {array}
+ \seq_new:c {g__pdf/annot/Field/#1/#2/Kids_seq}
+ \hook_gput_code:nnn {enddocument/afterlastpage}{pdf}
+ {
+ \pdf_object_write:nx
+ {pdf/annot/Field/#1/#2/Kids}
+ { \seq_use:cn{g__pdf/annot/Field/#1/#2/Kids_seq}{~} }
+ }
+ \pdfdict_gput:nnx
+ { Catalog / AcroForm }
+ { Fields }
+ { \pdf_object_ref:n {pdf/annot/Field/#1/#2} }
+ % Standard dictionary entries:
+ \pdfdict_put:nnx %flags, Ff
+ {annot/Field}{Ff}{\pdfannot_flag_use:n{annot/Field}}
+ \pdfdict_put:nnn %type, FT
+ {annot/Field}{FT}{/#1}
+ \pdfdict_put:nnx %Kids
+ {annot/Field}{Kids}{\pdf_object_ref:n {pdf/annot/Field/#1/#2/Kids}}
+ \pdfdict_put:nnn
+ {annot/Field}{T}{(#2)}
+ %write the field object and put in the field entry
+ \pdf_object_write:nx {pdf/annot/Field/#1/#2} { \pdfdict_map:n {annot/Field} }
+ \pdfdict_gput:nnx { Catalog / AcroForm } { Fields }{\pdf_object_ref:n {pdf/annot/Field/#1/#2} }
+ \group_end:
+ }
+ }
\cs_new_protected:Npn \__uf_checkbox_fielddict:n #1
{
- %#1 should pass through some escaping!
- \pdf_object_if_exist:nTF {annot/Field/Btn/#1}
- {
- %needed ? later
- }
- {
- \group_begin:
- \pdf_object_new:nn {annot/Field/Btn/#1} {dict}
- \pdf_object_new:nn {annot/Field/Btn/#1/Kids} {array}
- \seq_new:c {g_annot/Field/Btn/#1/Kids_seq}
- \hook_gput_code:nnn {enddocument/afterlastpage}{pdf}
- {
- \pdf_object_write:nx {annot/Field/Btn/#1/Kids} { \seq_use:cn{g_annot/Field/Btn/#1/Kids_seq}{~} }
- }
- \pdfdict_put:nnn {annot/Field}{FT}{/Btn}
- \pdfdict_put:nnn {annot/Field}{T}{(#1)}
- \pdfdict_put:nnn {annot/Field}{V}{/Off} %should be configurable/in sync with /AS/DV
- \pdfdict_put:nnn {annot/Field}{DV}{/Off} %should be configurable/in sync with /AS/DV
- \pdfdict_put:nnx {annot/Field}{Kids}{\pdf_object_ref:n {annot/Field/Btn/#1/Kids}}
- \pdfannot_flag_clear:nn {annot/Field}{Radio} %just in case
- \pdfannot_flag_clear:nn {annot/Field}{Pushbutton} %just in case
- \pdfannot_flag_set:nn {annot/Field}{NoExport}
- \pdfdict_put:nnx {annot/Field}{Ff}{\pdfannot_flag_use:n{annot/Field}}
- \pdf_object_write:nx {annot/Field/Btn/#1} { \pdfdict_map:n {annot/Field} }
- \pdfdict_gput:nnx { Catalog / AcroForm } { Fields }{\pdf_object_ref:n {annot/Field/Btn/#1} }
- \group_end:
- }
+ \group_begin:
+ \pdfdict_put:nnn {annot/Field}{V}{/Off} %should be configurable/in sync with /AS/DV
+ \pdfdict_put:nnn {annot/Field}{DV}{/Off} %should be configurable/in sync with /AS/DV
+ \pdfannot_flag_clear:nn {annot/Field}{Radio} %just in case
+ \pdfannot_flag_clear:nn {annot/Field}{Pushbutton} %just in case
+ \pdfannot_flag_set:nn {annot/Field}{NoExport}
+
+
+ \pdfannot_field:nn {Btn}{#1}
+
+ \group_end:
}
\cs_new_protected:Npn \__uf_checkbox_annot:n #1
@@ -174,8 +194,9 @@
{ \dim_use:N \l__uf_field_ht_dim }
{ \dim_use:N \l__uf_field_dp_dim }
{
- /Parent~ \pdf_object_ref:n{annot/Field/Btn/#1}
+ /Parent~ \pdf_object_ref:n{pdf/annot/Field/Btn/#1}
/AS ~ /Off
+ /H/P
/AP ~
<<
/N ~
@@ -186,7 +207,7 @@
}
\hfill
}
- \seq_gput_right:cx {g_annot/Field/Btn/#1/Kids_seq}{ \pdfannot_box_last:}
+ \seq_gput_right:cx {g__pdf/annot/Field/Btn/#1/Kids_seq}{ \pdfannot_box_last:}
\group_end:
}
% # form and field interface macros
@@ -209,8 +230,9 @@
\ExplSyntaxOff
-\begin{document}
-\begin{Form}[NeedAppearances=false]
+\begin{document}\errorcontextlines200
+\begin{Form}[NeedAppearances=false,action=mailto:
+ ,encoding=html, method=post]
1: \checkboxfield{checkbox1}
@@ -239,7 +261,9 @@ normal yes = checkbox/Yes/bear]{checkbox6}
normal off = checkbox/Off/bear,
normal yes = checkbox/Yes/bear]{checkbox2}
+\Submit{Submit}
+%\PushButton[onclick={this.exportAsText()}]{Submit}
\end{Form}
\end{document}
More information about the latex3-commits
mailing list.