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