]> git.lyx.org Git - lyx.git/blob - lib/examples/PDF-form.lyx
Amend and extend 9f3518bc
[lyx.git] / lib / examples / PDF-form.lyx
1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 508
3 \begin_document
4 \begin_header
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/
7 \textclass scrartcl
8 \begin_preamble
9 % used to check for needed LaTeX packages
10 \usepackage{ifthen}
11
12 % check for package insdljs
13 % used for JavScript code
14 \newboolean{insdljs}
15 \IfFileExists{insdljs.sty}
16  {\usepackage[pdftex]{insdljs}
17   \setboolean{insdljs}{true}}
18  {\setboolean{insdljs}{false}}
19
20 \pdfcatalog{/AA \the\pdflastobj\space 0 R}
21
22 \ifinsdljs % only execute if package insdljs is installed
23
24  \begin{insDLJS}[exaaae]{exaaae}{JavaScript}
25
26   function validateTime(){
27    this.delay = true;
28    if((event.value == "u") || (event.value == "unlimited")) {
29     this.getField("from").display = display.hidden;
30     this.getField("to").display = display.hidden;
31    } else {
32     this.getField("from").display = display.visible;
33     this.getField("to").display = display.visible;
34     this.getField("from").setFocus();
35    }
36    this.delay = false;
37   }
38  
39  function checkNumber() {
40   event.rc = true;
41   if (!Number(event.value))
42   {
43    app.alert("Value must be a number!");
44    event.value = "";
45   }  else {
46    event.target.textColor = color.green;
47  }
48
49 }
50
51  \end{insDLJS}
52
53 \fi % end \ifinsdljs
54
55 % if pdflatex is used
56 \usepackage{ifpdf}
57 \ifpdf
58
59 % set fonts for nicer pdf view
60 \IfFileExists{lmodern.sty}
61  {\usepackage{lmodern}}{}
62
63 \fi % end if pdflatex is used
64 \end_preamble
65 \options BCOR8mm,pagesize
66 \use_default_options false
67 \begin_modules
68 pdfform
69 \end_modules
70 \maintain_unincluded_children false
71 \language english
72 \language_package default
73 \inputencoding auto
74 \fontencoding global
75 \font_roman "default" "default"
76 \font_sans "default" "default"
77 \font_typewriter "default" "default"
78 \font_math "auto" "auto"
79 \font_default_family default
80 \use_non_tex_fonts false
81 \font_sc false
82 \font_osf false
83 \font_sf_scale 100 100
84 \font_tt_scale 100 100
85 \graphics default
86 \default_output_format pdf2
87 \output_sync 0
88 \bibtex_command bibtex
89 \index_command default
90 \paperfontsize 12
91 \spacing single
92 \use_hyperref true
93 \pdf_title "Description of the module pdfcomment"
94 \pdf_author "Uwe Stöhr"
95 \pdf_subject "PDF form"
96 \pdf_keywords "LyX, PDF forms, hyperref"
97 \pdf_bookmarks true
98 \pdf_bookmarksnumbered true
99 \pdf_bookmarksopen true
100 \pdf_bookmarksopenlevel 2
101 \pdf_breaklinks false
102 \pdf_pdfborder false
103 \pdf_colorlinks false
104 \pdf_backref false
105 \pdf_pdfusetitle false
106 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false, urlbordercolor={1 0 0}"
107 \papersize a4paper
108 \use_geometry false
109 \use_package amsmath 1
110 \use_package amssymb 1
111 \use_package cancel 0
112 \use_package esint 1
113 \use_package mathdots 1
114 \use_package mathtools 1
115 \use_package mhchem 1
116 \use_package stackrel 0
117 \use_package stmaryrd 0
118 \use_package undertilde 0
119 \cite_engine basic
120 \cite_engine_type default
121 \biblio_style plain
122 \use_bibtopic false
123 \use_indices false
124 \paperorientation portrait
125 \suppress_date true
126 \justification true
127 \use_refstyle 0
128 \notefontcolor #0000ff
129 \index Index
130 \shortcut idx
131 \color #008000
132 \end_index
133 \secnumdepth 3
134 \tocdepth 2
135 \paragraph_separation skip
136 \defskip medskip
137 \quotes_language english
138 \papercolumns 1
139 \papersides 1
140 \paperpagestyle default
141 \tracking_changes false
142 \output_changes false
143 \html_math_output 0
144 \html_css_as_file 0
145 \html_be_strict false
146 \end_header
147
148 \begin_body
149
150 \begin_layout Begin PDF Form
151 \begin_inset Argument 1
152 status open
153
154 \begin_layout Plain Layout
155 action=mailto:forms@lyx.test?subject=The submitted PDF form, method=post
156 \end_layout
157
158 \end_inset
159
160
161 \end_layout
162
163 \begin_layout Title
164 Description of the module PDF Form
165 \end_layout
166
167 \begin_layout Author
168 Uwe Stöhr
169 \end_layout
170
171 \begin_layout Standard
172 \begin_inset Note Note
173 status open
174
175 \begin_layout Plain Layout
176 To export all parts of this document to PDF the \SpecialChar LaTeX
177 -package 
178 \series bold
179 insdljs
180 \series default
181  must be installed.
182  If it is not installed you can export the document anyway but the example
183  in the section about dynamic form fields won't appear in the output.
184 \end_layout
185
186 \end_inset
187
188
189 \end_layout
190
191 \begin_layout Standard
192 By loading the module PDF
193 \begin_inset space ~
194 \end_inset
195
196 Form the whole document or a part of it can be made a PDF form.
197  You can add all possible form elements like text fields buttons etc.
198  This document describes how this is done.
199 \end_layout
200
201 \begin_layout Section
202 Preparation
203 \begin_inset CommandInset label
204 LatexCommand label
205 name "sec:Preparation"
206
207 \end_inset
208
209
210 \end_layout
211
212 \begin_layout Standard
213 At first load the module PDF
214 \begin_inset space ~
215 \end_inset
216
217 Form in the document settings of your file.
218  To make the whole document a form, insert the environment
219 \family sans
220  Begin
221 \begin_inset space ~
222 \end_inset
223
224 PDF
225 \begin_inset space ~
226 \end_inset
227
228 Form
229 \family default
230  from \SpecialChar LyX
231 's dropdown menu at the beginning of the document.
232  If only a part of the document should be a form, add 
233 \family sans
234 Begin
235 \begin_inset space ~
236 \end_inset
237
238 PDF
239 \begin_inset space ~
240 \end_inset
241
242 Form
243 \family default
244  at the position where the form should start.
245 \end_layout
246
247 \begin_layout Standard
248 \begin_inset Note Greyedout
249 status open
250
251 \begin_layout Plain Layout
252
253 \series bold
254 Note:
255 \series default
256  It is only possible to have one form in a PDF file!
257 \end_layout
258
259 \end_inset
260
261
262 \end_layout
263
264 \begin_layout Standard
265 If the form data should be submitted to a server or the like, then you must
266  specify the URL as parameter of the 
267 \family sans
268 Begin
269 \begin_inset space ~
270 \end_inset
271
272 PDF
273 \begin_inset space ~
274 \end_inset
275
276 Form
277 \family default
278  environment.
279  This is done by using the menu 
280 \family sans
281 Insert\SpecialChar menuseparator
282 PDF
283 \begin_inset space ~
284 \end_inset
285
286 form
287 \begin_inset space ~
288 \end_inset
289
290 parameters
291 \family default
292 .
293  For example in this document the following was inserted to the parameter
294  inset:
295 \end_layout
296
297 \begin_layout Standard
298
299 \series bold
300 action=mailto:forms@lyx.test?subject=The submitted PDF form,
301 \begin_inset Newline newline
302 \end_inset
303
304 method=post
305 \end_layout
306
307 \begin_layout Standard
308 This sends the form data as email to 
309 \emph on
310 forms@lyx.test
311 \emph default
312  when the user presses the submit button.
313  The email subject will be 
314 \begin_inset Quotes eld
315 \end_inset
316
317 The submitted PDF form
318 \begin_inset Quotes erd
319 \end_inset
320
321  and the HTML method is 
322 \series bold
323 post
324 \series default
325 .
326  (The other possible method would be 
327 \series bold
328 get
329 \series default
330 .) For more about submitting see sec.
331 \begin_inset space \thinspace{}
332 \end_inset
333
334
335 \begin_inset CommandInset ref
336 LatexCommand ref
337 reference "subsec:Submit-button"
338
339 \end_inset
340
341 .
342 \end_layout
343
344 \begin_layout Standard
345 \begin_inset Newpage newpage
346 \end_inset
347
348
349 \end_layout
350
351 \begin_layout Section
352 Form fields
353 \end_layout
354
355 \begin_layout Standard
356 There are 6
357 \begin_inset space ~
358 \end_inset
359
360 possible types of fields in a PDF form:
361 \end_layout
362
363 \begin_layout Subsection
364 Text field
365 \end_layout
366
367 \begin_layout Standard
368 A text field is added by inserting the custom inset 
369 \family sans
370 TextField
371 \family default
372  using the menu 
373 \family sans
374 Insert\SpecialChar menuseparator
375 Custom
376 \begin_inset space ~
377 \end_inset
378
379 Insets
380 \family default
381 .
382  Write inside the inset the label for the text field that will be printed
383  in the PDF output before the field.
384  Here is an example:
385 \begin_inset Newline newline
386 \end_inset
387
388
389 \begin_inset Flex TextField
390 status open
391
392 \begin_layout Plain Layout
393 \begin_inset Argument 1
394 status open
395
396 \begin_layout Plain Layout
397 name=customer
398 \end_layout
399
400 \end_inset
401
402 Enter your name here:
403 \end_layout
404
405 \end_inset
406
407
408 \end_layout
409
410 \begin_layout Standard
411 You must also specify a field name for text fields: Set the cursor into
412  its 
413 \family sans
414 Params
415 \family default
416  inset.
417  There insert for example the parameter 
418 \series bold
419 name=customer
420 \series default
421  (where 
422 \series bold
423 customer
424 \series default
425  is the field name).
426 \end_layout
427
428 \begin_layout Standard
429 Using the same name for several text fields results in an automatic duplication
430  of the inserted text.
431  This is for example useful if the user should input a date that should
432  appear at different places in the form.
433 \begin_inset Newline newline
434 \end_inset
435
436 Here are 2
437 \begin_inset space ~
438 \end_inset
439
440 fields as example: Fill one and see that the other one will also be filled
441  automatically:
442 \begin_inset Newline newline
443 \end_inset
444
445
446 \begin_inset Flex TextField
447 status open
448
449 \begin_layout Plain Layout
450 \begin_inset Argument 1
451 status open
452
453 \begin_layout Plain Layout
454 name=identic
455 \end_layout
456
457 \end_inset
458
459
460 \end_layout
461
462 \end_inset
463
464
465 \begin_inset Newline newline
466 \end_inset
467
468
469 \begin_inset Flex TextField
470 status open
471
472 \begin_layout Plain Layout
473 \begin_inset Argument 1
474 status open
475
476 \begin_layout Plain Layout
477 name=identic
478 \end_layout
479
480 \end_inset
481
482
483 \end_layout
484
485 \end_inset
486
487
488 \end_layout
489
490 \begin_layout Standard
491 All form fields can be customized by adding parameters.
492 \end_layout
493
494 \begin_layout Standard
495 Here is a customized multiline text field with a width of 60
496 \begin_inset space \thinspace{}
497 \end_inset
498
499 % of the text width, 3
500 \begin_inset space \thinspace{}
501 \end_inset
502
503 cm height and a proposed content:
504 \begin_inset VSpace defskip
505 \end_inset
506
507
508 \begin_inset Newline newline
509 \end_inset
510
511
512 \begin_inset Flex TextField
513 status open
514
515 \begin_layout Plain Layout
516 \begin_inset Argument 1
517 status open
518
519 \begin_layout Plain Layout
520 name=customer2, multiline, width=0.6
521 \backslash
522 textwidth, height=3cm, value={Testman}
523 \end_layout
524
525 \end_inset
526
527 Enter your name here:
528 \end_layout
529
530 \end_inset
531
532
533 \end_layout
534
535 \begin_layout Standard
536 \begin_inset Note Greyedout
537 status open
538
539 \begin_layout Plain Layout
540
541 \series bold
542 Note:
543 \series default
544  It is highly recommended to use a uniform layout of all fields in your
545  form.
546  See sec.
547 \begin_inset space \thinspace{}
548 \end_inset
549
550
551 \begin_inset CommandInset ref
552 LatexCommand ref
553 reference "sec:Form-field-customization"
554
555 \end_inset
556
557  for how this is done.
558 \end_layout
559
560 \end_inset
561
562
563 \end_layout
564
565 \begin_layout Subsection
566 Check box
567 \end_layout
568
569 \begin_layout Standard
570 A check box is added by inserting the custom inset 
571 \family sans
572 CheckBox
573 \family default
574 .
575  Write inside the inset the label for the box.
576  Here is an example:
577 \begin_inset Newline newline
578 \end_inset
579
580
581 \begin_inset Flex CheckBox
582 status open
583
584 \begin_layout Plain Layout
585 \begin_inset Argument 1
586 status open
587
588 \begin_layout Plain Layout
589 name=age
590 \end_layout
591
592 \end_inset
593
594 Are you older than 18 years?
595 \end_layout
596
597 \end_inset
598
599
600 \end_layout
601
602 \begin_layout Standard
603 You must also specify a field name for check boxes: Insert for example the
604  parameter 
605 \series bold
606 name=age
607 \series default
608  (where 
609 \series bold
610 age
611 \series default
612  is the field name) into the 
613 \family sans
614 Params
615 \family default
616  inset.
617 \end_layout
618
619 \begin_layout Subsection
620 Choice menu
621 \end_layout
622
623 \begin_layout Standard
624 A choice menu is added by inserting the custom inset 
625 \family sans
626 ChoiceMenu
627 \family default
628 .
629  A label for the inset is added by using the menu 
630 \family sans
631 Insert\SpecialChar menuseparator
632 Label
633 \family default
634 .
635  Insert the label text into this inset.
636 \begin_inset Newline newline
637 \end_inset
638
639 The different choices are inserted to the inset as comma-separated list.
640  There are 3
641 \begin_inset space ~
642 \end_inset
643
644 choice menu types:
645 \end_layout
646
647 \begin_layout Description
648 Radio Only one choice can be selected
649 \end_layout
650
651 \begin_layout Description
652 Combo The choices are listed in a combo box (dropdown list) but the user
653  is allowed to choose something that is not in the predefined list.
654 \end_layout
655
656 \begin_layout Description
657 Popdown All choices are listed below each other.
658  It the filed is not high enough a scroll bar is automatically added to
659  the field.
660 \end_layout
661
662 \begin_layout Standard
663 To determine the choice menu type, add the parameter 
664 \series bold
665 radio
666 \series default
667
668 \series bold
669 combo
670 \series default
671  or 
672 \series bold
673 popdown
674 \series default
675 .
676 \end_layout
677
678 \begin_layout Standard
679 Here is an example for the radio type:
680 \begin_inset VSpace defskip
681 \end_inset
682
683
684 \begin_inset Newline newline
685 \end_inset
686
687
688 \begin_inset Flex ChoiceMenu
689 status open
690
691 \begin_layout Plain Layout
692 \begin_inset Argument 1
693 status open
694
695 \begin_layout Plain Layout
696 radio, name=radio
697 \end_layout
698
699 \end_inset
700
701 male=m, female=f
702 \begin_inset Argument 2
703 status open
704
705 \begin_layout Plain Layout
706 Sex:
707 \end_layout
708
709 \end_inset
710
711
712 \end_layout
713
714 \end_inset
715
716
717 \end_layout
718
719 \begin_layout Standard
720 Here is an example for the combo type:
721 \begin_inset VSpace defskip
722 \end_inset
723
724
725 \begin_inset Newline newline
726 \end_inset
727
728
729 \begin_inset Flex ChoiceMenu
730 status open
731
732 \begin_layout Plain Layout
733 \begin_inset Argument 1
734 status open
735
736 \begin_layout Plain Layout
737 combo, name=combo
738 \end_layout
739
740 \end_inset
741
742 Albania=Al, Armenia=Ar, Azerbaidschan=Az
743 \begin_inset Argument 2
744 status open
745
746 \begin_layout Plain Layout
747 Country:
748 \end_layout
749
750 \end_inset
751
752
753 \end_layout
754
755 \end_inset
756
757
758 \end_layout
759
760 \begin_layout Standard
761 Here is an example for the popdown type:
762 \begin_inset VSpace defskip
763 \end_inset
764
765
766 \begin_inset Newline newline
767 \end_inset
768
769
770 \begin_inset Flex ChoiceMenu
771 status open
772
773 \begin_layout Plain Layout
774 \begin_inset Argument 1
775 status open
776
777 \begin_layout Plain Layout
778 popdown, name=country
779 \end_layout
780
781 \end_inset
782
783 Albania=Al, Armenia=Ar, Azerbaidschan=Az
784 \begin_inset Argument 2
785 status open
786
787 \begin_layout Plain Layout
788 Country:
789 \end_layout
790
791 \end_inset
792
793
794 \end_layout
795
796 \end_inset
797
798
799 \end_layout
800
801 \begin_layout Standard
802 You must also specify a field name for choice menus: Insert for example
803  the parameter 
804 \series bold
805 name=country
806 \series default
807  (where 
808 \series bold
809 country
810 \series default
811  is the field name) into the 
812 \family sans
813 Params
814 \family default
815  inset.
816 \end_layout
817
818 \begin_layout Standard
819 It is recommended to add a short name for every choice to be able to access
820  them and to know which one was chosen by the user.
821  This is done by adding 
822 \series bold
823 =name
824 \series default
825  behind each choice (where 
826 \series bold
827 name
828 \series default
829  is the choice name).
830  For example the radio type example contains this choice list:
831 \series bold
832  male=m, female=f
833 \series default
834 .
835  If the user chose 
836 \begin_inset Quotes eld
837 \end_inset
838
839 male
840 \begin_inset Quotes erd
841 \end_inset
842
843  you know that he chose the choice 
844 \begin_inset Quotes eld
845 \end_inset
846
847 m
848 \begin_inset Quotes erd
849 \end_inset
850
851 .
852  By specifying names you can also preset/propose e.g.
853 \begin_inset space \space{}
854 \end_inset
855
856 the choice 
857 \begin_inset Quotes eld
858 \end_inset
859
860 male
861 \begin_inset Quotes erd
862 \end_inset
863
864  by adding the parameter 
865 \series bold
866 default=m
867 \series default
868 .
869  Here is an example:
870 \end_layout
871
872 \begin_layout Standard
873 \begin_inset Flex ChoiceMenu
874 status open
875
876 \begin_layout Plain Layout
877 \begin_inset Argument 1
878 status open
879
880 \begin_layout Plain Layout
881 radio, name=sex, default=m
882 \end_layout
883
884 \end_inset
885
886 male=m, female=f
887 \begin_inset Argument 2
888 status open
889
890 \begin_layout Plain Layout
891 Sex:
892 \end_layout
893
894 \end_inset
895
896
897 \end_layout
898
899 \end_inset
900
901
902 \end_layout
903
904 \begin_layout Standard
905 \begin_inset Note Greyedout
906 status open
907
908 \begin_layout Plain Layout
909
910 \series bold
911 Note:
912 \series default
913  Due to a bug in the \SpecialChar LaTeX
914  package 
915 \series bold
916 hyperref
917 \series default
918  it is currently only possible the set the first choice as default.
919 \end_layout
920
921 \end_inset
922
923
924 \end_layout
925
926 \begin_layout Standard
927 \begin_inset Newpage newpage
928 \end_inset
929
930
931 \end_layout
932
933 \begin_layout Subsection
934 Push button
935 \end_layout
936
937 \begin_layout Standard
938 A push button is added by inserting the custom inset 
939 \family sans
940 PushButton
941 \family default
942 .
943  Write inside the inset the label for the button.
944  Here is an example:
945 \end_layout
946
947 \begin_layout Standard
948 \begin_inset Flex PushButton
949 status open
950
951 \begin_layout Plain Layout
952 \begin_inset Argument 1
953 status open
954
955 \begin_layout Plain Layout
956
957 \end_layout
958
959 \end_inset
960
961 Don't click on this button or your fridge will be destroyed!!!
962 \end_layout
963
964 \end_inset
965
966
967 \end_layout
968
969 \begin_layout Standard
970 The action that is triggered by pressing the button is specified by JavaScript
971  code.
972  To specify it, add the parameter 
973 \series bold
974 onclick={}
975 \series default
976  and insert the JavaScript code between the braces.
977  For info about JavaScript, see its documentation, 
978 \begin_inset CommandInset citation
979 LatexCommand cite
980 key "JavaScript"
981
982 \end_inset
983
984 .
985  In the following example this JavaScript code was used:
986 \begin_inset Newline newline
987 \end_inset
988
989
990 \series bold
991 app.alert(
992 \begin_inset ERT
993 status collapsed
994
995 \begin_layout Plain Layout
996
997 "
998 \end_layout
999
1000 \end_inset
1001
1002 What the hell? Now you destroyed your fridge.
1003  Congratulations.
1004 \begin_inset ERT
1005 status collapsed
1006
1007 \begin_layout Plain Layout
1008
1009 "
1010 \end_layout
1011
1012 \end_inset
1013
1014 )
1015 \end_layout
1016
1017 \begin_layout Standard
1018 \begin_inset Flex PushButton
1019 status open
1020
1021 \begin_layout Plain Layout
1022 \begin_inset Argument 1
1023 status open
1024
1025 \begin_layout Plain Layout
1026 onclick={app.alert(
1027 \begin_inset ERT
1028 status collapsed
1029
1030 \begin_layout Plain Layout
1031
1032 "
1033 \end_layout
1034
1035 \end_inset
1036
1037 What the hell? Now you destroyed your fridge.
1038  Congratulations.
1039 \begin_inset ERT
1040 status collapsed
1041
1042 \begin_layout Plain Layout
1043
1044 "
1045 \end_layout
1046
1047 \end_inset
1048
1049 )}
1050 \end_layout
1051
1052 \end_inset
1053
1054 Don't click on this button or your fridge will be destroyed!!!
1055 \end_layout
1056
1057 \end_inset
1058
1059
1060 \end_layout
1061
1062 \begin_layout Standard
1063 \begin_inset Note Greyedout
1064 status open
1065
1066 \begin_layout Plain Layout
1067
1068 \series bold
1069 Note:
1070 \series default
1071  All quote characters in form parameters must be inserted as \SpecialChar TeX
1072  code!
1073 \end_layout
1074
1075 \end_inset
1076
1077
1078 \end_layout
1079
1080 \begin_layout Standard
1081 A common usage for pus buttons is to open a weblink.
1082  Such a button is created by inserting a hyperlink into the button inset.
1083  Here is an example:
1084 \end_layout
1085
1086 \begin_layout Standard
1087 \begin_inset Flex PushButton
1088 status open
1089
1090 \begin_layout Plain Layout
1091 \begin_inset Argument 1
1092 status open
1093
1094 \begin_layout Plain Layout
1095
1096 \end_layout
1097
1098 \end_inset
1099
1100
1101 \begin_inset CommandInset href
1102 LatexCommand href
1103 name "Information how to fill out this form"
1104 target "http://wiki.lyx.org"
1105
1106 \end_inset
1107
1108
1109 \end_layout
1110
1111 \end_inset
1112
1113
1114 \end_layout
1115
1116 \begin_layout Standard
1117 To get rid of the frame for weblinks add this to the additional options
1118  in the document settings under 
1119 \family sans
1120 PDF
1121 \begin_inset space ~
1122 \end_inset
1123
1124 properties
1125 \family default
1126 :
1127 \end_layout
1128
1129 \begin_layout Standard
1130
1131 \series bold
1132 urlbordercolor={1 0 0}
1133 \end_layout
1134
1135 \begin_layout Standard
1136 if your push button border color is red (the default), otherwise use the
1137  same color definition as for your push button border color.
1138 \end_layout
1139
1140 \begin_layout Subsection
1141 Submit button
1142 \begin_inset CommandInset label
1143 LatexCommand label
1144 name "subsec:Submit-button"
1145
1146 \end_inset
1147
1148
1149 \end_layout
1150
1151 \begin_layout Standard
1152 A submit button is used to submit the form data to a server.
1153  It is added by inserting the custom inset 
1154 \family sans
1155 SubmitButton
1156 \family default
1157 .
1158  Write inside the inset the label for the button.
1159  Here is an example:
1160 \end_layout
1161
1162 \begin_layout Standard
1163 \begin_inset Flex SubmitButton
1164 status open
1165
1166 \begin_layout Plain Layout
1167 \begin_inset Argument 1
1168 status open
1169
1170 \begin_layout Plain Layout
1171 name=submit1
1172 \end_layout
1173
1174 \end_inset
1175
1176 Send your data via email
1177 \end_layout
1178
1179 \end_inset
1180
1181
1182 \end_layout
1183
1184 \begin_layout Standard
1185 The submit button creates a forms data format (FDF) file (file extension
1186  *.fdf) which is then submitted.
1187  The FDF file contains only the form data.
1188  They can only be applied to a PDF form if all fields in the form have a
1189  name.
1190 \end_layout
1191
1192 \begin_layout Standard
1193 \begin_inset Note Greyedout
1194 status open
1195
1196 \begin_layout Plain Layout
1197
1198 \series bold
1199 Note:
1200 \series default
1201  You can only use a submit button if you specified the submit method and
1202  target in the PDF form environment options! See sec.
1203 \begin_inset space \thinspace{}
1204 \end_inset
1205
1206
1207 \begin_inset CommandInset ref
1208 LatexCommand ref
1209 reference "sec:Preparation"
1210
1211 \end_inset
1212
1213  for the description.
1214  If there are no specifications you will get \SpecialChar LaTeX
1215  errors!
1216 \end_layout
1217
1218 \end_inset
1219
1220
1221 \end_layout
1222
1223 \begin_layout Standard
1224 \begin_inset Note Greyedout
1225 status open
1226
1227 \begin_layout Plain Layout
1228
1229 \series bold
1230 Note:
1231 \series default
1232  If you have more than one submit button in your document you must specify
1233  a name for each of them to avoid \SpecialChar LaTeX
1234  errors! For example add 
1235 \series bold
1236 name=submit1
1237 \series default
1238  (where 
1239 \series bold
1240 submit1
1241 \series default
1242  is the button name).
1243 \end_layout
1244
1245 \end_inset
1246
1247
1248 \end_layout
1249
1250 \begin_layout Subsection
1251 Reset button
1252 \end_layout
1253
1254 \begin_layout Standard
1255 A reset button is used to reset all form fields to the initial state.
1256  It is added by inserting the custom inset 
1257 \family sans
1258 ResetButton
1259 \family default
1260 .
1261  Write inside the inset the label for the button.
1262  Here is an example:
1263 \end_layout
1264
1265 \begin_layout Standard
1266 \begin_inset Flex ResetButton
1267 status open
1268
1269 \begin_layout Plain Layout
1270 \begin_inset Argument 1
1271 status open
1272
1273 \begin_layout Plain Layout
1274 name=reset1
1275 \end_layout
1276
1277 \end_inset
1278
1279 Reset the form
1280 \end_layout
1281
1282 \end_inset
1283
1284
1285 \end_layout
1286
1287 \begin_layout Standard
1288 \begin_inset Note Greyedout
1289 status open
1290
1291 \begin_layout Plain Layout
1292
1293 \series bold
1294 Note:
1295 \series default
1296  If you have more than one reset button in your document you must specify
1297  a name for each of them to avoid \SpecialChar LaTeX
1298  errors! For example add 
1299 \series bold
1300 name=reset1
1301 \series default
1302  (where 
1303 \series bold
1304 reset1
1305 \series default
1306  is the button name).
1307 \end_layout
1308
1309 \end_inset
1310
1311
1312 \end_layout
1313
1314 \begin_layout Section
1315 Form field customization
1316 \begin_inset CommandInset label
1317 LatexCommand label
1318 name "sec:Form-field-customization"
1319
1320 \end_inset
1321
1322
1323 \end_layout
1324
1325 \begin_layout Standard
1326 Since all form elements should look uniform, one can determine their layout
1327  using the following styles:
1328 \end_layout
1329
1330 \begin_layout Description
1331 Text
1332 \begin_inset space ~
1333 \end_inset
1334
1335 Field
1336 \begin_inset space ~
1337 \end_inset
1338
1339 Style
1340 \end_layout
1341
1342 \begin_layout Description
1343 Check
1344 \begin_inset space ~
1345 \end_inset
1346
1347 Box
1348 \begin_inset space ~
1349 \end_inset
1350
1351 Style 
1352 \end_layout
1353
1354 \begin_layout Description
1355 List
1356 \begin_inset space ~
1357 \end_inset
1358
1359 Box
1360 \begin_inset space ~
1361 \end_inset
1362
1363 Style affects all choice menu types
1364 \end_layout
1365
1366 \begin_layout Description
1367 Combo
1368 \begin_inset space ~
1369 \end_inset
1370
1371 Box
1372 \begin_inset space ~
1373 \end_inset
1374
1375 Style affects only the combo box style
1376 \end_layout
1377
1378 \begin_layout Description
1379 Popdown
1380 \begin_inset space ~
1381 \end_inset
1382
1383 Box
1384 \begin_inset space ~
1385 \end_inset
1386
1387 Style affects only the popdown box style
1388 \end_layout
1389
1390 \begin_layout Description
1391 Radio
1392 \begin_inset space ~
1393 \end_inset
1394
1395 Box
1396 \begin_inset space ~
1397 \end_inset
1398
1399 Style affects only the radio box style
1400 \end_layout
1401
1402 \begin_layout Description
1403 Push
1404 \begin_inset space ~
1405 \end_inset
1406
1407 Button
1408 \begin_inset space ~
1409 \end_inset
1410
1411 Style
1412 \end_layout
1413
1414 \begin_layout Description
1415 Submit
1416 \begin_inset space ~
1417 \end_inset
1418
1419 Button
1420 \begin_inset space ~
1421 \end_inset
1422
1423 Style
1424 \end_layout
1425
1426 \begin_layout Description
1427 Reset
1428 \begin_inset space ~
1429 \end_inset
1430
1431 Button
1432 \begin_inset space ~
1433 \end_inset
1434
1435 Style
1436 \end_layout
1437
1438 \begin_layout Text Field Style
1439
1440 \end_layout
1441
1442 \begin_layout Standard
1443 The content of the styles is a comma-separated list of parameters.
1444  The possible parameters are listed in sec.
1445 \begin_inset space \thinspace{}
1446 \end_inset
1447
1448 6.2 
1449 \begin_inset Quotes eld
1450 \end_inset
1451
1452 Forms optional parameters
1453 \begin_inset Quotes erd
1454 \end_inset
1455
1456  of the documentation of the \SpecialChar LaTeX
1457  package 
1458 \series bold
1459 hyperref
1460 \series default
1461
1462 \begin_inset CommandInset citation
1463 LatexCommand cite
1464 key "hyperref"
1465
1466 \end_inset
1467
1468 .
1469  It is important that the parameter print is always part of the definition,
1470  otherwise the fields won't appear in the PDF output.
1471  The defined style is applied to all fields following the definition.
1472 \end_layout
1473
1474 \begin_layout Subsubsection*
1475 Here are some examples:
1476 \end_layout
1477
1478 \begin_layout Text Field Style
1479 print, bordercolor=red, borderstyle=U, backgroundcolor=lightgray, color=lime,
1480  maxlen=10, align=2, charsize=16pt
1481 \end_layout
1482
1483 \begin_layout Check Box Style
1484 print, borderstyle=S, checkboxsymbol=
1485 \backslash
1486 ding{55}
1487 \end_layout
1488
1489 \begin_layout Combo Box Style
1490 print, bordercolor={0.33 0.66 0.33}, borderstyle=D
1491 \end_layout
1492
1493 \begin_layout Popdown Box Style
1494 print, menulength=2
1495 \end_layout
1496
1497 \begin_layout Radio Box Style
1498 print, borderstyle=I, radiosymbol=6
1499 \end_layout
1500
1501 \begin_layout Push Button Style
1502 print, borderstyle=B, bordercolor=lime
1503 \end_layout
1504
1505 \begin_layout Submit Button Style
1506 print, borderwidth=0, bordercolor=white
1507 \end_layout
1508
1509 \begin_layout Reset Button Style
1510 print, bordercolor=lime
1511 \end_layout
1512
1513 \begin_layout Itemize
1514 Text field with gray background, lime text color, a red border only below
1515  the field, right alignment, 16
1516 \begin_inset space \thinspace{}
1517 \end_inset
1518
1519 pt font size and a limitation for maximal 10
1520 \begin_inset space ~
1521 \end_inset
1522
1523 characters to insert:
1524 \begin_inset VSpace defskip
1525 \end_inset
1526
1527
1528 \begin_inset Newline newline
1529 \end_inset
1530
1531
1532 \begin_inset Flex TextField
1533 status open
1534
1535 \begin_layout Plain Layout
1536 \begin_inset Argument 1
1537 status open
1538
1539 \begin_layout Plain Layout
1540
1541 \end_layout
1542
1543 \end_inset
1544
1545 Enter your name here:
1546 \end_layout
1547
1548 \end_inset
1549
1550
1551 \end_layout
1552
1553 \begin_layout Standard
1554 The 
1555 \series bold
1556 borderstyle
1557 \series default
1558  can be 
1559 \series bold
1560 U
1561 \series default
1562  (underlined), 
1563 \series bold
1564 S
1565 \series default
1566  (solid), 
1567 \series bold
1568 D
1569 \series default
1570  (dashed), 
1571 \series bold
1572 B
1573 \series default
1574  (bevel), or 
1575 \series bold
1576 I
1577 \series default
1578  (inverted bevel).
1579 \end_layout
1580
1581 \begin_layout Standard
1582 \begin_inset Note Greyedout
1583 status open
1584
1585 \begin_layout Plain Layout
1586
1587 \series bold
1588 Note
1589 \series default
1590  that the 
1591 \series bold
1592 value
1593 \series default
1594  has only an effect for text fields if a 
1595 \series bold
1596 name
1597 \series default
1598  was specified.
1599 \end_layout
1600
1601 \end_inset
1602
1603
1604 \end_layout
1605
1606 \begin_layout Itemize
1607 Check box with normal border and symbol 
1608 \backslash
1609 ding{55}:
1610 \begin_inset VSpace defskip
1611 \end_inset
1612
1613
1614 \begin_inset Newline newline
1615 \end_inset
1616
1617
1618 \begin_inset Flex CheckBox
1619 status open
1620
1621 \begin_layout Plain Layout
1622 \begin_inset Argument 1
1623 status open
1624
1625 \begin_layout Plain Layout
1626
1627 \end_layout
1628
1629 \end_inset
1630
1631 Are you older than 18 years?
1632 \end_layout
1633
1634 \end_inset
1635
1636
1637 \end_layout
1638
1639 \begin_layout Standard
1640 The symbol is either specified as number or with the command
1641 \begin_inset Newline newline
1642 \end_inset
1643
1644
1645 \series bold
1646
1647 \backslash
1648 ding{number}
1649 \series default
1650
1651 \begin_inset Newline newline
1652 \end_inset
1653
1654 where 
1655 \series bold
1656 number
1657 \series default
1658  is one of the possible numbers listed in Table
1659 \begin_inset space ~
1660 \end_inset
1661
1662 2 of 
1663 \begin_inset CommandInset citation
1664 LatexCommand cite
1665 key "pifont"
1666
1667 \end_inset
1668
1669 .
1670 \end_layout
1671
1672 \begin_layout Itemize
1673 Combo box with dashed, colored border:
1674 \begin_inset VSpace defskip
1675 \end_inset
1676
1677
1678 \begin_inset Newline newline
1679 \end_inset
1680
1681
1682 \begin_inset Flex ChoiceMenu
1683 status open
1684
1685 \begin_layout Plain Layout
1686 \begin_inset Argument 1
1687 status open
1688
1689 \begin_layout Plain Layout
1690 combo, name=combo2, default=Az
1691 \end_layout
1692
1693 \end_inset
1694
1695 Albania=Al, Armenia=Ar, Azerbaidschan=Az
1696 \begin_inset Argument 2
1697 status open
1698
1699 \begin_layout Plain Layout
1700 Country:
1701 \end_layout
1702
1703 \end_inset
1704
1705
1706 \end_layout
1707
1708 \end_inset
1709
1710
1711 \end_layout
1712
1713 \begin_layout Itemize
1714 Popdown box where only 2
1715 \begin_inset space ~
1716 \end_inset
1717
1718 entries are shown and where the last entry is preselected:
1719 \begin_inset VSpace defskip
1720 \end_inset
1721
1722
1723 \begin_inset Newline newline
1724 \end_inset
1725
1726
1727 \begin_inset Flex ChoiceMenu
1728 status open
1729
1730 \begin_layout Plain Layout
1731 \begin_inset Argument 1
1732 status open
1733
1734 \begin_layout Plain Layout
1735 popdown, name=country2, value=Az
1736 \end_layout
1737
1738 \end_inset
1739
1740 Albania=Al, Armenia=Ar, Azerbaidschan=Az
1741 \begin_inset Argument 2
1742 status open
1743
1744 \begin_layout Plain Layout
1745 Country:
1746 \end_layout
1747
1748 \end_inset
1749
1750
1751 \end_layout
1752
1753 \end_inset
1754
1755
1756 \end_layout
1757
1758 \begin_layout Standard
1759 \begin_inset VSpace defskip
1760 \end_inset
1761
1762
1763 \begin_inset Note Greyedout
1764 status open
1765
1766 \begin_layout Plain Layout
1767
1768 \series bold
1769 Note
1770 \series default
1771  that the 
1772 \series bold
1773 borderstyle B
1774 \series default
1775  and 
1776 \series bold
1777 I
1778 \series default
1779  and also 
1780 \series bold
1781 color
1782 \series default
1783  has no effect for popdown boxes.
1784 \end_layout
1785
1786 \end_inset
1787
1788
1789 \end_layout
1790
1791 \begin_layout Itemize
1792 Radio box with inverted bevel border and symbol number
1793 \begin_inset space ~
1794 \end_inset
1795
1796 6 as checkmark:
1797 \begin_inset VSpace defskip
1798 \end_inset
1799
1800
1801 \begin_inset Newline newline
1802 \end_inset
1803
1804
1805 \begin_inset Flex ChoiceMenu
1806 status open
1807
1808 \begin_layout Plain Layout
1809 \begin_inset Argument 1
1810 status open
1811
1812 \begin_layout Plain Layout
1813 radio, name=radio2
1814 \end_layout
1815
1816 \end_inset
1817
1818 male=m, female=f
1819 \begin_inset Argument 2
1820 status open
1821
1822 \begin_layout Plain Layout
1823 Sex:
1824 \end_layout
1825
1826 \end_inset
1827
1828
1829 \end_layout
1830
1831 \end_inset
1832
1833
1834 \end_layout
1835
1836 \begin_layout Itemize
1837 Push button with a bevel border and colored text:
1838 \begin_inset VSpace defskip
1839 \end_inset
1840
1841
1842 \begin_inset Newline newline
1843 \end_inset
1844
1845
1846 \begin_inset Flex PushButton
1847 status open
1848
1849 \begin_layout Plain Layout
1850 \begin_inset Argument 1
1851 status open
1852
1853 \begin_layout Plain Layout
1854 onclick={app.alert(
1855 \begin_inset ERT
1856 status collapsed
1857
1858 \begin_layout Plain Layout
1859
1860 "
1861 \end_layout
1862
1863 \end_inset
1864
1865 Why do you click this?
1866 \begin_inset ERT
1867 status collapsed
1868
1869 \begin_layout Plain Layout
1870
1871 "
1872 \end_layout
1873
1874 \end_inset
1875
1876 )}
1877 \end_layout
1878
1879 \end_inset
1880
1881
1882 \begin_inset Box Frameless
1883 position "t"
1884 hor_pos "c"
1885 has_inner_box 1
1886 inner_pos "t"
1887 use_parbox 0
1888 use_makebox 1
1889 width ""
1890 special "none"
1891 height "1in"
1892 height_special "totalheight"
1893 thickness "0.4pt"
1894 separation "3pt"
1895 shadowsize "4pt"
1896 framecolor "black"
1897 backgroundcolor "lime"
1898 status open
1899
1900 \begin_layout Plain Layout
1901
1902 \color red
1903 Don't click on this button!!!
1904 \end_layout
1905
1906 \end_inset
1907
1908
1909 \end_layout
1910
1911 \end_inset
1912
1913
1914 \end_layout
1915
1916 \begin_layout Standard
1917 \begin_inset VSpace defskip
1918 \end_inset
1919
1920
1921 \begin_inset Note Greyedout
1922 status open
1923
1924 \begin_layout Plain Layout
1925
1926 \series bold
1927 Note
1928 \series default
1929  that the 
1930 \series bold
1931 backgroundcolor
1932 \series default
1933  and
1934 \series bold
1935  color
1936 \series default
1937  has no effect for push, submit and reset buttons.
1938 \end_layout
1939
1940 \end_inset
1941
1942
1943 \end_layout
1944
1945 \begin_layout Standard
1946 As workaround use a colored box and/or color the box text.
1947 \end_layout
1948
1949 \begin_layout Standard
1950 \begin_inset Note Greyedout
1951 status open
1952
1953 \begin_layout Plain Layout
1954
1955 \series bold
1956 Note
1957 \series default
1958  that the 
1959 \series bold
1960 height 
1961 \series default
1962 and 
1963 \series bold
1964 width
1965 \series default
1966  has no effect for push, submit and reset buttons.
1967 \end_layout
1968
1969 \end_inset
1970
1971
1972 \end_layout
1973
1974 \begin_layout Standard
1975 As workaround a box.
1976 \end_layout
1977
1978 \begin_layout Itemize
1979 Submit button without border, with cyan background color and increased height:
1980 \begin_inset VSpace defskip
1981 \end_inset
1982
1983
1984 \begin_inset Newline newline
1985 \end_inset
1986
1987
1988 \begin_inset Flex SubmitButton
1989 status open
1990
1991 \begin_layout Plain Layout
1992 \begin_inset Argument 1
1993 status open
1994
1995 \begin_layout Plain Layout
1996 name=submit2
1997 \end_layout
1998
1999 \end_inset
2000
2001
2002 \begin_inset Box Frameless
2003 position "c"
2004 hor_pos "c"
2005 has_inner_box 1
2006 inner_pos "c"
2007 use_parbox 1
2008 use_makebox 0
2009 width "5cm"
2010 special "none"
2011 height "4in"
2012 height_special "totalheight"
2013 thickness "0.4pt"
2014 separation "3pt"
2015 shadowsize "4pt"
2016 framecolor "black"
2017 backgroundcolor "cyan"
2018 status open
2019
2020 \begin_layout Plain Layout
2021 Send your data via mail
2022 \end_layout
2023
2024 \end_inset
2025
2026
2027 \end_layout
2028
2029 \end_inset
2030
2031
2032 \begin_inset VSpace bigskip
2033 \end_inset
2034
2035
2036 \end_layout
2037
2038 \begin_layout Itemize
2039 Reset button with a width of 7
2040 \begin_inset space \thinspace{}
2041 \end_inset
2042
2043 cm:
2044 \begin_inset VSpace defskip
2045 \end_inset
2046
2047
2048 \begin_inset Newline newline
2049 \end_inset
2050
2051
2052 \begin_inset Flex ResetButton
2053 status open
2054
2055 \begin_layout Plain Layout
2056 \begin_inset Argument 1
2057 status open
2058
2059 \begin_layout Plain Layout
2060 name=reset2
2061 \end_layout
2062
2063 \end_inset
2064
2065
2066 \begin_inset Box Frameless
2067 position "t"
2068 hor_pos "c"
2069 has_inner_box 1
2070 inner_pos "t"
2071 use_parbox 0
2072 use_makebox 1
2073 width "7cm"
2074 special "none"
2075 height "1in"
2076 height_special "totalheight"
2077 thickness "0.4pt"
2078 separation "3pt"
2079 shadowsize "4pt"
2080 framecolor "black"
2081 backgroundcolor "none"
2082 status open
2083
2084 \begin_layout Plain Layout
2085 Reset the form
2086 \end_layout
2087
2088 \end_inset
2089
2090
2091 \end_layout
2092
2093 \end_inset
2094
2095
2096 \end_layout
2097
2098 \begin_layout Section
2099 PDF viewer action buttons
2100 \end_layout
2101
2102 \begin_layout Standard
2103 One often needs basic actions to be done by the PDF viewer program.
2104  For example to print the form.
2105  Such PDF program-specific actions can be triggered by adding inserting
2106  the custom inset 
2107 \family sans
2108 PDFAction
2109 \family default
2110 .
2111  The PDF viewer programs 
2112 \emph on
2113 Acrobat
2114 \emph default
2115  and 
2116 \emph on
2117 Adobe Reader
2118 \emph default
2119  can handle all possible actions while other PDF viewers might only support
2120  some of them.
2121  However, all PDF viewer programs support the basic things like printing,
2122  save
2123 \begin_inset space ~
2124 \end_inset
2125
2126 as, view in fullscreen etc..
2127 \end_layout
2128
2129 \begin_layout Standard
2130 To specify the action insert its name to the 
2131 \family sans
2132 Action
2133 \family default
2134  inset.
2135  A list with possible actions can be found in sec.
2136 \begin_inset space \thinspace{}
2137 \end_inset
2138
2139
2140 \begin_inset Quotes eld
2141 \end_inset
2142
2143 Acrobat-specific behavior
2144 \begin_inset Quotes erd
2145 \end_inset
2146
2147  of the documentation of the \SpecialChar LaTeX
2148  package 
2149 \series bold
2150 hyperref
2151 \series default
2152
2153 \begin_inset CommandInset citation
2154 LatexCommand cite
2155 key "hyperref"
2156
2157 \end_inset
2158
2159 .
2160 \end_layout
2161
2162 \begin_layout Standard
2163 Here are some examples:
2164 \end_layout
2165
2166 \begin_layout Description
2167 Printing: 
2168 \begin_inset Flex PDFAction
2169 status open
2170
2171 \begin_layout Plain Layout
2172 \begin_inset Argument 1
2173 status open
2174
2175 \begin_layout Plain Layout
2176 Print
2177 \end_layout
2178
2179 \end_inset
2180
2181 Print the document
2182 \end_layout
2183
2184 \end_inset
2185
2186
2187 \end_layout
2188
2189 \begin_layout Description
2190 Save
2191 \begin_inset space ~
2192 \end_inset
2193
2194 as: 
2195 \begin_inset Flex PDFAction
2196 status open
2197
2198 \begin_layout Plain Layout
2199 \begin_inset Argument 1
2200 status open
2201
2202 \begin_layout Plain Layout
2203 SaveAs
2204 \end_layout
2205
2206 \end_inset
2207
2208 Save document as
2209 \end_layout
2210
2211 \end_inset
2212
2213
2214 \end_layout
2215
2216 \begin_layout Description
2217 View
2218 \begin_inset space ~
2219 \end_inset
2220
2221 in
2222 \begin_inset space ~
2223 \end_inset
2224
2225 fullscreen: 
2226 \begin_inset Flex PDFAction
2227 status open
2228
2229 \begin_layout Plain Layout
2230 \begin_inset Argument 1
2231 status open
2232
2233 \begin_layout Plain Layout
2234 FullScreen
2235 \end_layout
2236
2237 \end_inset
2238
2239 View the form in fullscreen
2240 \end_layout
2241
2242 \end_inset
2243
2244
2245 \end_layout
2246
2247 \begin_layout Subsection
2248 Action button customization
2249 \begin_inset CommandInset label
2250 LatexCommand label
2251 name "subsec:Action-button-customization"
2252
2253 \end_inset
2254
2255
2256 \end_layout
2257
2258 \begin_layout Standard
2259 Customizing the action buttons requires the usage of boxes because things
2260  like the width, height and border separation cannot be specified as button
2261  parameters.
2262 \end_layout
2263
2264 \begin_layout Standard
2265 The easiest way to customize the buttons is to fill it with a custom box.
2266  For example the button should be 4
2267 \begin_inset space \thinspace{}
2268 \end_inset
2269
2270 cm wide and have the height of 2 lines.
2271  Then create this parbox:
2272 \end_layout
2273
2274 \begin_layout Standard
2275 \begin_inset Box Frameless
2276 position "c"
2277 hor_pos "c"
2278 has_inner_box 1
2279 inner_pos "c"
2280 use_parbox 1
2281 use_makebox 0
2282 width "4cm"
2283 special "none"
2284 height "2in"
2285 height_special "totalheight"
2286 thickness "0.4pt"
2287 separation "3pt"
2288 shadowsize "4pt"
2289 framecolor "black"
2290 backgroundcolor "none"
2291 status open
2292
2293 \begin_layout Plain Layout
2294 \noindent
2295 Save form as
2296 \end_layout
2297
2298 \end_inset
2299
2300
2301 \end_layout
2302
2303 \begin_layout Standard
2304 inside a 
2305 \family sans
2306 PDFAction
2307 \family default
2308  inset.
2309  This is the result:
2310 \end_layout
2311
2312 \begin_layout Standard
2313 \begin_inset Flex PDFAction
2314 status open
2315
2316 \begin_layout Plain Layout
2317 \begin_inset Argument 1
2318 status open
2319
2320 \begin_layout Plain Layout
2321 SaveAs
2322 \end_layout
2323
2324 \end_inset
2325
2326
2327 \begin_inset Box Frameless
2328 position "c"
2329 hor_pos "c"
2330 has_inner_box 1
2331 inner_pos "c"
2332 use_parbox 1
2333 use_makebox 0
2334 width "4cm"
2335 special "none"
2336 height "2in"
2337 height_special "totalheight"
2338 thickness "0.4pt"
2339 separation "3pt"
2340 shadowsize "4pt"
2341 framecolor "black"
2342 backgroundcolor "none"
2343 status open
2344
2345 \begin_layout Plain Layout
2346 Save form as
2347 \end_layout
2348
2349 \end_inset
2350
2351
2352 \end_layout
2353
2354 \end_inset
2355
2356
2357 \end_layout
2358
2359 \begin_layout Standard
2360 To customize the border color, add the command 
2361 \series bold
2362 menubordercolor={r g b}
2363 \series default
2364  to the additional options in the document settings under 
2365 \family sans
2366 PDF
2367 \begin_inset space ~
2368 \end_inset
2369
2370 properties
2371 \family default
2372  and replace 
2373 \series bold
2374 r
2375 \series default
2376
2377 \series bold
2378 g
2379 \series default
2380  and 
2381 \series bold
2382 b
2383 \series default
2384  with a number between 0 and 1 for the colors red, green and blue.
2385  If you want to change the border color only for certain buttons, use the
2386  layout 
2387 \family sans
2388 PDF
2389 \begin_inset space ~
2390 \end_inset
2391
2392 link
2393 \begin_inset space ~
2394 \end_inset
2395
2396 setup
2397 \family default
2398  before the button and insert there the command 
2399 \series bold
2400 menubordercolor
2401 \series default
2402 .
2403  The default value of 
2404 \series bold
2405 menubordercolor
2406 \series default
2407  is 
2408 \series bold
2409 {1 0 0}
2410 \series default
2411 .
2412 \end_layout
2413
2414 \begin_layout PDF Link Setup
2415 menubordercolor={0.1 0.9 0.5}
2416 \end_layout
2417
2418 \begin_layout Standard
2419 An example with 
2420 \series bold
2421 menubordercolor={0.1 0.9 0.5}
2422 \series default
2423 :
2424 \begin_inset Newline newline
2425 \end_inset
2426
2427
2428 \begin_inset Flex PDFAction
2429 status open
2430
2431 \begin_layout Plain Layout
2432 \begin_inset Argument 1
2433 status open
2434
2435 \begin_layout Plain Layout
2436 SaveAs
2437 \end_layout
2438
2439 \end_inset
2440
2441
2442 \begin_inset Box Frameless
2443 position "c"
2444 hor_pos "c"
2445 has_inner_box 1
2446 inner_pos "c"
2447 use_parbox 1
2448 use_makebox 0
2449 width "4cm"
2450 special "none"
2451 height "2in"
2452 height_special "totalheight"
2453 thickness "0.4pt"
2454 separation "3pt"
2455 shadowsize "4pt"
2456 framecolor "black"
2457 backgroundcolor "none"
2458 status open
2459
2460 \begin_layout Plain Layout
2461 \noindent
2462 Save form as
2463 \end_layout
2464
2465 \end_inset
2466
2467
2468 \end_layout
2469
2470 \end_inset
2471
2472
2473 \end_layout
2474
2475 \begin_layout Standard
2476 To change the border width use the command 
2477 \series bold
2478 pdfborder={0 0 w}
2479 \series default
2480  where 
2481 \series bold
2482 w
2483 \series default
2484  is the width in pixels.
2485  The default value of 
2486 \series bold
2487 pdfborder
2488 \series default
2489  is 
2490 \series bold
2491 {0 0 1}
2492 \series default
2493 .
2494 \end_layout
2495
2496 \begin_layout Standard
2497 \begin_inset Note Greyedout
2498 status open
2499
2500 \begin_layout Plain Layout
2501
2502 \series bold
2503 Note:
2504 \series default
2505  
2506 \series bold
2507 pdfborder
2508 \series default
2509  affects all link types, not only the menu links.
2510 \end_layout
2511
2512 \end_inset
2513
2514
2515 \end_layout
2516
2517 \begin_layout PDF Link Setup
2518 pdfborder={0 0 4}, menubordercolor={1 1 0}
2519 \end_layout
2520
2521 \begin_layout Standard
2522 An example with a 4
2523 \begin_inset space ~
2524 \end_inset
2525
2526 pixel thick yellow border:
2527 \begin_inset Newline newline
2528 \end_inset
2529
2530
2531 \begin_inset Flex PDFAction
2532 status open
2533
2534 \begin_layout Plain Layout
2535 \begin_inset Argument 1
2536 status open
2537
2538 \begin_layout Plain Layout
2539 SaveAs
2540 \end_layout
2541
2542 \end_inset
2543
2544
2545 \begin_inset Box Frameless
2546 position "c"
2547 hor_pos "c"
2548 has_inner_box 1
2549 inner_pos "c"
2550 use_parbox 1
2551 use_makebox 0
2552 width "4cm"
2553 special "none"
2554 height "2in"
2555 height_special "totalheight"
2556 thickness "0.4pt"
2557 separation "3pt"
2558 shadowsize "4pt"
2559 framecolor "black"
2560 backgroundcolor "none"
2561 status open
2562
2563 \begin_layout Plain Layout
2564 \noindent
2565 Save form as
2566 \end_layout
2567
2568 \end_inset
2569
2570
2571 \end_layout
2572
2573 \end_inset
2574
2575
2576 \end_layout
2577
2578 \begin_layout Standard
2579 To change the background color use a colored box.
2580 \end_layout
2581
2582 \begin_layout PDF Link Setup
2583 pdfborder={0 0 0}
2584 \end_layout
2585
2586 \begin_layout Standard
2587 An example without a border and with lime background color:
2588 \begin_inset Newline newline
2589 \end_inset
2590
2591
2592 \begin_inset Flex PDFAction
2593 status open
2594
2595 \begin_layout Plain Layout
2596 \begin_inset Argument 1
2597 status open
2598
2599 \begin_layout Plain Layout
2600 SaveAs
2601 \end_layout
2602
2603 \end_inset
2604
2605
2606 \begin_inset Box Frameless
2607 position "c"
2608 hor_pos "c"
2609 has_inner_box 1
2610 inner_pos "c"
2611 use_parbox 1
2612 use_makebox 0
2613 width "4cm"
2614 special "none"
2615 height "2in"
2616 height_special "totalheight"
2617 thickness "0.4pt"
2618 separation "3pt"
2619 shadowsize "4pt"
2620 framecolor "black"
2621 backgroundcolor "lime"
2622 status open
2623
2624 \begin_layout Plain Layout
2625 \noindent
2626 Save form as
2627 \end_layout
2628
2629 \end_inset
2630
2631
2632 \end_layout
2633
2634 \end_inset
2635
2636
2637 \end_layout
2638
2639 \begin_layout PDF Link Setup
2640 pdfborder={0 0 1}, menubordercolor={1 0 0}
2641 \end_layout
2642
2643 \begin_layout Section
2644 Dynamic form fields
2645 \end_layout
2646
2647 \begin_layout Standard
2648 It is also possible to have dynamic form fields.
2649  This means that depending on the actions of the user fields can (dis)appear
2650  or change their appearance.
2651  To use this feature, add these lines to your document preamble:
2652 \end_layout
2653
2654 \begin_layout Standard
2655
2656 \series bold
2657
2658 \backslash
2659 usepackage[pdftex]{insdljs}
2660 \begin_inset Newline newline
2661 \end_inset
2662
2663
2664 \backslash
2665 pdfcatalog{/AA 
2666 \backslash
2667 the
2668 \backslash
2669 pdflastobj
2670 \backslash
2671 space 0 R}
2672 \end_layout
2673
2674 \begin_layout Standard
2675 Then add the necessary JavaScript code to your document \SpecialChar LaTeX
2676  preamble or as
2677  \SpecialChar TeX
2678  code to your document.
2679  For info about JavaScript, see its documentation, 
2680 \begin_inset CommandInset citation
2681 LatexCommand cite
2682 key "JavaScript"
2683
2684 \end_inset
2685
2686 .
2687 \end_layout
2688
2689 \begin_layout Standard
2690 \begin_inset ERT
2691 status collapsed
2692
2693 \begin_layout Plain Layout
2694
2695
2696 \backslash
2697 ifinsdljs
2698 \end_layout
2699
2700 \end_inset
2701
2702
2703 \begin_inset Note Note
2704 status open
2705
2706 \begin_layout Plain Layout
2707 The following section will only be displayed when the \SpecialChar LaTeX
2708  package 
2709 \series bold
2710 insdljs
2711 \series default
2712  is installed.
2713 \end_layout
2714
2715 \end_inset
2716
2717
2718 \end_layout
2719
2720 \begin_layout Standard
2721 For the following choice menu this JavaScript code was used:
2722 \end_layout
2723
2724 \begin_layout Standard
2725 \begin_inset listings
2726 lstparams "language=TeX"
2727 inline false
2728 status open
2729
2730 \begin_layout Plain Layout
2731
2732
2733 \backslash
2734 begin{insDLJS}[exaaae]{exaaae}{JavaScript}
2735 \end_layout
2736
2737 \begin_layout Plain Layout
2738
2739  function validateTime(){
2740 \end_layout
2741
2742 \begin_layout Plain Layout
2743
2744   this.delay = true;
2745 \end_layout
2746
2747 \begin_layout Plain Layout
2748
2749   if((event.value == "u") || (event.value == "unlimited")) {
2750 \end_layout
2751
2752 \begin_layout Plain Layout
2753
2754    this.getField("from").display = display.hidden;
2755 \end_layout
2756
2757 \begin_layout Plain Layout
2758
2759    this.getField("to").display = display.hidden;
2760 \end_layout
2761
2762 \begin_layout Plain Layout
2763
2764   } else {
2765 \end_layout
2766
2767 \begin_layout Plain Layout
2768
2769    this.getField("from").display = display.visible;
2770 \end_layout
2771
2772 \begin_layout Plain Layout
2773
2774    this.getField("to").display = display.visible;
2775 \end_layout
2776
2777 \begin_layout Plain Layout
2778
2779    this.getField("from").setFocus();
2780 \end_layout
2781
2782 \begin_layout Plain Layout
2783
2784   }
2785 \end_layout
2786
2787 \begin_layout Plain Layout
2788
2789   this.delay = false;
2790 \end_layout
2791
2792 \begin_layout Plain Layout
2793
2794  }
2795 \end_layout
2796
2797 \begin_layout Plain Layout
2798
2799
2800 \backslash
2801 end{insDLJS}
2802 \end_layout
2803
2804 \end_inset
2805
2806
2807 \end_layout
2808
2809 \begin_layout Standard
2810 \begin_inset Note Greyedout
2811 status open
2812
2813 \begin_layout Plain Layout
2814
2815 \series bold
2816 Note:
2817 \series default
2818  
2819 \emph on
2820 All
2821 \emph default
2822  JavaScript funtions must be inserted into the same 
2823 \family sans
2824 insDLJS
2825 \family default
2826  environment.
2827 \end_layout
2828
2829 \end_inset
2830
2831
2832 \end_layout
2833
2834 \begin_layout Standard
2835 The 
2836 \family sans
2837 PDF
2838 \begin_inset space ~
2839 \end_inset
2840
2841 form
2842 \begin_inset space ~
2843 \end_inset
2844
2845 parameters
2846 \family default
2847  of the following choice menu are
2848 \begin_inset Newline newline
2849 \end_inset
2850
2851
2852 \series bold
2853 name=contract,radio,default=tl,validate={validateTime();}
2854 \end_layout
2855
2856 \begin_layout Standard
2857 \begin_inset Flex ChoiceMenu
2858 status open
2859
2860 \begin_layout Plain Layout
2861 \begin_inset Argument 1
2862 status open
2863
2864 \begin_layout Plain Layout
2865 name=contract,radio,default=tl,validate={validateTime();}
2866 \end_layout
2867
2868 \end_inset
2869
2870 term-limited=tl, unlimited=u
2871 \begin_inset Argument 2
2872 status open
2873
2874 \begin_layout Plain Layout
2875 Job contract:
2876 \end_layout
2877
2878 \end_inset
2879
2880
2881 \end_layout
2882
2883 \end_inset
2884
2885
2886 \begin_inset VSpace defskip
2887 \end_inset
2888
2889
2890 \end_layout
2891
2892 \begin_layout Standard
2893 \begin_inset Tabular
2894 <lyxtabular version="3" rows="3" columns="2">
2895 <features tabularvalignment="middle">
2896 <column alignment="left" valignment="top">
2897 <column alignment="center" valignment="top">
2898 <row>
2899 <cell alignment="left" valignment="top" usebox="none">
2900 \begin_inset Text
2901
2902 \begin_layout Plain Layout
2903 From:
2904 \end_layout
2905
2906 \end_inset
2907 </cell>
2908 <cell alignment="center" valignment="top" usebox="none">
2909 \begin_inset Text
2910
2911 \begin_layout Plain Layout
2912 \begin_inset Flex TextField
2913 status open
2914
2915 \begin_layout Plain Layout
2916 \begin_inset Argument 1
2917 status open
2918
2919 \begin_layout Plain Layout
2920 name=from,width=10em
2921 \end_layout
2922
2923 \end_inset
2924
2925
2926 \end_layout
2927
2928 \end_inset
2929
2930
2931 \end_layout
2932
2933 \end_inset
2934 </cell>
2935 </row>
2936 <row>
2937 <cell alignment="center" valignment="top" usebox="none">
2938 \begin_inset Text
2939
2940 \begin_layout Plain Layout
2941
2942 \end_layout
2943
2944 \end_inset
2945 </cell>
2946 <cell alignment="center" valignment="top" usebox="none">
2947 \begin_inset Text
2948
2949 \begin_layout Plain Layout
2950 \begin_inset VSpace -1.5mm
2951 \end_inset
2952
2953
2954 \end_layout
2955
2956 \end_inset
2957 </cell>
2958 </row>
2959 <row>
2960 <cell alignment="left" valignment="top" usebox="none">
2961 \begin_inset Text
2962
2963 \begin_layout Plain Layout
2964 To:
2965 \end_layout
2966
2967 \end_inset
2968 </cell>
2969 <cell alignment="center" valignment="top" usebox="none">
2970 \begin_inset Text
2971
2972 \begin_layout Plain Layout
2973 \begin_inset Flex TextField
2974 status open
2975
2976 \begin_layout Plain Layout
2977 \begin_inset Argument 1
2978 status open
2979
2980 \begin_layout Plain Layout
2981 name=to,width=10em
2982 \end_layout
2983
2984 \end_inset
2985
2986
2987 \end_layout
2988
2989 \end_inset
2990
2991
2992 \end_layout
2993
2994 \end_inset
2995 </cell>
2996 </row>
2997 </lyxtabular>
2998
2999 \end_inset
3000
3001
3002 \end_layout
3003
3004 \begin_layout Standard
3005 \begin_inset VSpace bigskip
3006 \end_inset
3007
3008
3009 \end_layout
3010
3011 \begin_layout Standard
3012 To check and assure that the user only enters a number to a text field you
3013  can for example use this JavaScript code:
3014 \end_layout
3015
3016 \begin_layout Standard
3017 \begin_inset listings
3018 lstparams "language=TeX"
3019 inline false
3020 status open
3021
3022 \begin_layout Plain Layout
3023
3024 function checkNumber() {
3025 \end_layout
3026
3027 \begin_layout Plain Layout
3028
3029  event.rc = true;
3030 \end_layout
3031
3032 \begin_layout Plain Layout
3033
3034  if (!Number(event.value)) {
3035 \end_layout
3036
3037 \begin_layout Plain Layout
3038
3039   app.alert("Value must be a number!");
3040 \end_layout
3041
3042 \begin_layout Plain Layout
3043
3044   event.value = "";
3045 \end_layout
3046
3047 \begin_layout Plain Layout
3048
3049  } else {
3050 \end_layout
3051
3052 \begin_layout Plain Layout
3053
3054   event.target.textColor = color.green;
3055 \end_layout
3056
3057 \begin_layout Plain Layout
3058
3059 }
3060 \end_layout
3061
3062 \end_inset
3063
3064
3065 \end_layout
3066
3067 \begin_layout Standard
3068 An example text field: 
3069 \begin_inset Flex TextField
3070 status open
3071
3072 \begin_layout Plain Layout
3073 \begin_inset Argument 1
3074 status open
3075
3076 \begin_layout Plain Layout
3077 name=onlyNumbers, align=1, validate={checkNumber();}
3078 \end_layout
3079
3080 \end_inset
3081
3082
3083 \end_layout
3084
3085 \end_inset
3086
3087
3088 \end_layout
3089
3090 \begin_layout Standard
3091 \begin_inset ERT
3092 status collapsed
3093
3094 \begin_layout Plain Layout
3095
3096
3097 \backslash
3098 else
3099 \end_layout
3100
3101 \end_inset
3102
3103
3104 \begin_inset Note Note
3105 status open
3106
3107 \begin_layout Plain Layout
3108 The following will be displayed when the \SpecialChar LaTeX
3109  package 
3110 \series bold
3111 insdljs
3112 \series default
3113  is not installed:
3114 \end_layout
3115
3116 \end_inset
3117
3118
3119 \end_layout
3120
3121 \begin_layout Standard
3122 You need to install the package 
3123 \series bold
3124 insdljs
3125 \series default
3126  to see the content of this section in the output.
3127 \end_layout
3128
3129 \begin_layout Standard
3130 \begin_inset ERT
3131 status collapsed
3132
3133 \begin_layout Plain Layout
3134
3135
3136 \backslash
3137 fi
3138 \end_layout
3139
3140 \end_inset
3141
3142
3143 \end_layout
3144
3145 \begin_layout End PDF Form
3146 \begin_inset Note Note
3147 status open
3148
3149 \begin_layout Plain Layout
3150 keep this emtpy
3151 \end_layout
3152
3153 \end_inset
3154
3155
3156 \end_layout
3157
3158 \begin_layout Section
3159 General notes and hints
3160 \end_layout
3161
3162 \begin_layout Itemize
3163 Submitting and applying data requires that all form fields have a name.
3164 \end_layout
3165
3166 \begin_layout Itemize
3167 All braces, brackets, backslashes and quote characters in form parameters
3168  must be inserted as \SpecialChar TeX
3169  code!
3170 \end_layout
3171
3172 \begin_layout Itemize
3173 Creating a PDF form requires pdflatex or lualatex.
3174  Use either the \SpecialChar LyX
3175  export formats 
3176 \family sans
3177 PDF (pdflatex)
3178 \family default
3179  or 
3180 \family sans
3181 PDF (Lua\SpecialChar TeX
3182 )
3183 \family default
3184 .
3185 \end_layout
3186
3187 \begin_layout Itemize
3188 To see in 
3189 \emph on
3190 Adobe Reader
3191 \emph default
3192  and 
3193 \emph on
3194 Acrobat
3195 \emph default
3196  custom background colors you must disable in these programs to highlight
3197  the available form fields in the PDF.
3198 \end_layout
3199
3200 \begin_layout Bibliography
3201 \begin_inset CommandInset bibitem
3202 LatexCommand bibitem
3203 key "JavaScript"
3204
3205 \end_inset
3206
3207
3208 \begin_inset CommandInset href
3209 LatexCommand href
3210 name "JavaScript reference"
3211 target "https://developer.mozilla.org/en/docs/Web/JavaScript/Reference"
3212
3213 \end_inset
3214
3215
3216 \end_layout
3217
3218 \begin_layout Bibliography
3219 \begin_inset CommandInset bibitem
3220 LatexCommand bibitem
3221 key "hyperref"
3222
3223 \end_inset
3224
3225
3226 \begin_inset CommandInset href
3227 LatexCommand href
3228 name "Documentation"
3229 target "http://mirrors.ctan.org/macros/latex/contrib/hyperref/doc/manual.pdf"
3230
3231 \end_inset
3232
3233  of the \SpecialChar LaTeX
3234  package 
3235 \series bold
3236 hyperref
3237 \end_layout
3238
3239 \begin_layout Bibliography
3240 \begin_inset CommandInset bibitem
3241 LatexCommand bibitem
3242 key "pifont"
3243
3244 \end_inset
3245
3246
3247 \begin_inset CommandInset href
3248 LatexCommand href
3249 name "Documentation"
3250 target "http://mirrors.ctan.org/macros/latex/required/psnfss/psnfss2e.pdf"
3251
3252 \end_inset
3253
3254  of the \SpecialChar LaTeX
3255  package 
3256 \series bold
3257 pifont
3258 \end_layout
3259
3260 \end_body
3261 \end_document