Debian Codegraph @

texmf-dist/source/latex/pdfmanagement/l3pdffield-textfield.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3pdffield-textfield.dtx
4 %
5 % Copyright (C) 2021-2026 The LaTeX Project
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % http://www.latex-project.org/lppl.txt
13 %
14 % This file is part of the "LaTeX PDF management bundle" (The Work in LPPL)
15 % and all files in that bundle must be distributed together.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/latex3/pdfresources
22 %
23 % for those people who are interested.
24 %
25 %<*driver>
26 \DocumentMetadata{tagging=on} % no ua-2 yet, labels of widgets missing.
27 \documentclass[full]{l3doc}
28 \usepackage{latex-lab-testphase-l3doc}
29
30 \usepackage{array,booktabs,csquotes}
31 \usepackage{l3pdffield}
32 \hypersetup{pdfauthor=The LaTeX Project,
33 pdftitle=l3pdffield (LaTeX PDF management bundle)}
34 \begin{document}
35 \DocInput{\jobname.dtx}
36 \end{document}
37 %</driver>
38 % \fi
39 % \providecommand\hook[1]{\texttt{#1}}
40 % \title{^^A
41 % The \pkg{l3pdffield-textfield} module\\ Commands to create textfield form fields ^^A
42 % \\ \LaTeX{} PDF management bundle
43 % }
44 %
45 % \author{^^A
46 % The \LaTeX{} Project\thanks
47 % {^^A
48 % E-mail:
49 % \href{mailto:[email protected]}
50 % {[email protected]}^^A
51 % }^^A
52 % }
53 %
54 % \date{Version 0.97c, released 2026-05-26}
55 %
56 % \maketitle
57 % \begin{documentation}
58 % \section{\pkg{l3pdffield-textfield} Introduction}
59 % \ExplSyntaxOn
60 % Enter~your~name:\quad \pdffield_textfield:n{name=name,fontcolor=[RGB]{00,33,99},width=5cm}
61 % \ExplSyntaxOff
62 %
63 % This is the documentation for textfield fields, for general information about form fields
64 % check the documentation l3pdffield.
65 %
66 % Textfields allows the user to input text which is then rendered by the PDF viewer and
67 % often can also be saved together with the PDF.
68 %
69 % Currently the package doesn't initialize the font |/Helv|
70 % used by default in the fields (It works also without it, but this isn't fully compliant.)
71 % I don't want to setup the same font twice and haven't yet decided how
72 % to organize the collaboration with hyperref. So for now you should load hyperref
73 % and issue the \cs{Form} command.
74 %
75 % Please keep in mind
76 % \begin{itemize}
77 % \item Not every PDF viewer supports textfields.
78 % \item The font and the exact position of the chars depends on the PDF viewer.
79 % \item The handling can depend on settings in the PDF viewer. In adobe reader for
80 % example I had to disable an option to avoid that it tries to create an appearance
81 % itself
82 % \item Standards like pdf/A disable features of form fields too
83 % (as you typically can't change the PDF).
84 % \end{itemize}
85 %
86 % \subsection{About fonts}
87 %
88 % The font color and font size can be changed with the keys |fontcolor| and
89 % |fontsize| described below. This works quite reliably (but e.g.
90 % the PDF viewer of my browser insists to show the font in blue while editing).
91 % The |fontsize| can be set to 0pt, this is interpreted as an \enquote{auto} fontsize
92 % and it will shrink if the text gets too long for the field.
93 %
94 % Much more difficult is the font family:
95 % a typical wish for textfields is that a font matching the document font is used
96 % in the fields. But how can that be done?
97 % Obviously it is not possible like with a checkbox to prepare and include appearances
98 % with the right look, the PDF reader has to render the text dynamically.
99
100 % The PDF reference mentions only one way to pass a font setting to the text field:
101 % The |DA| key can contain a font operator and the fontname used should be added
102 % along with a object reference of the font to the form resources
103 % in the |AcroForm/DR/Font| dictionary. The question is: what does a PDF renderer
104 % make with this data? Clearly the main resources to render
105 % the text can not be to rely on an embedded font and a PDF font operator as both
106 % is not enough
107 % to guarantee a sensible text support: a font operator is normally used in
108 % the page stream along with glyph indices and positioning instructions, not
109 % with unicode input, and typically a font is only partially embedded.
110 % This means the PDF viewers and editors actually have to use external
111 % resources--system fonts, or fonts that come along with the viewer and libraries
112 % to handle font shaping.
113 %
114 % Hyperref may add a reference the type1 font helvetica to the DA key, but
115 % PDF viewers use actually Arial. And if one doesn't add a font with
116 % |DA| and |DR/Font| the text field works nevertheless.
117 %
118 % This doesn't mean that the DA/DR info is ignored altogether.
119 % Adobe Reader and Pro seems to use it to choose a fitting fallback font:
120 % \begin{itemize}
121 % \item One can change the font by simply using the font name (the examples use
122 % the |font| key of this module). One get courier with |font=courier|,
123 % times with |font=times|,
124 % comic sans with |font=ComicSansMS|, DejaVu with |font=DejaVuSans|. The fonts
125 % don't need to be used in the document or added as resources in the DR/Font dictionary.
126 % Some fonts work better than other: comic sans is quite unproblematic,
127 % but DejaVu seems to trigger a font search first and so is slower (perhaps the.
128 % \item If one fill and then save such a PDF at least adobe adds
129 % the missing font resources to the PDF.
130 % \end{itemize}
131 %
132 % This lazy font setting doesn't work with other PDF viewers.
133 % In other test I had better results by actually embedding a few glyphs
134 % of the font and then adding the font
135 % as resource to the DR/Font dictionary. Sadly this requires lualatex, only there is
136 % possible to retrieve the internal font name and font object number for a larger set
137 % of fonts---with pdflatex it works only for fonts not using a virtual font, and xelatex
138 % has no access at all. The code for lualatex looked like this (the font one wants
139 % to use should be active)
140 % \begin{verbatim}
141 % \pdffield_textfield:n {name=text,font=F\pdffeedback~fontname\font}
142 % \pdfmanagement_add:nee{Catalog/AcroForm/DR/Font}
143 % {F\pdffeedback~fontname\font}
144 % {\pdffeedback~fontobjnum\font \c_space_tl 0 \c_space_tl R}
145 % \end{verbatim}
146 %
147 % \subsection{Vertical alignment}
148 % There is no way to set a reference point for the baseline.
149 % Alignment must achieved by
150 % fiddling with the height and depth of the field. The defaults (which uses as
151 % height the fontsize, and a bit depth) works okay in adobe reader with arial.
152 % If the font is set to courier, the text jumps up and one has to decrease the height
153 % by around 30\%. For a multiline field which should be top aligned you should
154 % increase the depth by the wanted amount \emph{and} the height by around 2pt.
155 %
156 % The geometry of the fields is seen by TeX, and so can influence the line spacing.
157 % If needed you should hide the height with \cs{raisebox} or \cs{smash}.
158 %
159 % \section{Textfields}
160 % Input a value:
161 % \ExplSyntaxOn
162 % \pdffield_textfield:n{name=test,width=4cm,height=0.7\baselineskip,depth=0.3\baselineskip}
163 % \ExplSyntaxOff
164 %
165 % \bigskip
166 % \subsection{Commands}
167 % \begin{function}{\pdffield_textfield:n}
168 % \begin{syntax}
169 % \cs{pdffield_textfield:n} \Arg{key val list}
170 % \end{syntax}
171 % This creates a textfield. The list of allowed keys is described below.
172 % The \meta{key val list} should at least set the name, without it the default name
173 % |textfield| is used. Textfields with the same
174 % name belong to the same field and are filled together. The default appearance
175 % is a light gray background.
176 % The default appearance is setup at the first use.
177 % \end{function}
178 %
179 %
180 % \subsection{Keys}
181 %
182 % The new textfield command accept all field and annot keys from l3pdffield,
183 % please check the documentation there. The list here mentions only a few
184 % central keys, and the keys which are either specific for textfields, or have
185 % changed functionality.
186 %
187 % Disabled keys are
188 % \begin{itemize}
189 % \item |FT| is overwritten.
190 % \item |AS| is cleared.
191 % \item |DA| is overwritten.
192 % Locally use |fontcolor|, |fontsize| and |font| instead.
193 % Globally you can set the |DA| key in the catalog with for example
194 % \begin{verbatim}
195 % \pdfmanagement_add:nnn{Catalog/AcroForm}{DA}{(/Helv~10~Tf~1~1~0~rg)}
196 % \end{verbatim}
197 % \item For textfields only the field flags |ReadOnly|, |Required| |NoExport|
198 % |Multiline|, |Password|, |FileSelect|, |DoNotSpellCheck|, |DoNotScroll| and |Comb|
199 % make sense.
200 % If |Comb| is set, |Multiline|, |Password| and |FileSelect| are unset, |MaxLen| is
201 % set to 10 if it hasn't been set previously.
202 % \end{itemize}
203 %
204 % The keys |value| and |default| are mapped to |V| and |DV| for this field type, see
205 % below.
206 %
207 %
208 % \begin{function}{preset-textfield}
209 % \begin{syntax}
210 % |preset-textfield| = \Arg{key val list}
211 % \end{syntax}
212 % This key can be used with \cs{pdffield_setup:n} and allows to set default keys for a textfield.
213 % \end{function}
214 %
215 % \begin{function}{name,T}
216 % \begin{syntax}
217 % |name| = \meta{partial name}\\
218 % |T| = \meta{partial name}
219 % \end{syntax}
220 % This sets like the |T| key for fields the partial name of the field. The value
221 % shouldn't contain a period, be not empty and sensibly consist of simple chars.
222 % Additionally the value is used to create the field ID.
223 % This means that textfield with the same partial name are annotations
224 % with the same field as parent and are filled together---this
225 % what is typically expected.
226 % The field ID is then internal and can not be used to
227 % attach another annotation.
228 % For explicit control of the field ID use the |fieldID| key.
229 % \end{function}
230 %
231 % \begin{function}{fieldID}
232 % \begin{syntax}
233 % |fieldID| = \meta{field ID}\\
234 % \end{syntax}
235 % \emph{For experts only!}
236 % This allows to give the textfield a specific ID. This is only useful
237 % in the context of a larger fieldset or if you want to attach another annotation
238 % to the field with \cs{pdffield_annot:n}. If used wrongly you can
239 % easily create an invalid fieldset. It allows you to create to fields with the
240 % same partial name, but if you want to see both
241 % you need to ensure that their full names are
242 % different---for example by adding some parent fields.
243 % \end{function}
244 %
245 % \begin{function}{parent}
246 % \begin{syntax}
247 % |parent| = \meta{field ID}\\
248 % \end{syntax}
249 % This is only needed if the field should be part
250 % of a larger fieldset. The value should be a field ID of a field created previously
251 % with \cs{pdffield_field:nn}.
252 % \end{function}
253 %
254 %
255 % \begin{function}{altname,TU}
256 % \begin{syntax}
257 % |altname| = \meta{string}\\
258 % |TU| = \meta{string}\\
259 % \end{syntax}
260 % This is sets an alternative name for user interaction.
261 % This name can only be set at the first textfield instance, when the field is initialized.
262 % \end{function}
263 %
264 % \begin{function}{mappingname,TM}
265 % \begin{syntax}
266 % |mappingname| = \meta{string}\\
267 % |TM| = \meta{string}\\
268 % \end{syntax}
269 % This is sets an alternative name for export.
270 % This name can only be set at the first textfield instance, when the field is initialized.
271 % \end{function}
272 %
273 % \begin{function}{width,height,depth}
274 % \begin{syntax}
275 % |width| = \meta{dim expression}\\
276 % |height| = \meta{dim expression}\\
277 % |depth| = \meta{dim expression}
278 % \end{syntax}
279 % These keys allow to set the dimensions of textfield instance.
280 % The value should be a dimension expression. By default
281 % |width| is 3cm, the |height| uses the fontsize (\cs{f@size} in pt),
282 % the |depth| is 0.3\cs{f@size}.
283 % \end{function}
284 %
285 % \begin{function}{appearance,rollover-appearance,down-appearance}
286 % \begin{syntax}
287 % |appearance| = \meta{name}\\
288 % |rollover-appearance| = \meta{name}\\
289 % |down-appearance| = \meta{name}
290 % \end{syntax}
291 % This keys sets the normal appearance, the rollover appearance (when the
292 % mouse hovers over the textfield) and the down appearance (when the
293 % mouse clicks). They expect the name of an existing form Xobject as value.
294 % The initial value is |pdffield/textfield/default|
295 % for the normal appearance and shows a light gray background.
296 % The other appearance are not set by default (and it is quite unclear if they
297 % make sense for a textfield).
298 % \end{function}
299 %
300 % \begin{function}{V,value}
301 % \begin{syntax}
302 % |V| = \meta{text}\\
303 % |value| = \meta{text}
304 % \end{syntax}
305 % This sets the start text in the field. The keys have an effect only at the first
306 % instance of the textfield, when the field is initialized.
307 % \end{function}
308 %
309 % \begin{function}{DV,default}
310 % \begin{syntax}
311 % |DV| = \meta{text}\\
312 % |default| = \meta{text}
313 % \end{syntax}
314 % This sets the text which is shown if the form is reset.
315 % The keys have an effect only at the first
316 % instance of the textfield, when the field is initialized.
317 % \end{function}
318 %
319 % \begin{function}{fontcolor}
320 % \begin{syntax}
321 % |fontcolor| = \meta{color expression} \verb"|" [\meta{model}]\Arg{values}\\
322 % \end{syntax}
323 % This is sets the color of font in the textfield. Internally currently RGB is used.
324 % The colors used in
325 % \meta{color expression} must be known to the \pkg{l3color} commands.
326 % The initial color is black. It is a \emph{field} setting, that means instances
327 % share the color.
328 % \end{function}
329 %
330 % \begin{function}{fontsize}
331 % \begin{syntax}
332 % |fontsize| = \meta{dim expression}
333 % \end{syntax}
334 % This is sets the size of the font in the textfield.
335 % The default value is the current font size (\cs{f@size} in pt).
336 % It is a \emph{field} setting, that means instances
337 % share the size. A value of |0pt| means |auto|.
338 % \end{function}
339 %
340 % \begin{function}{font}
341 % \begin{syntax}
342 % |font| = \meta{symbolic font name}
343 % \end{syntax}
344 % This is sets the font in the textfield. See the discussion at the begin of
345 % the documentation about some background. The default value is |Helv| and this
346 % name is setup if you load hyperref and issue the \cs{Form} command.
347 % The default value is the current font size (\cs{f@size} in pt).
348 % It is a \emph{field} setting, that means instances
349 % share the font.
350 % \end{function}
351 %
352 % \subsection{Using with hyperref}
353 % The \cs{TextField} command from hyperref also prints a label, something that the
354 % command here doesn't do. A redefinition like the following should allow \cs{TextField}
355 % to use the commands of this module. Be aware that the behaviour will not be identical!
356 % Not every setting and key from \pkg{hyperref} has been copied.
357 %
358 % \begin{verbatim}
359 % \ExplSyntaxOn\makeatletter
360 % \def\@TextField[#1]#2{\LayoutTextField{#2}{\pdffield_textfield:n {name=#2,#1}}}
361 % \ExplSyntaxOff\makeatother
362 % \end{verbatim}
363 %
364 %
365 % \end{documentation}
366 %
367 % \begin{implementation}
368 % \DoNotIndex
369 % {\\
370 % ,\bitset_clear:N
371 % ,\bitset_new:Nn
372 % ,\bitset_set_false:Nn
373 % ,\bitset_set_true:Nn
374 % ,\bitset_to_arabic:N
375 % ,\bitset_item:Nn
376 % ,\bool_new:N
377 % ,\box_dp:N
378 % ,\box_ht:N
379 % ,\clist_map_inline:nn
380 % ,\color_export:nnN
381 % ,\color_set:nn
382 % ,\color_set:nnn
383 % ,\color_select:n
384 % ,\cs_new_protected:Npn
385 % ,\cs_new_protected:cpn
386 % ,\cs_set_eq:NN
387 % ,\cs_gset_eq:cN
388 % ,\cs_set_protected:Npn
389 % ,\cs_generate_variant:Nn
390 % ,\cs_gset_eq:NN
391 % ,\c_space_tl
392 % ,\csname
393 % ,\dim_eval:n
394 % ,\dim_new:N
395 % ,\dim_to_decimal_in_bp:n
396 % ,\endcsname
397 % ,\exp_args:Ne
398 % ,\fboxsep
399 % ,\fp_eval:n
400 % ,\f@size
401 % ,\group_begin:
402 % ,\group_end:
403 % ,\hbox_to_wd:nn
404 % ,\hfill
405 % ,\hook_gput_code:nnn
406 % ,\int_eval:n
407 % ,\int_compare:nNnT
408 % ,\l_keys_choice_int
409 % ,\keys_define:nn
410 % ,\keys_set:nn
411 % ,\mode_leave_vertical:
412 % ,\msg_error:nnn
413 % ,\msg_error:nnnn
414 % ,\msg_new:nnn
415 % ,\msg_warning:nn
416 % ,\msg_warning:nnn
417 % ,\msg_warning:nnnnn
418 % ,\NeedsTeXFormat
419 % ,\normalsize
420 % ,\paperheight
421 % ,\paperwidth
422 % ,\pdf_name_from_unicode_e:n
423 % ,\pdf_object_if_exist:nTF
424 % ,\pdf_object_if_exist:nF
425 % ,\pdf_object_new:n
426 % ,\pdf_object_ref:n
427 % ,\pdf_object_ref_last:
428 % ,\pdf_object_unnamed_write:nn
429 % ,\pdf_object_write:nnn
430 % ,\pdf_string_from_unicode:nnN
431 % ,\pdfannot_box_ref_last:
432 % ,\pdfannot_dict_put:nnn
433 % ,\pdfannot_dict_remove:nn
434 % ,\pdfannot_widget_box:nnn
435 % ,\pdfdict_if_empty:nTF
436 % ,\pdfdict_get:nnN
437 % ,\pdfdict_new:n
438 % ,\pdfdict_put:nnn
439 % ,\pdfdict_remove:nn
440 % ,\pdfdict_use:n
441 % ,\pdfmanagement_add:nnn
442 % ,\pdfmeta_standard_verify:nTF
443 % ,\pdfxform_if_exist:nTF
444 % ,\pdfxform_new:nnn
445 % ,\pdfxform_ref:n
446 % ,\phantom
447 % ,\prg_do_nothing:
448 % ,\ProvidesExplPackage
449 % ,\quark_if_no_value:NT
450 % ,\raisebox
451 % ,\rule
452 % ,\seq_gput_right:Nn
453 % ,\seq_if_exist:NTF
454 % ,\seq_new:N
455 % ,\seq_use:Nn
456 % ,\smash
457 % ,\str_if_empty:NTF
458 % ,\str_if_in:NnTF
459 % ,\str_new:N
460 % ,\strut
461 % ,\strutbox
462 % ,\tl_put_right:Nn
463 % ,\tl_if_empty:NTF
464 % ,\tl_if_empty:NT
465 % ,\tl_if_empty:NF
466 % ,\tl_put_left:Nn
467 % ,\tl_if_empty:nTF
468 % ,\tl_if_head_eq_charcode:nNTF
469 % ,\tl_new:N
470 % ,\tl_set:Nn
471 % ,\tl_to_str:n
472 % ,\use:c
473 % }
474 % \section{\pkg{l3pdffield-textfield} Implementation}
475 % \begin{macrocode}
476 %<*package>
477 %<@@=pdffield>
478 % \end{macrocode}
479 % \subsection{Variables}
480 % \begin{variable}
481 % {
482 % \l_@@_DA_fontcolor_tl, \l_@@_DA_fontsize_dim, \l_@@_DA_fontname_tl
483 % }
484 % Variables for the font setup in the DA key.
485 % \begin{macrocode}
486 \tl_new:N \l_@@_DA_fontcolor_tl
487 \dim_new:N \l_@@_DA_fontsize_dim
488 \tl_new:N \l_@@_DA_fontname_tl
489 % \end{macrocode}
490 % \end{variable}
491 %
492 % \subsection{Appearances}
493 % The default appearance is a light gray background.
494 %
495 % \begin{macro}{\@@_textfield_default_appearance:}
496 % This defines the standard appearance. It is setup at the first
497 % use of a textfield.
498 % \begin{macrocode}
499 \cs_new_protected:Npn {\@@_textfield_default_appearance:}
500 {
501 \pdffield_appearance:nn {pdffield/textfield/default}
502 {
503 { \color_select:n{black!5!white}\rule{\paperwidth}{\paperheight} }
504 }
505 \cs_gset_eq:NN \@@_textfield_default_appearance: \prg_do_nothing:
506 }
507 % \end{macrocode}
508 % \end{macro}
509 %
510 %\subsection{Creating the field}
511 % \begin{macro}{\@@_textfield_field:n}
512 % A field should be created only if the name doesn't exist
513 % \begin{macrocode}
514 \cs_new_protected:Npn \@@_textfield_field:n #1 %name
515 {
516 \pdf_object_if_exist:nF {@@/field/@@/textfield/#1}
517 {
518 \@@_field:n { @@/textfield/#1 }
519 }
520 \keys_set:nn {pdffield}{parent={@@/textfield/#1}}
521 }
522 \cs_generate_variant:Nn \@@_textfield_field:n {V}
523 % \end{macrocode}
524 % \end{macro}
525 %
526 % \subsection{Assembling the textfield}
527 %
528 % \begin{macro}{\@@_textfield:n}
529 % At first we map the handler and setup the appearance.
530 % \begin{macrocode}
531 \cs_new_protected:Npn \@@_textfield:n #1
532 {
533 \group_begin:
534 \cs_set_eq:NN\@@_V_handler:nN \@@_textfield_V_handler:nN
535 \cs_set_eq:NN\@@_value_handler:n \@@_textfield_value_handler:n
536 \cs_set_eq:NN\@@_default_handler:n \@@_textfield_default_handler:n
537 \@@_textfield_default_appearance:
538 % \end{macrocode}
539 % Setting up the defaults and processing the keys.
540 % \begin{macrocode}
541 \keys_set:nn {pdffield}
542 {
543 ,fieldID=
544 ,name=textfield
545 ,appearance = pdffield/textfield/default
546 ,width = 3cm
547 ,fontsize= \f@size pt
548 ,height = \f@size pt,
549 depth = \fp_eval:n {0.3*\f@size} pt,
550 % font defaults!!
551 }
552 \keys_set:nn { pdffield }{@@/preset/textfield,#1}
553 % \end{macrocode}
554 % We need to check if Comb is used and setup some flags in this case.
555 % \begin{macrocode}
556 \int_compare:nNnT {\bitset_item:Nn \l_@@_Ff_bitset {Comb}}={1}
557 {
558 % warning if set?
559 \keys_set:nn { pdffield }
560 {
561 ,unsetFf={FileSelect,Multiline,Password}
562 }
563 \pdfdict_get:nnN {l_@@/field}{MaxLen}\l_@@_tmpa_tl
564 \quark_if_no_value:NT \l_@@_tmpa_tl
565 {
566 \keys_set:nn { pdffield}
567 {
568 MaxLen = 10 %variable
569 }
570 % warning
571 }
572 }
573 % \end{macrocode}
574 % Now the postprocessing.
575 % \begin{macrocode}
576 \keys_set:nn { pdffield }
577 {
578 ,FT= Tx
579 ,AS=
580 ,DA=
581 {
582 \pdf_name_from_unicode_e:n{\l_@@_DA_fontname_tl}
583 \c_space_tl
584 \dim_to_decimal_in_bp:n{\l_@@_DA_fontsize_dim}
585 \c_space_tl
586 Tf
587 \c_space_tl
588 \l_@@_DA_fontcolor_tl
589 \c_space_tl
590 %\l_@@_text_DAextra_tl
591 }
592 }
593 % \end{macrocode}
594 % If no field ID exists, we get it from the T key.
595 % \begin{macrocode}
596 \tl_if_empty:NT\l_@@_fieldID_tl
597 {
598 \pdfdict_get:nnN {l_@@/field}{T}\l_@@_fieldID_tl
599 \tl_put_left:Nn \l_@@_fieldID_tl {@@/textfield/}
600 }
601 \@@_textfield_field:V\l_@@_fieldID_tl
602 \@@_annot:
603 \group_end:
604 }
605 % \end{macrocode}
606 % \end{macro}
607 %
608 % \subsection{Keys}
609 % Most keys are inherited simply the ones from the generic field and annot keys.
610 % A key to decide if the box is initially checked or not.
611 % We stay in the same family so that we can build a style.
612 % \begin{macro}{fontcolor,fontsize,font}
613 % \begin{macrocode}
614 \keys_define:nn {pdffield}
615 {
616 ,fontcolor .code:n =
617 {
618 \@@_color_set:nn {@@/tmp}{#1}
619 \color_export:nnN{@@/tmp}{space-sep-rgb}\l_@@_DA_fontcolor_tl
620 \tl_put_right:Nn \l_@@_DA_fontcolor_tl{~rg}
621 }
622 ,fontcolor .initial:n = black,
623 ,fontcolor .groups:n = {textfield}
624 ,font .tl_set:N = \l_@@_DA_fontname_tl
625 ,font .initial:n = {Helv}
626 ,font .groups:n = {textfield}
627 ,fontsize .dim_set:N = \l_@@_DA_fontsize_dim
628 ,fontsize .initial:n = {10bp}
629 ,fontsize .groups:n = {textfield}
630 }
631 % \end{macrocode}
632 % \end{macro}
633 %
634 % \subsection{Handler}
635 % \begin{macro}{\@@_textfield_V_handler:nN}
636 % The handler for V/DV, it creates a string.
637 % \begin{macrocode}
638 \cs_new_protected:Npn \@@_textfield_V_handler:nN #1#2
639 {
640 \pdf_string_from_unicode:nnN {utf16/hex}{#1}#2
641 }
642 % \end{macrocode}
643 % \end{macro}
644 % \begin{macro}{\@@_textfield_value_handler:n,\@@_textfield_default_handler:n}
645 % The handler for value and default. They simply map to V,DV here.
646 % \begin{macrocode}
647 \cs_new_protected:Npn \@@_textfield_value_handler:n #1
648 {
649 \keys_set:nn{pdffield}{V={#1}}
650 }
651 \cs_new_protected:Npn \@@_textfield_default_handler:n #1
652 {
653 \keys_set:nn{pdffield}{DV={#1}}
654 }
655 % \end{macrocode}
656 % \end{macro}
657 % \subsection{User command}
658 % \begin{macro}{\pdffield_textfield:n}
659 % \begin{macrocode}
660 \cs_set_eq:NN \pdffield_textfield:n \@@_textfield:n
661 %</package>
662 % \end{macrocode}
663 % \end{macro}
664 %\end{implementation}
665 %\PrintIndex