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