Effective guidelines for PDF form field types

Types

This section explains how to use type declarations in Instant JSON records.

The optional keys are specified as follows:

{ optionalKey?: value; }

To reduce payload size, omit optional keys when their values are undefined.

Form fields

Form field types allow you to sync form fields across different devices.

Common types

There are some data types used by different form field types:

// Examples of common types of Instant JSON payloads.
// Additional action types.
formFieldEventTriggerType = "onChange"
// Additional action types for input events.
// K — Action to be performed when the user types a keystroke into a text field or combo box or modifies the selection in a scrollable list box.
formFieldInputEventTriggerType = "onInput"
// Form field flags.
formFieldFlags = ["readOnly", "required"]
// Form option.
formOption = {
"label": "name",
"value": "John Appleseed"
};

Base form field shared properties

Some properties are common to all form fields and shared among all form field Instant types.

The following example shows a payload of this abstract type:

// Example of a base form field Instant JSON schema:
{
"type": "pspdfkit/form-field/text",
"pdfObjectId": 100,
"annotationIds": ["100"],
"name": "Email",
"label": "Email", // Used to identify the field in the UI or for accessibility.
"flags": ["required"]
}

Choice form field

Here’s an abstract type encompassing list box and combo box form fields:

// Example of the Instant JSON schema of a choice form field:
{
"type": "pspdfkit/form-field/listbox",
"pdfObjectId": 100,
"annotationIds": ["101", "102"],
"name": "Subscribe",
"label": "Subscribe",
"options": [
{
"label": "Yes",
"value": "Yes"
},
{
"label": "No",
"value": "No"
}
],
"multiSelect": false,
"commitOnChange": false,
"defaultValues": ["No"]
}

List box form field

// Example of the Instant JSON schema of a list box form field:
{
"type": "pspdfkit/form-field/listbox",
"pdfObjectId": 100,
"annotationIds": ["101", "102"],
"name": "Subscribe",
"label": "Subscribe",
"options": [
{
"label": "Yes",
"value": "Yes"
},
{
"label": "No",
"value": "No"
}
],
"multiSelect": false,
"commitOnChange": false,
"defaultValues": ["No"],
"additionalActions": {
"onInput": {
"type": "goTo",
"pageIndex": 3
}
}
}

Combo box form field

// Example of the Instant JSON schema of a combo box form field:
{
"type": "pspdfkit/form-field/combobox",
"pdfObjectId": 100,
"annotationIds": ["101", "102"],
"name": "Subscribe",
"label": "Subscribe",
"options": [
{
"label": "Yes",
"value": "Yes"
},
{
"label": "No",
"value": "No"
}
],
"multiSelect": false,
"commitOnChange": false,
"defaultValues": ["No"],
"edit": false,
"doNotSpellCheck": false
}

Checkbox form field

// Example of the Instant JSON schema of a checkbox form field:
{
"pdfObjectId": 100,
"annotationIds": ["100"],
"name": "Accept",
"label": "Accept",
"flags": ["required"],
"options": [
{
"label": "Yes",
"value": "Yes"
},
{
"label": "No",
"value": "No"
}
],
"defaultValues": ["No"]
}

Radio button form field

// Example of the Instant JSON schema of a radio button form field:
{
"type": "pspdfkit/form-field/radio",
"pdfObjectId": 100,
"annotationIds": ["101", "102"],
"name": "Color",
"label": "Color",
"options": [
{
"label": "Blue",
"value": "Blue"
},
{
"label": "Red",
"value": "Red"
}
],
"noToggleToOff": true,
"radiosInUnison": false, // Not supported in Web.
"defaultValue": "Blue"
}

Text form field

// Example of the Instant JSON schema of a text form field:
{
"type": "pspdfkit/form-field/text",
"pdfObjectId": 100,
"annotationIds": ["100"],
"name": "Name",
"label": "Name", // Used to identify the field in the UI or for accessibility.
"password": false,
"maxLength": 100,
"doNotSpellcheck": true,
"doNotScroll": false,
"multiLine": false,
"comb": false,
"defaultValue": ""
}

Signature form field

// Example of the Instant JSON schema of a signature form field:
{
"type": "pspdfkit/form-field/signature",
"pdfObjectId": 100,
"annotationIds": ["100"],
"name": "Your signature",
"label": "Your signature"
}

Button form field

// Example of the Instant JSON schema of a button form field:
{
"type": "pspdfkit/form-field/button",
"pdfObjectId": 100,
"annotationIds": ["100"],
"name": "A button",
"label": "A button"
}