FoxitPDFSDKforWeb v11.0.1
Foxit PDF SDK for Web
PDFFormField Class Reference
Inheritance diagram for PDFFormField:
Disposable PDFSignature

Public Member Functions

async addOption (item:ChoiceOptionItem)
 Adds an option to the end of the list box or combo box. More...
 
async deleteOption (index:number)
 Deletes an option by index from the list box or combo box. More...
 
 describeFieldFlags ()
 Retrieves the flag options for the current field. More...
 
 getAdditionalAction ()
 Retrives the additional action object. More...
 
 getAlignment ()
 Retrieves the field's alignment. More...
 
async getAlternateName ()
 Get alternate name. More...
 
 getDefaultValue ()
 Retrieves the default value of the field. More...
 
 getExtType ()
 Retrieves the extended type information for the current form field. More...
 
 getFlags ()
 Retrieves the field's flags. More...
 
 getMappingName ()
 Get mapping name. More...
 
 getMaxLength ()
 Retrieves the maximum length of the text field. More...
 
 getName ()
 Retrives the name of the form field. More...
 
 getOptions ()
 Retrieves combo box and list box options. More...
 
 getOptionsSize ()
 Retrieves the number of options available in the list box or combo box. More...
 
 getType ()
 Get form field's type. More...
 
 getValue ()
 Get field value. More...
 
async getWidget (index:number)
 Get widget annot with specified index. Please call PDFFormField.getWidgetsCount to get count. More...
 
 getWidgetsCount ()
 Get the count of field's controls. More...
 
async insertOption (index:number, item:ChoiceOptionItem)
 Inserts an option at the specified index. More...
 
 isCheckedByDefault ()
 Checks if the field is checked by default. More...
 
async isReadonly ()
 Check if the field is read only. More...
 
async isRequired ()
 Check if the field is required. More...
 
async moveOption (srcIndex:number, destIndex:number)
 Moves an option from one index to another. More...
 
async selectOption (index:number)
 Selects an option by index in the list box or combo box. More...
 
async setAlignment (alignment:number)
 Sets the field's alignment (not applicable for signature fields). More...
 
async setAlternateName (alternateName:string)
 Set alternate name. More...
 
 setCheckedByDefault (checked:boolean)
 Sets the default checked state of the field. More...
 
 setDefaultValue (defaultValue:string)
 Sets the default value of the field. More...
 
async setMappingName (mappingName:string)
 Set mapping name. (Not support signature field). More...
 
async setMaxLength (maxLength:number)
 Sets the maximum length for the text field. More...
 
async setOptions (options:{ label:string;value:string;selected:boolean;defaultSelected:boolean;}[])
 Sets the options (items) for a list box or combo box. More...
 
 setValue (value:string, isTriggerEvent=true)
 Set field value. More...
 
 updateFlagByOptions (options:Partial< FieldFlagOptions >)
 Updates the field's flags based on the given options. More...
 
async updateOption (index:number, itemOptions:Partial< ChoiceOptionItem >)
 Updates an option at a specified index. More...
 
- Public Member Functions inherited from Disposable
 addDestroyHook (...hooks)
 Add a function to destroyHooks list, which will be called during destroy. More...
 
 destroy ()
 
 ownsTo (owner)
 Establishes an ownership relationship where this instance will be destroyed when the owner is destroyed. Additionally, the owner will be automatically removed from the destroyHooks list when this instance is destroyed. More...
 

Detailed Description

PDF Form Field object

Field

Since
11.0.0

Member Function Documentation

◆ addOption()

async PDFFormField::addOption (   item:ChoiceOptionItem)
inline

Adds an option to the end of the list box or combo box.

Parameters
itemChoiceOptionItem - The option to add.
Returns
Promise<void> - Resolves when the option is added.
Since
11.0.0

◆ deleteOption()

async PDFFormField::deleteOption (   index:number)
inline

Deletes an option by index from the list box or combo box.

Parameters
indexnumber - The index of the option to delete.
Returns
Promise<void> - Resolves when the option is deleted.
Since
11.0.0

◆ describeFieldFlags()

PDFFormField::describeFieldFlags ( )
inline

Retrieves the flag options for the current field.

Returns
Promise<FieldFlagOptions> -
Since
11.0.0

◆ getAdditionalAction()

PDFFormField::getAdditionalAction ( )
inline

Retrives the additional action object.

Returns
AdditionalAction<FieldActionTriggerEvents> - The additional action object used to manipulate additional actions.
Since
11.0.0

◆ getAlignment()

PDFFormField::getAlignment ( )
inline

Retrieves the field's alignment.

Returns
Promise<Alignment> - The current alignment of the field.
Since
11.0.0

◆ getAlternateName()

async PDFFormField::getAlternateName ( )
inline

Get alternate name.

An alternate field name to be used in place of the actual field name wherever the field must be identified in the user interface (such as in error or status messages referring to the field). This text is also useful when extracting the document's contents in support of accessibility to users with disabilities or for other purposes.

let fieldname = 'ComboBox0'
let pdfviewer = await pdfui.getPDFViewer()
let field = pdfviewer.getPDFDocRender().getPDFDoc().getPDFForm().getField(fieldname)
field.getAlternateName()
Returns
Promise<string> - A promise that fullfilled with the alternate field name.
Since
11.0.0

◆ getDefaultValue()

PDFFormField::getDefaultValue ( )
inline

Retrieves the default value of the field.

Returns
Promise<string> - The current default value of the field.
Since
11.0.0

◆ getExtType()

PDFFormField::getExtType ( )
inline

Retrieves the extended type information for the current form field.

Returns
ExtFieldType - The extended field type information.
Since
11.0.0

◆ getFlags()

PDFFormField::getFlags ( )
inline

Retrieves the field's flags.

Returns
number - The flags associated with the field.
See also
FieldFlag
Since
11.0.0

◆ getMappingName()

PDFFormField::getMappingName ( )
inline

Get mapping name.

Mapping name is to be used when exporting interactive form field data from the document.

Returns
Promise<string> - The mapping name.
Since
11.0.0

◆ getMaxLength()

PDFFormField::getMaxLength ( )
inline

Retrieves the maximum length of the text field.

Returns
Promise<number> - The maximum length of the text.
Since
11.0.0

◆ getName()

PDFFormField::getName ( )
inline

Retrives the name of the form field.

Returns
string - Form field's name

◆ getOptions()

PDFFormField::getOptions ( )
inline

Retrieves combo box and list box options.

Returns
Array<ChoiceOptionItem> - Array of field's options. For Example:
[
{
label:"label0",
value:"value0"
},{
label:"label1",
value:"value1"
},
...
]
Since
11.0.0

◆ getOptionsSize()

PDFFormField::getOptionsSize ( )
inline

Retrieves the number of options available in the list box or combo box.

Returns
Promise<number> - The number of options available.
Since
11.0.0

◆ getType()

PDFFormField::getType ( )
inline

Get form field's type.

Returns
FieldType - Form field's type. Please refer to FieldType

Unknown:0; PushButton:1; CheckBox:2; RadioButton:3; ComboBox:4; ListBox:5; Text:6; Sign:7; Barcode:8

◆ getValue()

PDFFormField::getValue ( )
inline

Get field value.

Returns
Promise<string> - A Promise fullfilled with Field's value

◆ getWidget()

async PDFFormField::getWidget (   index:number)
inline

Get widget annot with specified index. Please call PDFFormField.getWidgetsCount to get count.

Parameters
indexNumber - Index of widget.
Returns
Promise<Widget> - Widget annot.
Since
7.5.0

◆ getWidgetsCount()

PDFFormField::getWidgetsCount ( )
inline

Get the count of field's controls.

Returns
Promise<number> - Count of field's controls.
Since
11.0.0

◆ insertOption()

async PDFFormField::insertOption (   index:number,
  item:ChoiceOptionItem 
)
inline

Inserts an option at the specified index.

Parameters
indexnumber - The position where the new option will be inserted.
itemChoiceOptionItem - The option to be inserted.
Returns
Promise<void> - Resolves when the option is inserted.
Since
11.0.0

◆ isCheckedByDefault()

PDFFormField::isCheckedByDefault ( )
inline

Checks if the field is checked by default.

Returns
Promise<boolean> - The current default checked state.
Since
11.0.0

◆ isReadonly()

async PDFFormField::isReadonly ( )
inline

Check if the field is read only.

Returns
Promise<boolean> - A Promise fulfilled with a boolean indicating if the field is read only.
Since
11.0.0

◆ isRequired()

async PDFFormField::isRequired ( )
inline

Check if the field is required.

Returns
Promise<boolean> - A Promise fulfilled with a boolean indicating if the field is required.
Since
11.0.0

◆ moveOption()

async PDFFormField::moveOption (   srcIndex:number,
  destIndex:number 
)
inline

Moves an option from one index to another.

Parameters
srcIndexnumber - The source index of the option.
destIndexnumber - The destination index of the option.
Returns
Promise<void> - Resolves when the option is moved.
Since
11.0.0

◆ selectOption()

async PDFFormField::selectOption (   index:number)
inline

Selects an option by index in the list box or combo box.

Parameters
indexnumber - The index of the option to select.
Returns
Promise<void> - Resolves when the option is selected.
Since
11.0.0

◆ setAlignment()

async PDFFormField::setAlignment (   alignment:number)
inline

Sets the field's alignment (not applicable for signature fields).

Parameters
alignmentAlignment - The alignment to set.
Returns
Promise<void>

◆ setAlternateName()

async PDFFormField::setAlternateName (   alternateName:string)
inline

Set alternate name.

An alternate field name is to be used in place of the actual field name wherever the field must be identified in the user interface (such as in error or status messages referring to the field). This text is also useful when extracting the document's contents in support of accessibility to users with disabilities or for other purposes.

Parameters
alternateNamestring - A new alternate name string.
Since
11.0.0

◆ setCheckedByDefault()

PDFFormField::setCheckedByDefault (   checked:boolean)
inline

Sets the default checked state of the field.

Parameters
checkedboolean - The checked state to set by default.
Returns
Promise<void> - Resolves once the checked state is set.
Since
11.0.0

◆ setDefaultValue()

PDFFormField::setDefaultValue (   defaultValue:string)
inline

Sets the default value of the field.

Parameters
defaultValuestring - The default value to be set.
Returns
Promise<void> - Resolves once the value is set.
Since
11.0.0

◆ setMappingName()

async PDFFormField::setMappingName (   mappingName:string)
inline

Set mapping name. (Not support signature field).

Mapping name is to be used when exporting interactive form field data from the document.
If current form field is a signature field, this function will do nothing.

Parameters
mappingNamestring - A new mapping name string.
Returns
Promise<void> -
Since
11.0.0

◆ setMaxLength()

async PDFFormField::setMaxLength (   maxLength:number)
inline

Sets the maximum length for the text field.

Parameters
maxLengthnumber - Specifies the maximum text length (0 means no limit).
Returns
Promise<void> - Resolves when the max length is set.
Exceptions
Errorif maxLength is less than 0.
Since
11.0.0

◆ setOptions()

async PDFFormField::setOptions (   options:{ label:string;value:string;selected:boolean;defaultSelected:boolean;}[])
inline

Sets the options (items) for a list box or combo box.

Applicable for list box and combo box fields. For other field types, this function does nothing.

Parameters
optionsArray<{label: string, value: string, selected: boolean, defaultSelected: boolean}> - An array of options to set for the list box or combo box. For Example:
[
{
label: "label0",
value: "value0",
selected: true,
defaultSelected: true
},
{
label: "label1",
value: "value1",
selected: false,
defaultSelected: false
}
]
Returns
Promise<void> - Resolves when the options are successfully set.
Since
11.0.0

◆ setValue()

PDFFormField::setValue (   value:string,
  isTriggerEvent = true 
)
inline

Set field value.

Parameters
valuestring - Field's value to be set.
isTriggerEventboolean - Whether to trigger DataEvents.formFieldPropertyUpdated event after setting value. Default is true.
Returns
Promise<void> - Resolves once the value is set.
Since
11.0.0 When the field is focused, setValue will be ignored. Please use FormFillerEditorAPI instead. FormFillerService.getEditorAPI FormFillerEditorAPI

◆ updateFlagByOptions()

PDFFormField::updateFlagByOptions (   options:Partial< FieldFlagOptions >)
inline

Updates the field's flags based on the given options.

Parameters
optionsPartial<FieldFlagOptions> - The options used to update the field flags.
Returns
Promise<void> - Resolves when the flags have been successfully updated.
Since
11.0.0

◆ updateOption()

async PDFFormField::updateOption (   index:number,
  itemOptions:Partial< ChoiceOptionItem > 
)
inline

Updates an option at a specified index.

Parameters
indexnumber - The index of the option to update.
itemOptionsPartial<ChoiceOptionItem> - The new values for the option.
Returns
Promise<void> - Resolves when the option is updated.
Since
11.0.0

Foxit Software Corporation Logo
@2025 Foxit Software Incorporated. All rights reserved.