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