|
8 | 8 | TextField,
|
9 | 9 | PasswordField,
|
10 | 10 | RadioButton,
|
11 |
| - Appearance |
| 11 | + Appearance, |
| 12 | + TextFieldGroup |
12 | 13 | } = jsPDF.AcroForm;
|
13 | 14 |
|
14 | 15 | doc.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); |
| 16 | +var margin = 12; |
| 17 | +let yPos = 20; |
| 18 | + |
| 19 | +addComboBox(); |
| 20 | +addListBox(); |
| 21 | +addCheckBox(); |
| 22 | +addPushButton(); |
| 23 | +addTextField(); |
| 24 | +addPasswordField(); |
| 25 | +addRadioGroups(); |
| 26 | +addTextFieldGroup(); |
| 27 | + |
| 28 | +function addComboBox() { |
| 29 | + doc.text("ComboBox:", 10, yPos); |
| 30 | + var comboBox = new ComboBox(); |
| 31 | + comboBox.fieldName = "ComboBox1"; |
| 32 | + comboBox.topIndex = 1; |
| 33 | + comboBox.Rect = [50, yPos - 5, 30, 10]; |
| 34 | + comboBox.setOptions(["a", "b", "c"]); |
| 35 | + comboBox.value = "b"; |
| 36 | + comboBox.defaultValue = "b"; |
| 37 | + doc.addField(comboBox); |
| 38 | + yPos += margin; |
| 39 | +} |
| 40 | + |
| 41 | +function addListBox() { |
| 42 | + doc.text("ListBox:", 10, yPos); |
| 43 | + var listbox = new ListBox(); |
| 44 | + listbox.edit = false; |
| 45 | + listbox.fieldName = "ListBox1"; |
| 46 | + listbox.topIndex = 2; |
| 47 | + listbox.Rect = [50, yPos - 5, 30, 10]; |
| 48 | + listbox.setOptions(["c", "a", "d", "f", "b", "s"]); |
| 49 | + listbox.value = "s"; |
| 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 | + doc.addField(checkBox); |
| 60 | + yPos += margin; |
| 61 | +} |
| 62 | + |
| 63 | +function addPushButton() { |
| 64 | + doc.text("PushButton:", 10, yPos); |
| 65 | + var pushButton = new PushButton(); |
| 66 | + pushButton.fieldName = "PushButton1"; |
| 67 | + pushButton.Rect = [50, yPos - 5, 30, 10]; |
| 68 | + doc.addField(pushButton); |
| 69 | + yPos += margin; |
| 70 | +} |
| 71 | + |
| 72 | +function addTextField() { |
| 73 | + doc.text("TextField:", 10, yPos); |
| 74 | + var textField = new TextField(); |
| 75 | + textField.Rect = [50, yPos - 5, 40, 10]; |
| 76 | + textField.multiline = true; |
| 77 | + textField.value = |
| 78 | + "The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse"; |
| 79 | + textField.fieldName = "TestTextBox"; |
| 80 | + doc.addField(textField); |
| 81 | + yPos += margin; |
| 82 | +} |
| 83 | + |
| 84 | +function addPasswordField() { |
| 85 | + doc.text("Password:", 10, yPos); |
| 86 | + var passwordField = new PasswordField(); |
| 87 | + passwordField.Rect = [50, yPos - 5, 40, 10]; |
| 88 | + doc.addField(passwordField); |
| 89 | + yPos += margin; |
| 90 | +} |
| 91 | + |
| 92 | +function addRadioGroups() { |
| 93 | + var boxDim = 10; |
| 94 | + doc.text("RadioGroups:", 10, yPos); |
| 95 | + |
| 96 | + // First radio group |
| 97 | + var radioGroup = new RadioButton(); |
| 98 | + radioGroup.value = "RadioGroup1Option3"; |
| 99 | + radioGroup.fieldName = "RadioGroup1"; |
| 100 | + doc.addField(radioGroup); |
| 101 | + yPos -= 5; |
| 102 | + |
| 103 | + var radioButton1 = radioGroup.createOption("RadioGroup1Option1"); |
| 104 | + radioButton1.Rect = [50, yPos, boxDim, boxDim]; |
| 105 | + |
| 106 | + var radioButton2 = radioGroup.createOption("RadioGroup1Option2"); |
| 107 | + radioButton2.Rect = [62, yPos, boxDim, boxDim]; |
| 108 | + |
| 109 | + var radioButton3 = radioGroup.createOption("RadioGroup1Option3"); |
| 110 | + radioButton3.Rect = [74, yPos, boxDim, boxDim]; |
| 111 | + radioButton3.AS = "/RadioGroup1Option3"; |
| 112 | + |
| 113 | + radioGroup.setAppearance(Appearance.RadioButton.Cross); |
| 114 | + yPos += boxDim + 5; |
| 115 | + |
| 116 | + // Second radio group |
| 117 | + var radioGroup2 = new RadioButton("RadioGroup2"); |
| 118 | + radioGroup2.value = "RadioGroup2Option3"; |
| 119 | + radioGroup2.fieldName = "RadioGroup2"; |
| 120 | + |
| 121 | + doc.addField(radioGroup2); |
| 122 | + |
| 123 | + var radioButton21 = radioGroup2.createOption("RadioGroup2Option1"); |
| 124 | + radioButton21.Rect = [50, yPos, boxDim, boxDim]; |
| 125 | + |
| 126 | + var radioButton22 = radioGroup2.createOption("RadioGroup2Option2"); |
| 127 | + radioButton22.Rect = [62, yPos, boxDim, boxDim]; |
| 128 | + |
| 129 | + var radioButton23 = radioGroup2.createOption("RadioGroup2Option3"); |
| 130 | + radioButton23.Rect = [74, yPos, boxDim, boxDim]; |
| 131 | + radioButton23.AS = "/RadioGroup2Option3"; |
| 132 | + |
| 133 | + radioGroup2.setAppearance(Appearance.RadioButton.Circle); |
| 134 | + yPos += margin + boxDim; |
| 135 | +} |
| 136 | + |
| 137 | +function addTextFieldGroup() { |
| 138 | + doc.text("TextField Group:", 10, yPos); |
| 139 | + |
| 140 | + const txtDate = new TextFieldGroup(); |
| 141 | + txtDate.fieldName = "Date"; |
| 142 | + txtDate.value = new Date().toLocaleDateString("en-US"); |
| 143 | + doc.addField(txtDate); |
| 144 | + |
| 145 | + const txtDate1 = txtDate.createChild(); |
| 146 | + txtDate1.Rect = [50, yPos - 5, 40, 10]; |
| 147 | + |
| 148 | + yPos += margin; |
| 149 | + |
| 150 | + const txtDate2 = txtDate.createChild(); |
| 151 | + txtDate2.Rect = [50, yPos - 5, 40, 10]; |
| 152 | +} |
0 commit comments