You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Viewer/javascript-es6/form-designer/custom-data.md
+71-40Lines changed: 71 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,100 +7,131 @@ control: PDF Viewer
7
7
documentation: ug
8
8
---
9
9
10
-
# Add custom data to form fields
10
+
# Add Custom Data to PDF Form Fields in TypeScript PDF Viewer
11
11
12
-
You can associate arbitrary metadata with any form field using the customData property. This is useful for storing business IDs, validation hints, tags, or any app-specific information alongside the field. The data stays with the field object during the viewer session and can be accessed whenever you query or update fields.
12
+
The Syncfusion **TypeScript PDF Viewer** allows you to attach **custom application-specific data** to form fields by using the customData property. This enables you to associate business identifiers, tags, validation hints, or workflow metadata with form fields.
13
13
14
-
N> customData is a free-form object. You control both its shape and how it is used in your application.
14
+
The custom data remains linked to the form field throughout the viewer session and can be accessed or updated whenever the field is queried or modified.
15
15
16
-
## Add custom data when creating fields (programmatically)
16
+
This page explains how to:
17
+
-[Add custom data when creating form fields](#add-custom-data-while-creating-pdf-form-fields)
18
+
-[Define default custom data for fields created using the UI](#set-default-custom-data-for-pdf-form-fields-added-using-ui)
19
+
-[Update or replace custom data for existing fields](#update-or-replace-pdf-form-field-custom-data)
20
+
-[Read custom data from form fields](#read-custom-data-from-pdf-form-fields)
21
+
-[Apply best practices when using custom data](#best-practices)
17
22
18
-
Pass a customData object in the second parameter of addFormField. You can include any serializable values.
23
+
**Key Points**
24
+
- customData is a **free form object**; you control its structure.
25
+
- Use only **serializable values** such as objects, arrays, strings, numbers, and booleans.
26
+
- Custom data does not affect the field appearance or behavior unless consumed by your application logic.
27
+
28
+
## Add Custom Data While Creating PDF Form Fields
29
+
30
+
You can attach custom data at the time of field creation by passing a **customData** object in the settings parameter of **addFormField()**.
## Set Default Custom Data for PDF Form Fields Added Using UI
45
54
46
-
## Set default custom data for UI-created fields
55
+
When users add form fields using the [Form Designer toolbar](../toolbar-customization/form-designer-toolbar), you can define default customData so that newly created fields automatically inherit it. Default custom data can be configured using per-field settings objects such as:
47
56
48
-
When users add fields via the Form Designer toolbar, you can predefine default customData using the per-field settings objects.
You can do the same for other field types using passwordFieldSettings, checkBoxFieldSettings, radioButtonFieldSettings, listBoxFieldSettings, dropDownFieldSettings, signatureFieldSettings, and initialFieldSettings.
## Update or replace custom data on existing fields
81
+
## Update or Replace PDF Form Field Custom Data
61
82
62
-
Use updateFormField to set or modify the customData of any existing field (retrieved by object or ID).
83
+
You can modify the customData of an existing form field by using the [updateFormField()](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#updateformfields) method. The field can be identified using either its object reference or field ID.
Tip: You can merge new values with existing ones in your app code before calling updateFormField.
97
+
**Tip:**
98
+
Merge new values with the existing customData object before calling [updateFormField()](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#updateformfields) to avoid overwriting previously stored data.
73
99
74
-
## Read custom data
100
+
## Read Custom Data from PDF Form Fields
75
101
76
-
You can read customData from any field at any time. Typical entry points:
77
-
- After document load
78
-
- On your own UI actions (save, validate, route, etc.)
102
+
You can access the customData property from any form field at any point in your application flow, such as:
103
+
- After the document is loaded
104
+
- During save or submit operations
105
+
- While performing validation or conditional routing
0 commit comments