@@ -31,8 +31,11 @@ export async function configure(dotNetInterop) {
31
31
try {
32
32
PdfViewer . Inject ( Toolbar , Magnification , Navigation , Annotation , LinkAnnotation , ThumbnailView ,
33
33
BookmarkView , TextSelection , TextSearch , FormFields , FormDesigner , PageOrganizer ) ;
34
-
35
- pdfviewer = new PdfViewer ( ) ;
34
+ pdfviewer = new PdfViewer ( {
35
+ formFieldAdd : function ( args ) {
36
+ dotNetInterop . invokeMethodAsync ( 'OnFormFieldAdded' , args ) ;
37
+ }
38
+ } ) ;
36
39
configured = true ;
37
40
} catch ( e ) {
38
41
console . log ( e . message ) ;
@@ -73,10 +76,10 @@ export async function addSignatureField() {
73
76
try {
74
77
if ( pdfviewer != null ) {
75
78
const signatureFormElement = document . getElementById ( 'pdfViewer_formfield_signature' ) ;
76
- const signatureDialog = document . getElementById ( 'pdfViewer_formfield_signature-popup' ) ;
79
+
77
80
if ( signatureFormElement != null ) {
78
81
signatureFormElement . click ( ) ;
79
-
82
+ const signatureDialog = document . getElementById ( 'pdfViewer_formfield_signature-popup' ) ;
80
83
if ( signatureDialog != null ) {
81
84
const signatureDrawButton = signatureDialog . firstElementChild . firstElementChild . firstElementChild ;
82
85
if ( signatureDrawButton != null ) {
@@ -94,10 +97,10 @@ export async function addInitialField() {
94
97
try {
95
98
if ( pdfviewer != null ) {
96
99
const initialFormElement = document . getElementById ( 'pdfViewer_formfield_signature' ) ;
97
- const initialDialog = document . getElementById ( 'pdfViewer_formfield_signature-popup' ) ;
100
+
98
101
if ( initialFormElement != null ) {
99
102
initialFormElement . click ( ) ;
100
-
103
+ const initialDialog = document . getElementById ( 'pdfViewer_formfield_signature-popup' ) ;
101
104
if ( initialDialog != null ) {
102
105
const initialDrawButton = initialDialog . lastElementChild . lastElementChild . firstElementChild ;
103
106
if ( initialDrawButton != null ) {
@@ -124,17 +127,69 @@ export async function addTextBoxField() {
124
127
console . error ( e . message ) ;
125
128
}
126
129
}
130
+ export async function addCheckBoxField ( ) {
131
+ try {
132
+ if ( pdfviewer != null ) {
133
+ const checkbox = document . getElementById ( 'pdfViewer_formdesigner_checkbox' ) ;
134
+ if ( checkbox != null ) {
135
+ checkbox . click ( ) ;
136
+ }
137
+ }
138
+
139
+ } catch ( e ) {
140
+ console . error ( e . message ) ;
141
+ }
142
+ }
143
+ export async function addRadioBoxField ( ) {
144
+ try {
145
+ if ( pdfviewer != null ) {
146
+ const radiobox = document . getElementById ( 'pdfViewer_formdesigner_radiobutton' ) ;
147
+ if ( radiobox != null ) {
148
+ radiobox . click ( ) ;
149
+ }
150
+ }
151
+
152
+ } catch ( e ) {
153
+ console . error ( e . message ) ;
154
+ }
155
+ }
156
+ export async function addDropdownField ( ) {
157
+ try {
158
+ if ( pdfviewer != null ) {
159
+ const dropdown = document . getElementById ( 'pdfViewer_formdesigner_dropdown' ) ;
160
+ if ( dropdown != null ) {
161
+ dropdown . click ( ) ;
162
+ }
163
+ }
164
+
165
+ } catch ( e ) {
166
+ console . error ( e . message ) ;
167
+ }
168
+ }
169
+ export async function addListboxField ( ) {
170
+ try {
171
+ if ( pdfviewer != null ) {
172
+ const listbox = document . getElementById ( 'pdfViewer_formdesigner_listbox' ) ;
173
+ if ( listbox != null ) {
174
+ listbox . click ( ) ;
175
+ }
176
+ }
177
+
178
+ } catch ( e ) {
179
+ console . error ( e . message ) ;
180
+ }
181
+ }
127
182
export async function setFormFieldMode ( mode ) {
128
183
try {
129
184
if ( pdfviewer != null ) {
130
185
const addEditFormFieldButton = document . getElementById ( 'pdfViewer_formdesigner' ) ;
131
186
if ( addEditFormFieldButton != null ) {
132
- if ( mode ) {
187
+ if ( isDesignerMode == false && mode == true ) {
133
188
pdfviewer . enableFormDesigner = true ;
134
189
isDesignerMode = true ;
135
190
addEditFormFieldButton . click ( ) ;
136
191
}
137
- else {
192
+ else if ( isDesignerMode == true && mode == false ) {
138
193
addEditFormFieldButton . click ( ) ;
139
194
isDesignerMode = false ;
140
195
}
@@ -145,6 +200,25 @@ export async function setFormFieldMode(mode) {
145
200
146
201
}
147
202
}
203
+ export async function updateField ( id , _name , _isReadOnly , _visibility , _isRequired , _isPrint , _tooltip ) {
204
+ try {
205
+ if ( pdfviewer != null ) {
206
+ var formField = pdfviewer . getFormFieldByID ( id ) ;
207
+ pdfviewer . formDesignerModule . updateFormField ( formField , {
208
+ name : _name ,
209
+ isReadOnly : _isReadOnly ,
210
+ visibility : _visibility ,
211
+ isRequired : _isRequired ,
212
+ isPrint : _isPrint ,
213
+ tooltip : _tooltip ,
214
+ thickness : 1
215
+ } ) ;
216
+ }
217
+ } catch ( e ) {
218
+
219
+ }
220
+
221
+ }
148
222
document . addEventListener ( 'DOMContentLoaded' , ( event ) => {
149
223
configure ( ) . then ( ( ) => {
150
224
loadPDF ( 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf' ) ;
0 commit comments