@@ -12,68 +12,128 @@ var {
1212} = jsPDF . AcroForm ;
1313
1414doc . setFontSize ( 12 ) ;
15- doc . text ( "ComboBox:" , 10 , 105 ) ;
16-
17- var comboBox = new ComboBox ( ) ;
18- comboBox . fieldName = "ChoiceField1" ;
19- comboBox . topIndex = 1 ;
20- comboBox . Rect = [ 50 , 100 , 30 , 10 ] ;
21- comboBox . setOptions ( [ "a" , "b" , "c" ] ) ;
22- comboBox . value = "b" ;
23- comboBox . defaultValue = "b" ;
24- doc . addField ( comboBox ) ;
25-
26- doc . text ( "ListBox:" , 10 , 115 ) ;
27- var listbox = new ListBox ( ) ;
28- listbox . edit = false ;
29- listbox . fieldName = "ChoiceField2" ;
30- listbox . topIndex = 2 ;
31- listbox . Rect = [ 50 , 110 , 30 , 10 ] ;
32- listbox . setOptions ( [ "c" , "a" , "d" , "f" , "b" , "s" ] ) ;
33- listbox . value = "s" ;
34- doc . addField ( listbox ) ;
35-
36- doc . text ( "CheckBox:" , 10 , 125 ) ;
37- var checkBox = new CheckBox ( ) ;
38- checkBox . fieldName = "CheckBox1" ;
39- checkBox . Rect = [ 50 , 120 , 30 , 10 ] ;
40- doc . addField ( checkBox ) ;
41-
42- doc . text ( "PushButton:" , 10 , 135 ) ;
43- var pushButton = new PushButton ( ) ;
44- pushButton . fieldName = "PushButton1" ;
45- pushButton . Rect = [ 50 , 130 , 30 , 10 ] ;
46- doc . addField ( pushButton ) ;
47-
48- doc . text ( "TextField:" , 10 , 145 ) ;
49- var textField = new TextField ( ) ;
50- textField . Rect = [ 50 , 140 , 30 , 10 ] ;
51- textField . multiline = true ;
52- textField . value =
53- "The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse" ; //
54- textField . fieldName = "TestTextBox" ;
55- doc . addField ( textField ) ;
56-
57- doc . text ( "Password:" , 10 , 155 ) ;
58- var passwordField = new PasswordField ( ) ;
59- passwordField . Rect = [ 50 , 150 , 30 , 10 ] ;
60- doc . addField ( passwordField ) ;
61-
62- doc . text ( "RadioGroup:" , 50 , 165 ) ;
63- var radioGroup = new RadioButton ( ) ;
64- radioGroup . value = "Test" ;
65- radioGroup . Subtype = "Form" ;
66-
67- doc . addField ( radioGroup ) ;
68-
69- var radioButton1 = radioGroup . createOption ( "Test" ) ;
70- radioButton1 . Rect = [ 50 , 170 , 30 , 10 ] ;
71- radioButton1 . AS = "/Test" ;
72-
73- var radioButton2 = radioGroup . createOption ( "Test2" ) ;
74- radioButton2 . Rect = [ 50 , 180 , 30 , 10 ] ;
75-
76- var radioButton3 = radioGroup . createOption ( "Test3" ) ;
77- radioButton3 . Rect = [ 50 , 190 , 20 , 10 ] ;
78-
79- radioGroup . setAppearance ( Appearance . RadioButton . Cross ) ;
15+ var margin = 12 ;
16+ let yPos = 20 ;
17+
18+ addComboBox ( ) ;
19+ addListBox ( ) ;
20+ addCheckBox ( ) ;
21+ addPushButton ( ) ;
22+ addTextField ( ) ;
23+ addPasswordField ( ) ;
24+ addRadioGroups ( ) ;
25+
26+ function addComboBox ( ) {
27+ doc . text ( "ComboBox:" , 10 , yPos ) ;
28+ var comboBox = new ComboBox ( ) ;
29+ comboBox . fieldName = "ComboBox1" ;
30+ comboBox . topIndex = 1 ;
31+ comboBox . Rect = [ 50 , yPos - 5 , 30 , 10 ] ;
32+ comboBox . setOptions ( [ "a" , "b" , "c" ] ) ;
33+ comboBox . value = "b" ;
34+ comboBox . defaultValue = "b" ;
35+ doc . addField ( comboBox ) ;
36+ yPos += margin ;
37+ }
38+
39+ function addListBox ( ) {
40+ doc . text ( "ListBox:" , 10 , yPos ) ;
41+ var listbox = new ListBox ( ) ;
42+ listbox . edit = false ;
43+ listbox . fieldName = "ListBox1" ;
44+ listbox . topIndex = 2 ;
45+ listbox . Rect = [ 50 , yPos - 5 , 30 , 10 ] ;
46+ listbox . setOptions ( [ "c" , "a" , "d" , "f" , "b" , "s" ] ) ;
47+ listbox . value = "s" ;
48+ doc . addField ( listbox ) ;
49+ yPos += margin ;
50+ }
51+
52+ function addCheckBox ( ) {
53+ doc . text ( "CheckBox:" , 10 , yPos ) ;
54+ var checkBox = new CheckBox ( ) ;
55+ checkBox . fieldName = "CheckBox1" ;
56+ checkBox . Rect = [ 50 , yPos - 5 , 30 , 10 ] ;
57+ doc . addField ( checkBox ) ;
58+ yPos += margin ;
59+ }
60+
61+ function addPushButton ( ) {
62+ doc . text ( "PushButton:" , 10 , yPos ) ;
63+ var pushButton = new PushButton ( ) ;
64+ pushButton . fieldName = "PushButton1" ;
65+ pushButton . Rect = [ 50 , yPos - 5 , 30 , 10 ] ;
66+ pushButton . caption = "OK" ;
67+ doc . addField ( pushButton ) ;
68+ yPos += margin ;
69+ }
70+
71+ function addTextField ( ) {
72+ doc . text ( "TextField:" , 10 , yPos ) ;
73+ var textField = new TextField ( ) ;
74+ textField . Rect = [ 50 , yPos - 5 , 40 , 10 ] ;
75+ textField . multiline = true ;
76+ textField . value =
77+ "The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse" ;
78+ textField . fieldName = "TestTextBox" ;
79+ doc . addField ( textField ) ;
80+ yPos += margin ;
81+ }
82+
83+ function addPasswordField ( ) {
84+ doc . text ( "Password:" , 10 , yPos ) ;
85+ var passwordField = new PasswordField ( ) ;
86+ passwordField . Rect = [ 50 , yPos - 5 , 40 , 10 ] ;
87+ doc . addField ( passwordField ) ;
88+ yPos += margin ;
89+ }
90+
91+ function addRadioGroups ( ) {
92+ var boxDim = 10 ;
93+ doc . text ( "RadioGroups:" , 10 , yPos ) ;
94+
95+ // First radio group
96+ var radioGroup = new RadioButton ( ) ;
97+ radioGroup . fieldName = "RadioGroup1" ;
98+ doc . addField ( radioGroup ) ;
99+ yPos -= 5 ;
100+
101+ var radioButton1 = radioGroup . createOption ( "RadioGroup1Option1" ) ;
102+ radioButton1 . Rect = [ 50 , yPos , boxDim , boxDim ] ;
103+
104+ var radioButton2 = radioGroup . createOption ( "RadioGroup1Option2" ) ;
105+ radioButton2 . Rect = [ 62 , yPos , boxDim , boxDim ] ;
106+
107+ var radioButton3 = radioGroup . createOption ( "RadioGroup1Option3" ) ;
108+ radioButton3 . Rect = [ 74 , yPos , boxDim , boxDim ] ;
109+ radioGroup . setAppearance ( Appearance . RadioButton . Cross ) ;
110+ yPos += boxDim + 5 ;
111+
112+ // Second radio group
113+ var radioGroup2 = new RadioButton ( "RadioGroup2" ) ;
114+ radioGroup2 . value = "RadioGroup2Option3" ;
115+ radioGroup2 . fieldName = "RadioGroup2" ;
116+
117+ // Will apply to all radio buttons in the group, unless overridden
118+ radioGroup2 . borderColor = [ 0.4 , 0.4 , 0.4 ] ; // gray
119+ radioGroup2 . borderWidth = 2 ;
120+ doc . addField ( radioGroup2 ) ;
121+
122+ var radioButton21 = radioGroup2 . createOption ( "RadioGroup2Option1" ) ;
123+ radioButton21 . Rect = [ 50 , yPos , boxDim , boxDim ] ;
124+
125+ // override the radioGroup's border settings for this one radio button
126+ radioButton21 . borderColor = [ 0 , 1 , 0 ] ; // green
127+ radioButton21 . backgroundColor = [ 1 , 0 , 0 ] ; // red
128+ radioButton21 . borderWidth = 3 ;
129+ radioButton21 . borderStyle = "dashed" ;
130+
131+ var radioButton22 = radioGroup2 . createOption ( "RadioGroup2Option2" ) ;
132+ radioButton22 . Rect = [ 62 , yPos , boxDim , boxDim ] ;
133+
134+ var radioButton23 = radioGroup2 . createOption ( "RadioGroup2Option3" ) ;
135+ radioButton23 . Rect = [ 74 , yPos , boxDim , boxDim ] ;
136+ radioButton23 . AS = "/RadioGroup2Option3" ;
137+
138+ radioGroup2 . setAppearance ( Appearance . RadioButton . Circle ) ;
139+ }
0 commit comments