Skip to content

Commit 7d3ca1b

Browse files
1004880: Updated Overview, Form filling and form designer review changes.
1 parent d2c0df8 commit 7d3ca1b

10 files changed

Lines changed: 460 additions & 203 deletions

File tree

Document-Processing/PDF/PDF-Viewer/javascript-es6/form-designer/form-designer.md

Lines changed: 145 additions & 84 deletions
Large diffs are not rendered by default.

Document-Processing/PDF/PDF-Viewer/javascript-es6/form-designer/form-filling.md

Lines changed: 120 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -8,125 +8,165 @@ documentation: ug
88
domainurl: ##DomainURL##
99
---
1010

11-
# Form filling in TypeScript PDF Viewer
11+
# Filling PDF Forms in TypeScript PDF Viewer
1212

13-
The PDF Viewer displays existing form fields in a PDF and enables users to fill, validate, and download the filled data.
13+
The Syncfusion PDF Viewer supports three types of form-filling:
1414

15-
## Form Fields
15+
1. [Filling Form Fields Programmatically](#fill-pdf-forms-programmatically)
1616

17-
Work with the runtime form fields present in a PDF Form.
18-
- Render existing fields
19-
- Fill fields.
20-
- Import/Export form data as JSON, XFDF, FDF, or as a plain object
21-
- Inject FormFields to enable form-filling features.
17+
You can fill or update PDF form fields programmatically using the updateFormFieldsValue APIs. This approach is useful when form data needs to be set dynamically based on application logic.
2218

23-
Use the following code-snippet to enable form-filling by injecting `FormFields` Module.
19+
2. [Form Filling Through User Interface](#fill-pdf-forms-through-the-user-interface)
2420

25-
```ts
26-
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields} from '@syncfusion/ej2-pdfviewer';
27-
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields);
28-
let pdfviewer: PdfViewer = new PdfViewer();
29-
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf";
30-
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
31-
pdfviewer.appendTo('#PdfViewer');
32-
```
21+
Users can fill in PDF form fields directly through the PDF Viewer user interface by typing text, selecting options, or interacting with supported form elements.
22+
23+
3. [Importing Form Field Data](#fill-pdf-forms-through-import-data)
3324

34-
![FormFilling](../images/FormFill.png)
25+
The PDF Viewer allows you to import form field data into an existing PDF document. This enables pre filled forms using external data sources.
3526

36-
The PDF Viewer supports the following form field types:
27+
## Fill PDF forms programmatically
3728

38-
* [Text box](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-listbox)
39-
* [Password](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-password)
40-
* [Check box](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-checkbox)
41-
* [Radio button](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-radiobutton)
42-
* [List box](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-listbox)
43-
* [Dropdown](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-dropdown)
44-
* [Signature field](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-signature-field)
45-
* [Initial field](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-initial-field)
29+
You can update the values of PDF form fields programmatically using the updateFormFieldsValue API. This method allows you to set or modify form field values dynamically based on application logic, without user interaction.
4630

47-
![Form filling in TypeScript PDF Viewer](../images/FormFields.gif)
31+
The following example demonstrates how to update PDF form field values programmatically:
32+
33+
```html
34+
<button id="updateBtn">Fill Form Fields</button>
35+
```
36+
```ts
37+
import {PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormFields} from '@syncfusion/ej2-pdfviewer';
38+
39+
PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormFields);
40+
41+
let pdfviewer: PdfViewer = new PdfViewer({
42+
documentPath:
43+
'https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf',
44+
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',
45+
});
46+
47+
pdfviewer.appendTo('#pdfViewer');
48+
49+
// Wire up the button click
50+
document.getElementById('updateBtn')!.onclick = () => {
51+
//Retriveformfields
52+
const fields =
53+
pdfviewer.retrieveFormFields?.() || pdfviewer.formFieldCollection || [];
54+
//Get form fields by name
55+
const field = fields.find((f) => f?.name === 'name') || fields[0];
56+
57+
//Update the Values
58+
if (field) {
59+
field.value = 'John Doe';
60+
field.tooltip = 'First';
61+
pdfviewer.updateFormFieldsValue(field);
62+
} else {
63+
console.warn('No form fields available to update.');
64+
}
65+
};
66+
```
4867

49-
## Disabling form filling
68+
## Fill PDF forms through the User Interface
5069

51-
The PDF Viewer provides an option to disable interaction with form fields using `enableFormDesigner` API. Use the following configuration to disable form fields in the viewer.
70+
The Syncfusion PDF Viewer allows users to fill PDF form fields directly through the user interface without using code. Users can click on form fields and enter or select values based on the field type.
5271

72+
![Form Filling](../images/FormFields.gif)
5373

54-
```ts
55-
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner} from '@syncfusion/ej2-pdfviewer';
74+
The PDF Viewer supports common form fields such as text boxes, check boxes, radio buttons, drop-down lists, list boxes, and signature fields. Filled values can be edited at any time, and the entered data is retained during the viewing session.
5675

57-
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
76+
{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/prefilledforms-cs1" %}
5877

59-
let pdfviewer: PdfViewer = new PdfViewer();
60-
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf";
61-
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
62-
pdfviewer.enableFormDesigner = false; //To disable Form Desinger
63-
pdfviewer.appendTo('#PdfViewer');
64-
```
78+
## Fill PDF forms through Import Data
6579

66-
## Access form fields
80+
The Syncfusion PDF Viewer allows you to import form field data into an existing PDF document using the `importFormFields` API. This feature enables you to prefill form fields using data from an external source without requiring manual user input.
6781

68-
You can access the collection of all interactive form fields in the loaded document using the `formFieldCollection` property. Fetch the collection after the document is loaded.
82+
Imported form field data is automatically mapped to the corresponding form fields in the PDF document based on the field names. Once the data is imported, the populated values are displayed in the PDF Viewer and can be edited through the user interface if required.
6983

70-
Use the following code-snippet to access interactive form fields collection:
7184
```html
72-
<button id="formFieldCollection">Fetch Form-Fields Collection</button>
85+
<button id="importJson">Import JSON</button>
86+
<div id="pdfViewer" style="height: 640px; width: 100%"></div>
7387
```
7488
```ts
75-
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner} from '@syncfusion/ej2-pdfviewer';
76-
77-
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner);
78-
79-
let pdfviewer: PdfViewer = new PdfViewer();
80-
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf";
81-
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
89+
import { PdfViewer, FormFieldDataFormat, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer';
8290

83-
pdfviewer.appendTo('#PdfViewer');
91+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, FormFields, FormDesigner);
8492

85-
// Access the form fields collection via button click
86-
document.getElementById('formFieldCollection')?.addEventListener('click',function() {
87-
const fields = pdfviewer.formFieldCollection; // Gets all form fields
88-
console.log(fields)//Log the formField Collection
93+
const viewer = new PdfViewer({
94+
documentPath: 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf',
95+
// serviceUrl: 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/' // Server-backed
96+
resourceUrl: "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"
8997
});
98+
viewer.appendTo('#pdfViewer');
9099

100+
document.getElementById('importJson')!.addEventListener('click', () => {
101+
// The file for importing should be accessible at the given path or as a file stream depending on your integration
102+
viewer.importFormFields('File', FormFieldDataFormat.Json);
103+
});
91104
```
92105

93-
## Add a handwritten signature to a signature field
94-
95-
Add a handwritten signature to a signature field by following these steps:
96-
97-
* Click the signature field in the PDF document to open the signature panel.
98-
99-
![Signature field in TypeScript PDF Viewer](../images/form-filling-signature.png)
100-
101-
* Draw the signature in the signature panel.
102-
103-
![Signature panel in TypeScript PDF Viewer](../images/form-filling-signature-dialog.png)
106+
For more details, see [Import Form Data](./import-export-formfields/import-formfields).
104107

105-
* Select **CREATE**. The drawn signature is added to the signature field.
108+
## How to get the filled data and store it to a backing system
106109

107-
![Signature added in TypeScript PDF Viewer](../images/form-filling-signature-signed.png)
110+
You can export the filled form field data from the PDF Viewer and store it in a backing system such as a database or file storage. The exported data can later be imported to restore the form state.
108111

109-
## Delete a signature from a signature field
112+
For more details, see [Export Form Data](./import-export-formfields/export-formfields).
110113

111-
Delete a signature placed in a signature field by using the Delete option in the annotation toolbar.
114+
## How to Validate Form Fields using `validateFormFields` Event
112115

113-
![Deleting a signature in TypeScript PDF Viewer](../images/form-filling-signature-del.png)
116+
The `validateFormFields` event in the Syncfusion PDF Viewer is triggered when a user tries to download or submit a form while validation is enabled. You can use the `retrieveFormFields()` API to get all the form fields and check them one by one to see if any form fields values are empty.
114117

115-
## Export and import form fields
118+
This validation applies to all form field types in the PDF Viewer. A textbox is empty if no text is entered, a list box or dropdown is empty if no item is selected, a signature or initial field is empty if the user has not signed, and radio buttons or checkboxes are empty if none are chosen.
119+
By enabling `enableFormFieldsValidation` and wiring the event, you can go through each field and stop the action if required fields are not filled.
116120

117-
The PDF Viewer supports exporting and importing form field data using the `importFormFields`, `exportFormFields`, and `exportFormFieldsAsObject` methods. The following formats are supported:
118-
119-
* FDF
120-
* XFDF
121-
* JSON
122-
123-
For more information, see the [Form fields documentation](./import-export-formfields/export-formfields).
121+
```ts
122+
import {PdfViewer, Toolbar, Magnification, Navigation,LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation,FormDesigner, FormFields,TextFieldSettings} from '@syncfusion/ej2-pdfviewer';
123+
124+
PdfViewer.Inject(Toolbar, Magnification, Navigation,LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation,FormDesigner, FormFields);
125+
126+
let pdfviewer: PdfViewer = new PdfViewer({
127+
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
128+
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib',
129+
});
130+
131+
pdfviewer.appendTo('#pdfViewer');
132+
pdfviewer.enableFormFieldsValidation = true;
133+
134+
pdfviewer.documentLoad = () => {
135+
// Add a required Email field
136+
pdfviewer.formDesignerModule.addFormField('Textbox', {
137+
name: 'Email',
138+
bounds: { X: 146, Y: 260, Width: 220, Height: 24 },
139+
isRequired: true,
140+
tooltip: 'Email is required',
141+
} as TextFieldSettings);
142+
143+
// Add a required Phone field
144+
pdfviewer.formDesignerModule.addFormField('Textbox', {
145+
name: 'Phone',
146+
bounds: { X: 146, Y: 300, Width: 220, Height: 24 },
147+
isRequired: true,
148+
tooltip: 'Phone number is required',
149+
} as TextFieldSettings);
150+
};
151+
152+
// Validate only the added fields
153+
pdfviewer.validateFormFields = (args: any) => {
154+
const fields = pdfviewer.retrieveFormFields();
155+
156+
fields.forEach((field) => {
157+
if ((field.name === 'Email' || field.name === 'Phone') && !field.value) {
158+
alert(field.name + ' field cannot be empty.');
159+
args.isFormSubmitCancelled = true;
160+
}
161+
});
162+
};
163+
```
124164

125165
## See also
126166

127167
- [Form Designer overview](./overview)
128168
- [Form Designer Toolbar](../toolbar-customization/form-designer-toolbar)
129-
- [Create form fields](./Create-edit-Style-del-formFields/create-formfields)
169+
- [Create](./Create-edit-Style-del-formFields/create-formfields), [edit](./Create-edit-Style-del-formFields/edit-formfields), [style](./Create-edit-Style-del-formFields/style-formfields) and [remove](./Create-edit-Style-del-formFields/remove-formfields) form fields
130170
- [Edit form fields](./Create-edit-Style-del-formFields/edit-formfields)
131171
- [Group form fields](./group-formfields)
132172
- [Add custom data to form fields](./custom-data)

Document-Processing/PDF/PDF-Viewer/javascript-es6/form-designer/overview.md

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ documentation: ug
99

1010
# Overview of Forms in TypeScript PDF Viewer
1111

12-
Syncfusion TypeScript PDF Viewer provides a complete forms experience. Design new forms or enhance existing PDFs, fill and validate fields, import or export data, and capture signatures — all via an intuitive UI and rich APIs.
12+
The Syncfusion PDF Viewer delivers a complete, easy-to-use PDF forms experience. You can read, fill, add, edit, and delete form fields directly within your PDF documents. These actions are supported through both the intuitive user interface and powerful programmatic APIs.
1313

14-
The viewer supports both runtime form filling and an interactive Form Designer to create or modify fields.
14+
The viewer also includes smooth import and export support for form data, making integration effortless. Developers benefit from extensive API control, while end users enjoy a clean and simple interface designed for a seamless and stress-free form-filling experience.
1515

16-
## Form Fields
16+
## Filling PDF Forms
1717

18-
Work with the runtime form fields present in a PDF Form.
19-
- Render existing fields
20-
- [Fill fields](./form-filling).
21-
- [Import/Export](./import-export-formfields/export-formfields) form data as JSON, XFDF, FDF, or as a plain object
22-
- Inject [FormFields](./form-designer) to enable form-filling features.
18+
Experience effortless PDF form filling through a clean, intuitive UI or automated workflows using powerful APIs. Flexible form data import and export support ensures smooth and efficient operations when working with PDF forms.
19+
20+
See the [Filling PDF Forms](./form-filling) page for full details.
2321

2422
Use the following code-snippet to enable form-filling by injecting `FormFields` Module.
2523

@@ -34,16 +32,15 @@ pdfviewer.appendTo('#PdfViewer');
3432

3533
![FormFilling](../images/FormFields.gif)
3634

35+
1. [Programmatically Form fill](./form-filling#fill-pdf-forms-programmatically)
36+
2. [Form Fill Using UI](./form-filling#fill-pdf-forms-through-the-user-interface)
37+
3. [Import the Form data](./form-filling#fill-pdf-forms-through-import-data)
38+
3739
## Form Designer
3840

39-
Create and customize interactive fields directly on the PDF page.
40-
- [Add fields](../form-designer/Create-edit-Style-del-formFields/create-formfields): textbox, checkbox, radio button, dropdown, list box, signature, and initials
41-
- [Edit quickly](../form-designer/Create-edit-Style-del-formFields/edit-formfields): move, resize, align, distribute, copy/paste, undo/redo
42-
- [Configure properties](../form-designer/Create-edit-Style-del-formFields/style-formfields): name, value, font, color, border, alignment, required/read-only/visibility, tab order
43-
- [Control interaction](../form-designer/form-constrain): toggle read-only, show/hide, and manage printing behavior
44-
- [Manage fields](../form-designer/group-formfields): select, group/ungroup, reorder, or delete
45-
- [Save and print](../download): persist designed fields in the PDF and print with appearances
46-
- [Tailor the UI](./form-designer#how-to-customize-the-form-designer-toolbar): show/hide or customize the Form Designer toolbar; handle events for add/edit/select/move/resize
41+
A built in Form Designer lets you quickly add, edit, move, and delete form fields in the PDF documents. This viewer allows you to design fillable PDF forms interactively either using the built-in form designer tools or building your own customized form designer tools.
42+
43+
See the [Form Designer](./form-designer) page for full details.
4744

4845
Use the following Code-snippet to enable Form Designer by injecting `FormDesigner` Module.
4946

@@ -58,6 +55,13 @@ pdfviewer.appendTo('#PdfViewer');
5855

5956
![FormDesigner](../images/FormDesigner.gif)
6057

58+
Create and customize interactive fields directly on the PDF page.
59+
- [Create](./Create-edit-Style-del-formFields/create-formfields), [edit](./Create-edit-Style-del-formFields/edit-formfields), or [remove](./Create-edit-Style-del-formFields/remove-formfields) forms
60+
- [Add a Signature Field](./Create-edit-Style-del-formFields/create-formfields/#add-signature-field)
61+
- [Edit Form Field](./Create-edit-Style-del-formFields/edit-formfields)
62+
- [Remove Form Field](./Create-edit-Style-del-formFields/remove-formfields)
63+
- [Form Field Constraints](./form-constrain)
64+
6165
## Supported form field types
6266

6367
- [Textbox](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-textbox)
@@ -67,26 +71,4 @@ pdfviewer.appendTo('#PdfViewer');
6771
- [ListBox](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-listbox)
6872
- [DropDown](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-dropdown)
6973
- [Signature field](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-signature-field)
70-
- [Initial field](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-initial-field)
71-
72-
## Typical workflows
73-
74-
- **Design** → Save → Fill: [create or modify fields](./Create-edit-Style-del-formFields/create-formfields), save them into the PDF, then fill and validate
75-
- **Fill**[Export/Import](./import-export-formfields/export-formfields): complete forms and export data to JSON/XFDF/FDF, or import data to fill
76-
- **Customize** → Integrate: wire up events and business rules; tailor the designer [toolbar](./form-designer#how-to-customize-the-form-designer-toolbar) for your app
77-
78-
## See also
79-
80-
- [Form filling](./form-filling)
81-
- [Form Designer Toolbar](../toolbar-customization/form-designer-toolbar)
82-
- [Create form fields](./Create-edit-Style-del-formFields/create-formfields)
83-
- [Edit form fields](./Create-edit-Style-del-formFields/edit-formfields)
84-
- [Style form fields](./Create-edit-Style-del-formFields/style-formfields)
85-
- [Group form fields](./group-formfields)
86-
- [Form constraints](./form-constrain)
87-
- [Form validation](./form-validation)
88-
- [Form Fields API](./formfields-api)
89-
- [Custom data on form fields](./custom-data)
90-
- [Import form data](./import-export-formfields/import-formfields)
91-
- [Export form data](./import-export-formfields/export-formfields)
92-
- [Import/Export events](./import-export-formfields/import-export-events)
74+
- [Initial field](../form-designer/Create-edit-Style-del-formFields/create-formfields#add-initial-field)
485 KB
Loading
-70.6 KB
Loading
66.7 KB
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#container {
2+
visibility: hidden;
3+
}
4+
5+
#loader {
6+
color: #008cff;
7+
font-family: 'Helvetica Neue','calibiri';
8+
font-size: 14px;
9+
height: 40px;
10+
left: 45%;
11+
position: absolute;
12+
top: 45%;
13+
width: 30%;
14+
}

0 commit comments

Comments
 (0)