[latex3-commits] [git/LaTeX3-latex3-pdfresources] backendtest: working on form fields (ca73701)
Ulrike Fischer
fischer at troubleshooting-tex.de
Thu Sep 5 23:59:26 CEST 2019
Repository : https://github.com/latex3/pdfresources
On branch : backendtest
Link : https://github.com/latex3/pdfresources/commit/ca73701c2d6b13ee37640052dc706a5431dc11a0
>---------------------------------------------------------------
commit ca73701c2d6b13ee37640052dc706a5431dc11a0
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Thu Sep 5 23:59:26 2019 +0200
working on form fields
>---------------------------------------------------------------
ca73701c2d6b13ee37640052dc706a5431dc11a0
experiments/formfields.tex | 54 ++++++++
hluatex-experimental.def | 305 ++++++++++++++++++++++++++-------------------
2 files changed, 234 insertions(+), 125 deletions(-)
diff --git a/experiments/formfields.tex b/experiments/formfields.tex
new file mode 100644
index 0000000..ae4b959
--- /dev/null
+++ b/experiments/formfields.tex
@@ -0,0 +1,54 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+\RequirePackage[enable-debug,check-declarations]{expl3}
+\RequirePackage[patches]{pdfresources}
+\DeclareDocumentMetaData{uncompress}
+\documentclass{article}
+\usepackage[customdriver=hluatex-experimental]{hyperref}
+\usepackage{xcolor,tikzducks,tikzlings,graphics}
+\begin{document}
+\ExplSyntaxOn
+\MakeFieldObject
+ {
+ \fbox{\tikz\duck;}
+ }
+ {xform_DuckCheckmark}
+\MakeFieldObject
+ {
+ \fbox{\tikz\bear;}
+ }
+ {xform_BearCheckmark}
+
+ \MakeFieldObject
+ {
+ \phantom{\tikz\duck;}
+ }
+ {xform_NoDuckCheckmark}
+ \MakeFieldObject
+ {
+ \phantom{\tikz\bear;}
+ }
+ {xform_NoBearCheckmark}
+
+\ExplSyntaxOff
+
+\begin{Form}[NeedAppearances=false]
+
+\LARGE\sffamily
+\CheckBox[name=check]{\makebox[4cm][l]{Check the mark!}}
+
+\bigskip
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_CheckmarkYes_tl { xform_DuckCheckmark }
+\tl_set:Nn \l__hyp_CheckmarkOff_tl { xform_NoDuckCheckmark }
+\ExplSyntaxOff
+\CheckBox[name=duck]{\makebox[4cm][l]{Check the duck!}}
+
+\ExplSyntaxOn
+\tl_set:Nn\l__hyp_CheckmarkYes_tl {xform_BearCheckmark}
+\tl_set:Nn\l__hyp_CheckmarkOff_tl {xform_NoBearCheckmark}
+\ExplSyntaxOff
+\bigskip
+\CheckBox[name=bear]{\makebox[4cm][l]{Check the bear!}}
+
+\end{Form}
+\end{document}
\ No newline at end of file
diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index bf150cf..f2abe93 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -924,6 +924,10 @@
\ExplSyntaxOff
\ExplSyntaxOn
+\tl_new:N \l__hyp_CheckmarkYes_tl
+\tl_set:Nn \l__hyp_CheckmarkYes_tl { __hyp_xform_CheckMarkYes }
+\tl_new:N \l__hyp_CheckmarkOff_tl
+\tl_set:Nn \l__hyp_CheckmarkOff_tl { __hyp_xform_CheckMarkOff }
\def\@Form[#1]
{
@@ -987,6 +991,30 @@
{__hyp_xform_Ding}
\MakeFieldObject
{
+ \group_begin:
+ \fontfamily{pzd}
+ \fontencoding{U}
+ \fontseries{m}
+ \fontshape{n}
+ \selectfont
+ \char51
+ \group_end:
+ }
+ {__hyp_xform_CheckMarkYes}
+ \MakeFieldObject
+ {
+ \group_begin:
+ \fontfamily{pzd}
+ \fontencoding{U}
+ \fontseries{m}
+ \fontshape{n}
+ \selectfont
+ \fbox{\char55} %perhaps xetex needs some small glyph ..
+ \group_end:
+ }
+ {__hyp_xform_CheckMarkOff}
+ \MakeFieldObject
+ {
\fbox{\textcolor{yellow}{\textsf{Submit}}} %color?
}
{__hyp_xform_Submit}
@@ -1000,30 +1028,34 @@
\let\@endForm\ltx at empty
\let\HyAnn at AbsPageLabel\ltx at empty
\let\Fld at pageobjref\ltx at empty
-\ltx at IfUndefined{pdfpageref}{%
-}{%
- \ltx at ifpackageloaded{zref-abspage}{%
- \newcount\HyAnn at Count
- \HyAnn at Count=\ltx at zero
- \def\HyAnn at AbsPageLabel{%
- \global\advance\HyAnn at Count by\ltx at one
- \zref at labelbyprops{HyAnn@\the\HyAnn at Count}{abspage}%
- \zref at refused{HyAnn@\the\HyAnn at Count}%
- }%
- \def\Fld at pageobjref{%
- \zref at ifrefundefined{HyAnn@\the\HyAnn at Count}{%
- }{%
- \zref at ifrefcontainsprop{HyAnn@\the\HyAnn at Count}{abspage}{%
- /P \pdfpageref
- \zref at extractdefault{HyAnn@\the\HyAnn at Count}{abspage}{1} %
- \space 0 R%
- }{%
- }%
- }%
- }%
- }{%
+
+\ExplSyntaxOn
+\newcount\HyAnn at Count
+\HyAnn at Count=\ltx at zero
+\def\HyAnn at AbsPageLabel
+ {
+ \global\advance\HyAnn at Count by\ltx at one
+ %\zref at labelbyprops{HyAnn@\the\HyAnn at Count}{abspage}%
+ \zref at labelbylist {HyAnn@\the\HyAnn at Count} {l3pdf}
+ \zref at refused{HyAnn@\the\HyAnn at Count}%
}%
-}
+\def\Fld at pageobjref
+ {
+ \zref at ifrefundefined{HyAnn@\the\HyAnn at Count}
+ {}
+ {
+ \zref at ifrefcontainsprop{HyAnn@\the\HyAnn at Count}{pdf at abspage}
+ {
+ /P~\pdf_pageobject_ref:n
+ {
+ \zref at extractdefault{HyAnn@\the\HyAnn at Count}{pdf at abspage}{1} %
+ }
+ }
+ {}
+ }
+ }
+
+\ExplSyntaxOff
\ExplSyntaxOn
%% check if the attr should be set through
%% hooks.
@@ -1284,9 +1316,9 @@
\def\Fld at width {\DefaultWidthofCheckBox}
\def\Fld at height{\DefaultHeightofCheckBox}
\exp_args:No\HyField at SetKeys
- {
- \DefaultOptionsofCheckBox,#1
- }
+ {
+ \DefaultOptionsofCheckBox,#1
+ }
\PDFForm at Name
\HyField at FlagsCheckBox
\legacy_if:nT { Fld at hidden }
@@ -1295,85 +1327,86 @@
}
\LayoutCheckField{#2}
{
- \mode_leave_vertical:
- \HyAnn at AbsPageLabel
- \Hy at escapeform\PDFForm at Check
- \pdf_annotation:nnnn
- {\Fld at width}
- {\Fld at height}
- {0pt}
- {\PDFForm at Check}
- \HyField at AddToFields
- }
+ \mode_leave_vertical:
+ \HyAnn at AbsPageLabel
+ \Hy at escapeform\PDFForm at Check
+ \pdf_annotation:nnnn
+ {\Fld at width}
+ {\Fld at height}
+ {0pt} %is this correct?
+ {\PDFForm at Check}
+ \HyField at AddToFields %check if this works with xelatex ...
+ }
\group_end:
}
\ExplSyntaxOff
%hm. Should a luatex driver use type1 fonts in fields????
\ExplSyntaxOn
-\def\Hy at FormObjects{%
- \pdf_object_new:nn {l__hyp_encoding_pdfdoc_obj } { dict }
- \pdf_object_new:nn {l__hyp_font_zapfdingbats_obj } { dict }
- \pdf_object_new:nn {l__hyp_font_helvetica_obj } { dict }
- \pdf_object_write:nx {l__hyp_encoding_pdfdoc_obj }
- {
- /Type/Encoding
- /Differences[
- 24/breve/caron/circumflex/dotaccent/hungarumlaut/ogonek
+\def\Hy at FormObjects
+ {
+ \pdf_object_new:nn {l__hyp_encoding_pdfdoc_obj } { dict }
+ \pdf_object_new:nn {l__hyp_font_zapfdingbats_obj } { dict }
+ \pdf_object_new:nn {l__hyp_font_helvetica_obj } { dict }
+ \pdf_object_write:nx {l__hyp_encoding_pdfdoc_obj }
+ {
+ /Type/Encoding
+ /Differences[
+ 24/breve/caron/circumflex/dotaccent/hungarumlaut/ogonek
/ring/tilde
- \c_space_tl
- 39/quotesingle
- \c_space_tl
- 96/grave %
- \iow_newline:
- 128/bullet/dagger/daggerdbl/ellipsis/emdash/endash/florin
- /fraction/guilsinglleft/guilsinglright/minus/perthousand
- /quotedblbase/quotedblleft/quotedblright/quoteleft
- /quoteright/quotesinglbase/trademark/fi/fl/Lslash/OE
- /Scaron/Ydieresis/Zcaron/dotlessi/lslash/oe/scaron/zcaron
- \iow_newline:
- 164/currency
- \c_space_tl
- 166/brokenbar
- \c_space_tl
- 168/dieresis/copyright/ordfeminine
- \c_space_tl
- 172/logicalnot/.notdef/registered/macron/degree/plusminus
- /twosuperior/threesuperior/acute/mu
- \c_space_tl
- 183/periodcentered/cedilla/onesuperior/ordmasculine
- \c_space_tl
- 188/onequarter/onehalf/threequarters
- \iow_newline:
- 192/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
- /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave
- /Iacute/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute
- /Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave
- /Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
- /agrave/aacute/acircumflex/atilde/adieresis/aring/ae
- /ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
- /iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute
- /ocircumflex/otilde/odieresis/divide/oslash/ugrave
- /uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
- ]
- }
- \pdf_object_write:nn {l__hyp_font_zapfdingbats_obj }
- {
- /Type/Font
- /Subtype/Type1
- /Name/ZaDb
- /BaseFont/ZapfDingbats
- }
- \pdf_object_write:nx {l__hyp_font_helvetica_obj }
- {
- /Type/Font
- /Subtype/Type1
- /Name/Helv
- /BaseFont/Helvetica
- /Encoding~\pdf_object_ref:n { l__hyp_encoding_pdfdoc_obj }
- }
+ \c_space_tl
+ 39/quotesingle
+ \c_space_tl
+ 96/grave %
+ \iow_newline:
+ 128/bullet/dagger/daggerdbl/ellipsis/emdash/endash/florin
+ /fraction/guilsinglleft/guilsinglright/minus/perthousand
+ /quotedblbase/quotedblleft/quotedblright/quoteleft
+ /quoteright/quotesinglbase/trademark/fi/fl/Lslash/OE
+ /Scaron/Ydieresis/Zcaron/dotlessi/lslash/oe/scaron/zcaron
+ \iow_newline:
+ 164/currency
+ \c_space_tl
+ 166/brokenbar
+ \c_space_tl
+ 168/dieresis/copyright/ordfeminine
+ \c_space_tl
+ 172/logicalnot/.notdef/registered/macron/degree/plusminus
+ /twosuperior/threesuperior/acute/mu
+ \c_space_tl
+ 183/periodcentered/cedilla/onesuperior/ordmasculine
+ \c_space_tl
+ 188/onequarter/onehalf/threequarters
+ \iow_newline:
+ 192/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
+ /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave
+ /Iacute/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute
+ /Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave
+ /Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+ /agrave/aacute/acircumflex/atilde/adieresis/aring/ae
+ /ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
+ /iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute
+ /ocircumflex/otilde/odieresis/divide/oslash/ugrave
+ /uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
+ ]
+ }
+ \pdf_object_write:nn {l__hyp_font_zapfdingbats_obj }
+ {
+ /Type/Font
+ /Subtype/Type1
+ /Name/ZaDb
+ /BaseFont/ZapfDingbats
+ }
+ \pdf_object_write:nx {l__hyp_font_helvetica_obj }
+ {
+ /Type/Font
+ /Subtype/Type1
+ /Name/Helv
+ /BaseFont/Helvetica
+ /Encoding~\pdf_object_ref:n { l__hyp_encoding_pdfdoc_obj }
+ }
\global\let\Hy at FormObjects\relax
-}
+ }
\ExplSyntaxOff
\providecommand*{\Fld at pageobjref}{}
\ifcsname pdf at escapestring\endcsname
@@ -1502,37 +1535,59 @@
/TM(\Fld at mappingname)%
\fi
}
-\def\PDFForm at Check{%
- /Subtype/Widget%
- \Fld at annotflags
- \Fld at pageobjref
- \Fld at annotnames
- /FT/Btn%
- \Fld at flags
- /Q \Fld at align
- /BS<</W \Fld at borderwidth /S/\Fld at borderstyle>>%
- /AP<< /N <</Yes<<>>>> >> %new string /Yes is from below
- /MK<<%
- \ifnum\Fld at rotation=\z@
- \else
- /R \Fld at rotation
- \fi
- \ifx\Fld at bordercolor\relax
- \else
- /BC[\Fld at bordercolor]%
- \fi
- \ifx\Fld at bcolor\relax
- \else
- /BG[\Fld at bcolor]%
- \fi
+\ExplSyntaxOn
+\def\PDFForm at Check
+ {
+ /Subtype/Widget
+ ~\Fld at annotflags
+ ~\Fld at pageobjref
+ ~\Fld at annotnames
+ /FT/Btn
+ \Fld at flags
+ /Q~\Fld at align
+ /BS<</W~\Fld at borderwidth /S/\Fld at borderstyle>>
+ /AP
+ <<
+ /N
+ <<
+ /Yes~\pdf_xform_ref:o{\l__hyp_CheckmarkYes_tl}
+ /Off~\pdf_xform_ref:o{\l__hyp_CheckmarkOff_tl}
+ >>
+ >>
+ /MK<<
+ \int_compare:nNnF {\Fld at rotation}={0}
+ {
+ /R~\Fld at rotation
+ }
+ \tl_if_empty:NF\Fld at bordercolor
+ {
+ /BC[\Fld at bordercolor]
+ }
+ \tl_if_empty:NF\Fld at bcolor
+ {
+ /BG[\Fld at bcolor]
+ }
/CA(\Hy at escapestring{\Fld at cbsymbol})%
- >>%
- /DA(/ZaDb \strip at pt\Fld at charsize\space Tf%
- \ifx\Fld at color\@empty\else\space\Fld at color\fi)%
- /H/P%
- \ifFld at checked /V/Yes/AS/Yes\else /V/Off/AS/Off\fi
+ >>
+ /DA
+ (
+ /ZaDb~\strip at pt\Fld at charsize\c_space_tl Tf
+ \tl_if_empty:NF \Fld at color
+ {
+ \c_space_tl \Fld at color
+ }
+ )
+ /H/P
+ \legacy_if:nTF {Fld at checked}
+ {
+ /V/Yes /AS/Yes
+ }
+ {
+ /V/Off /AS/Off
+ }
\Fld at additionalactions
}
+\ExplSyntaxOff
\ifHy at pdfa
\else
\def\PDFForm at Push{%
More information about the latex3-commits
mailing list