Skip to content

Commit c9c2001

Browse files
994681: Updated Images & code-snippets for Edit ans Style Form Fields
1 parent dd38a47 commit c9c2001

19 files changed

+216
-82
lines changed

Document-Processing/PDF/PDF-Viewer/javascript-es6/form-designer/Create-edit-Style-del-formFields/edit-formfields.md

Lines changed: 98 additions & 50 deletions
Large diffs are not rendered by default.

Document-Processing/PDF/PDF-Viewer/javascript-es6/form-designer/Create-edit-Style-del-formFields/style-formfields.md

Lines changed: 118 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ Use the Properties panel to adjust the value, font family/size/style, text color
3434

3535
Use `updateFormField` to modify a textbox’s appearance and behavior on a button click. The example below finds the field by name (or falls back to the first field) and updates value, typography, colors, alignment, and border thickness.
3636

37-
- value: Sets the displayed text.
38-
- fontFamily, fontSize, fontStyle: Controls text typography.
39-
- color: Text color.
40-
- borderColor, backgroundColor: Field border and fill colors.
41-
- alignment: Horizontal text alignment (Left, Center, Right).
42-
- thickness: Border thickness (set 0 to hide).
43-
4437
```html
4538
<button id="updateTextboxStyle">Update Textbox Style</button>
4639
```
@@ -78,7 +71,9 @@ pdfviewer.appendTo('#PdfViewer');
7871
});
7972
```
8073

81-
### Default Textbox settings (toolbar additions)
74+
### Default Textbox settings
75+
76+
The PDF Viewer exposes a default settings APIs for form fields. Use the [TextFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#textfieldsettings) to preconfigure TextBox properties applied when adding fields from the Form Designer toolbar.
8277

8378
```ts
8479
// Apply as defaults for Textbox added from toolbar
@@ -114,8 +109,19 @@ Use the Properties panel to configure the tooltip, font family and size, masked
114109
### Style Password programmatically
115110

116111
```ts
117-
const pw = pdfviewer.formFieldCollections.find(f => f.name === 'Password');
112+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PasswordFieldSettings } from '@syncfusion/ej2-pdfviewer';
113+
114+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
115+
116+
const pdfviewer: PdfViewer = new PdfViewer();
117+
pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf';
118+
pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
119+
pdfviewer.appendTo('#PdfViewer');
120+
121+
// Retrieve form fields collection and find the password field by name
122+
const pw = pdfviewer.formFieldCollections.find((f: any) => f.name === 'Password');
118123
if (pw) {
124+
// Update password field styling
119125
pdfviewer.formDesignerModule.updateFormField(pw, {
120126
tooltip: 'Enter password',
121127
fontFamily: 'Courier',
@@ -126,11 +132,13 @@ if (pw) {
126132
alignment: 'Left',
127133
maxLength: 20,
128134
thickness: 1
129-
});
135+
} as PasswordFieldSettings);
130136
}
131137
```
132138

133-
### Default Password settings (toolbar additions)
139+
### Default Password settings
140+
141+
The PDF Viewer exposes default settings APIs for form fields. Use the [PasswordFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#passwordfieldsettings) to preconfigure Password properties applied when adding fields from the Form Designer toolbar.
134142

135143
```ts
136144
pdfviewer.passwordFieldSettings = {
@@ -164,19 +172,32 @@ Use the Properties panel to toggle the checked state and customize border and ba
164172
### Style CheckBox programmatically
165173

166174
```ts
167-
const cb = pdfviewer.formFieldCollections.find(f => f.name === 'Subscribe');
175+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, CheckBoxFieldSettings } from '@syncfusion/ej2-pdfviewer';
176+
177+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
178+
179+
const pdfviewer: PdfViewer = new PdfViewer();
180+
pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf';
181+
pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
182+
pdfviewer.appendTo('#PdfViewer');
183+
184+
// Retrieve form fields collection and find the checkbox field by name
185+
const cb = pdfviewer.formFieldCollections.find((f: any) => f.name === 'Subscribe');
168186
if (cb) {
187+
// Update checkbox field styling
169188
pdfviewer.formDesignerModule.updateFormField(cb, {
170189
isChecked: true,
171190
backgroundColor: 'white',
172191
borderColor: 'black',
173192
thickness: 2,
174193
tooltip: 'Subscribe'
175-
});
194+
} as CheckBoxFieldSettings);
176195
}
177196
```
178197

179-
### Default CheckBox settings (toolbar additions)
198+
### Default CheckBox settings
199+
200+
The PDF Viewer exposes default settings APIs for form fields. Use the [CheckBoxFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#checkboxfieldsettings) to preconfigure CheckBox properties applied when adding fields from the Form Designer toolbar.
180201

181202
```ts
182203
pdfviewer.checkBoxFieldSettings = {
@@ -204,14 +225,28 @@ Use the Properties panel to set the selected state, border and background colors
204225
### Style RadioButton programmatically
205226

206227
```ts
207-
const radios = pdfviewer.formFieldCollections.filter(f => f.name === 'Gender');
228+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, RadioButtonFieldSettings } from '@syncfusion/ej2-pdfviewer';
229+
230+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
231+
232+
const pdfviewer: PdfViewer = new PdfViewer();
233+
pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf';
234+
pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
235+
pdfviewer.appendTo('#PdfViewer');
236+
237+
// Retrieve all radio buttons by group name
238+
const radios = pdfviewer.formFieldCollections.filter((f: any) => f.name === 'Gender');
208239
if (radios.length > 1) {
209-
pdfviewer.formDesignerModule.updateFormField(radios[0], { isSelected: false });
210-
pdfviewer.formDesignerModule.updateFormField(radios[1], { isSelected: true, thickness: 2, borderColor: 'black' });
240+
// Deselect first option
241+
pdfviewer.formDesignerModule.updateFormField(radios[0], { isSelected: false } as RadioButtonFieldSettings);
242+
// Select second option and style
243+
pdfviewer.formDesignerModule.updateFormField(radios[1], { isSelected: true, thickness: 2, borderColor: 'black' } as RadioButtonFieldSettings);
211244
}
212245
```
213246

214-
### Default RadioButton settings (toolbar additions)
247+
### Default RadioButton settings
248+
249+
The PDF Viewer exposes default settings APIs for form fields. Use the [RadioButtonFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#radiobuttonfieldsettings) to preconfigure RadioButton properties applied when adding fields from the Form Designer toolbar.
215250

216251
```ts
217252
pdfviewer.radioButtonFieldSettings = {
@@ -240,8 +275,19 @@ Use the Properties panel to add or remove items, set the selected value, and adj
240275
### Style ListBox programmatically
241276

242277
```ts
243-
const lb = pdfviewer.formFieldCollections.find(f => f.name === 'States');
278+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, TextFieldSettings } from '@syncfusion/ej2-pdfviewer';
279+
280+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
281+
282+
const pdfviewer: PdfViewer = new PdfViewer();
283+
pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf';
284+
pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
285+
pdfviewer.appendTo('#PdfViewer');
286+
287+
// Retrieve form fields collection and find the list box field by name
288+
const lb = pdfviewer.formFieldCollections.find((f: any) => f.name === 'States');
244289
if (lb) {
290+
// Update list box items, value, and styling
245291
pdfviewer.formDesignerModule.updateFormField(lb, {
246292
options: [
247293
{ itemName: 'Item 1', itemValue: 'item1' },
@@ -254,11 +300,13 @@ if (lb) {
254300
color: 'black',
255301
borderColor: 'black',
256302
backgroundColor: 'white'
257-
} as any);
303+
} as unknown as TextFieldSettings);
258304
}
259305
```
260306

261-
### Default ListBox settings (toolbar additions)
307+
### Default ListBox settings
308+
309+
The PDF Viewer exposes default settings APIs for form fields. Use the [listBoxFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#listboxfieldsettings) to preconfigure ListBox properties applied when adding fields from the Form Designer toolbar.
262310

263311
```ts
264312
const customOptions = [
@@ -298,8 +346,19 @@ Use the Properties panel to add or remove items, set the default value, and adju
298346
### Style DropDown programmatically
299347

300348
```ts
301-
const dd = pdfviewer.formFieldCollections.find(f => f.name === 'Country');
349+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, DropdownFieldSettings } from '@syncfusion/ej2-pdfviewer';
350+
351+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
352+
353+
const pdfviewer: PdfViewer = new PdfViewer();
354+
pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf';
355+
pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
356+
pdfviewer.appendTo('#PdfViewer');
357+
358+
// Retrieve form fields collection and find the dropdown field by name
359+
const dd = pdfviewer.formFieldCollections.find((f: any) => f.name === 'Country');
302360
if (dd) {
361+
// Update dropdown items, value, and styling
303362
pdfviewer.formDesignerModule.updateFormField(dd, {
304363
options: [
305364
{ itemName: 'USA', itemValue: 'US' },
@@ -312,11 +371,13 @@ if (dd) {
312371
color: 'black',
313372
borderColor: 'black',
314373
backgroundColor: 'white'
315-
} as any);
374+
} as DropdownFieldSettings);
316375
}
317376
```
318377

319-
### Default DropDown settings (toolbar additions)
378+
### Default DropDown settings
379+
380+
The PDF Viewer exposes default settings APIs for form fields. DropDown uses [DropDownFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#DropDownfieldsettings) to preconfigure properties applied when adding fields from the Form Designer toolbar.
320381

321382
```ts
322383
const ddOptions = [
@@ -326,7 +387,7 @@ const ddOptions = [
326387
];
327388

328389
// DropDown uses listBoxFieldSettings for defaults
329-
pdfviewer.listBoxFieldSettings = {
390+
pdfviewer.DropdownFieldSettings = {
330391
name: 'DropDown',
331392
isReadOnly: false,
332393
visibility: 'visible',
@@ -357,20 +418,33 @@ Use the Properties panel to configure the tooltip, indicator text, dialog displa
357418
### Style Signature field programmatically
358419

359420
```ts
360-
const sig = pdfviewer.formFieldCollections.find(f => f.name === 'Sign');
421+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, SignatureFieldSettings } from '@syncfusion/ej2-pdfviewer';
422+
423+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
424+
425+
const pdfviewer: PdfViewer = new PdfViewer();
426+
pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf';
427+
pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
428+
pdfviewer.appendTo('#PdfViewer');
429+
430+
// Retrieve form fields collection and find the signature field by name
431+
const sig = pdfviewer.formFieldCollections.find((f: any) => f.name === 'Sign');
361432
if (sig) {
433+
// Update signature field settings
362434
pdfviewer.formDesignerModule.updateFormField(sig, {
363435
tooltip: 'Please sign here',
364436
thickness: 3,
365437
isRequired: true,
366438
isPrint: true,
367439
backgroundColor: 'white',
368440
borderColor: 'black'
369-
});
441+
} as unknown as SignatureFieldSettings);
370442
}
371443
```
372444

373-
### Default Signature field settings (toolbar additions)
445+
### Default Signature field settings
446+
447+
The PDF Viewer exposes default settings APIs for form fields. Use the [SignatureFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#signaturefieldsettings) to preconfigure Signature properties applied when adding fields from the Form Designer toolbar.
374448

375449
```ts
376450
pdfviewer.signatureFieldSettings = {
@@ -407,20 +481,33 @@ Use the Properties panel to configure the tooltip, indicator text, dialog displa
407481
### Style Initial field programmatically
408482

409483
```ts
410-
const init = pdfviewer.formFieldCollections.find(f => f.name === 'Initial');
484+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, InitialFieldSettings } from '@syncfusion/ej2-pdfviewer';
485+
486+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
487+
488+
const pdfviewer: PdfViewer = new PdfViewer();
489+
pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf';
490+
pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
491+
pdfviewer.appendTo('#PdfViewer');
492+
493+
// Retrieve form fields collection and find the initial field by name
494+
const init = pdfviewer.formFieldCollections.find((f: any) => f.name === 'Initial');
411495
if (init) {
496+
// Update initial field settings
412497
pdfviewer.formDesignerModule.updateFormField(init, {
413498
tooltip: 'Add your initials',
414499
thickness: 2,
415500
isRequired: true,
416501
isPrint: true,
417502
backgroundColor: 'white',
418503
borderColor: 'black'
419-
});
504+
} as unknown as InitialFieldSettings);
420505
}
421506
```
422507

423-
### Default Initial field settings (toolbar additions)
508+
### Default Initial field settings
509+
510+
The PDF Viewer exposes default settings APIs for form fields. Use the [InitialFieldSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#initialfieldsettings) to preconfigure Initial properties applied when adding fields from the Form Designer toolbar.
424511

425512
```ts
426513
pdfviewer.initialFieldSettings = {
@@ -445,4 +532,3 @@ pdfviewer.initialFieldSettings = {
445532
}
446533
};
447534
```
448-
79.8 KB
Loading
62.2 KB
Loading
58.6 KB
Loading
60.4 KB
Loading
64.7 KB
Loading
55.9 KB
Loading
53.6 KB
Loading
62.8 KB
Loading

0 commit comments

Comments
 (0)