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