FoxitPDFSDKforWeb  v10.0.0
Foxit PDF SDK for Web
PDFField Class Reference
Inheritance diagram for PDFField:
PDFSignature

Public Member Functions

 getAlignment ()
 Get field's alignment. More...
 
 getAlternateName ()
 Get alternate name. More...
 
 getBorderColor ()
 Get field's border color. More...
 
 getBorderStyle ()
 Get field's border style. More...
 
 getControlByIndex (index)
 Get field's control by index. Please call PDFField.getControlsCount() to get count. More...
 
 getControlsCount ()
 Get the count of field's controls. More...
 
 getDAFontSize ()
 Get default appearance's font size. More...
 
 getFillColor ()
 Get field's fill color. More...
 
 getFlags ()
 Get field's flags. For more information, refer to Field_Flag. More...
 
 getMappingName ()
 Get mapping name. More...
 
 getMaxLength ()
 Get text field's max length. More...
 
 getName ()
 Get form field's name(aka title). More...
 
 getOptions ()
 Set combo box and list box's options. More...
 
 getType ()
 Get form field's type. More...
 
 getValue ()
 Get field value. More...
 
 setAction (trigger, action)
 Set field's action. More...
 
 setAlignment (alignment)
 Set field's alignment(Not support signature field). More...
 
 setAlternateName (alternateName)
 Set alternate name. More...
 
 setBorderColor (borderColor)
 Set field's border color(Not support signature field). More...
 
 setBorderStyle (strStyle)
 Set field's border style(Not support signature field). More...
 
 setFillColor (fillColor)
 Set field's fillColor(Not support signature field). More...
 
 setFlags (flags)
 Set field's flags. More...
 
 setMappingName (mappingName)
 Set mapping name. (Not support signature field). More...
 
 setMaxLength (maxLength)
 Set text field's max length. More...
 
 setOptions (options)
 Set options(items) of list box or combo box. More...
 
 setValue (value='', control=null)
 Set field's value. More...
 

Detailed Description

PDF Form Field object

Since
7.1.0

Member Function Documentation

◆ getAlignment()

PDFField::getAlignment ( )
inline

Get field's alignment.

Returns
number - The alignment value. Please Refer to Alignment.

◆ getAlternateName()

PDFField::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
string - The alternate name.

◆ getBorderColor()

PDFField::getBorderColor ( )
inline

Get field's border color.

Note
Load all relative annotations before call this function, or wrong value will return.
Returns
number - An integer indicating border color will be returned.

◆ getBorderStyle()

PDFField::getBorderStyle ( )
inline

Get field's border style.

Note
Load all relative annotations before call this function, or wrong value will be returned.
Returns
string - Border style, should be one of 'solid','dashed','inset','beveled','underline'. Nothing will be done with invalid string

◆ getControlByIndex()

PDFField::getControlByIndex (   index)
inline

Get field's control by index. Please call PDFField.getControlsCount() to get count.

Parameters
indexnumber - Index of the control.
Returns
PDFControl - PDFControl.
Since
7.5.0

◆ getControlsCount()

PDFField::getControlsCount ( )
inline

Get the count of field's controls.

Returns
number - Count of field's controls.
Since
7.5.0

◆ getDAFontSize()

PDFField::getDAFontSize ( )
inline

Get default appearance's font size.

let fieldname = 'ComboBox0'
let pdfviewer = await pdfui.getPDFViewer()
let field = pdfviewer.getPDFDocRender().getPDFDoc().getPDFForm().getField(fieldname)
field.getDAFontSize()
Returns
number - Font size.

◆ getFillColor()

PDFField::getFillColor ( )
inline

Get field's fill color.

Note
Load all relative annotations before call this function, or wrong value will return.
Returns
number - An integer indicating border color will be returned.

◆ getFlags()

PDFField::getFlags ( )
inline

Get field's flags. For more information, refer to Field_Flag.

Returns
number - Field's flags.

◆ getMappingName()

PDFField::getMappingName ( )
inline

Get mapping name.

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

Returns
string - The mapping name.
Since
9.1.0

◆ getMaxLength()

PDFField::getMaxLength ( )
inline

Get text field's max length.

Returns
number - Field's max length.

◆ getName()

PDFField::getName ( )
inline

Get form field's name(aka title).

Returns
string - Form field's name

◆ getOptions()

PDFField::getOptions ( )
inline

Set combo box and list box's options.

Returns
Array<{label:string,value:string}> - Field's options array. Such as:
[
{
label:"label0",
value:"value0"
},{
label:"label1",
value:"value1"
},
...
]

◆ getType()

PDFField::getType ( )
inline

Get form field's type.

Returns
number - Form field's type. Please refer to Field_Type

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

◆ getValue()

PDFField::getValue ( )
inline

Get field value.

Returns
string - Field's value

◆ setAction()

PDFField::setAction (   trigger,
  action 
)
inline

Set field's action.

Parameters
triggernumber - The trigger of action. Please refer to Action_Trigger.
actionstring|Action - Action or string. If it is a string, it must be valid JavaScript..
Returns
Promise<void>

◆ setAlignment()

PDFField::setAlignment (   alignment)
inline

Set field's alignment(Not support signature field).

Parameters
alignmentnumber - Alignment. Please Refer to Alignment.
Returns
Promise<void>

◆ setAlternateName()

PDFField::setAlternateName (   alternateName)
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
9.1.0

◆ setBorderColor()

PDFField::setBorderColor (   borderColor)
inline

Set field's border color(Not support signature field).

Note
Load all relative annotations before call this function, or wrong value will return.
Parameters
borderColornumber|[string,number,number,number]|string - Border color for field. Supported color format:
  • number, such as 0xff0000, 16711680
  • PDF color array, such as ['RGB',1,1,1] which means white. Range: 0.0~1.0, The ratio to HTML color format is 1:255.
  • HTML color format, such as '#ff0000', 'rgb(255,0,0)', 'rgba(255,0,0,1)'
Returns
Promise<boolean> - true for success, false for failed

◆ setBorderStyle()

PDFField::setBorderStyle (   strStyle)
inline

Set field's border style(Not support signature field).

Note
Load all relative annotations before call this function, or wrong value will return.
Parameters
stylestring - Border style, should be one of 'solid','dashed','inset','beveled'. Nothing will be done with invalid string
Returns
Promise<void> -

◆ setFillColor()

PDFField::setFillColor (   fillColor)
inline

Set field's fillColor(Not support signature field).

Note
Load all relative annotations before call this function, or wrong value will return.
Parameters
fillColornumber|['T']|[string,number,number,number]|string - Specify fill color for field (alpha is not supported). Supported color format:
  • 0 or ['T'] for transparent
  • number, such as 0xff0000, 16711680
  • PDF color array, such as ['RGB',1,1,1] which means white. Range: 0.0~1.0, The ratio to HTML color format is 1:255.
  • HTML color format, such as '#ff0000', 'rgb(255,0,0)', 'rgba(255,0,0,1)'
Returns
Promise<void>

◆ setFlags()

PDFField::setFlags (   flags)
inline

Set field's flags.

Parameters
flagsnumber - New form field flags. Please refer to Field_Flag, and this should be one or a combination of these values
let fieldname = 'Check Box0'
let pdfviewer = await pdfui.getPDFViewer()
let field = pdfviewer.getPDFDocRender().getPDFDoc().getPDFForm().getField(fieldname)
let Field_Flag = PDFViewCtrl.PDF.form.constant.Field_Flag
field.setFlags(Field_Flag.ReadOnly | Field_Flag.Required)
Since
8.0.0

◆ setMappingName()

PDFField::setMappingName (   mappingName)
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.
Since
9.1.0

◆ setMaxLength()

PDFField::setMaxLength (   maxLength)
inline

Set text field's max length.

Parameters
maxLengthnumber - Max length to be set to field.

◆ setOptions()

PDFField::setOptions (   options)
inline

Set options(items) of list box or combo box.

Applicable for list box and combo box. For field types that are not applicable, this function will do nothing.

Parameters
optionsArray<{label:string,value:string,selected:boolean,defaultSelected:boolean}> - An array of options which is to be set to list box or combo box.
[
{
label:"label0",
value:"value0",
selected:true,
defaultSelected:true
},{
label:"label1",
value:"value1",
selected:false,
defaultSelected:false
},
...
]
Returns
Promise<void>

◆ setValue()

PDFField::setValue (   value = '',
  control = null 
)
inline

Set field's value.

Note
Applicable for all fields except push button and signature. For field types that are not applicable, nothing will be done. This function will not trigger calculation action. If application want trigger it, please call PDFForm::calculate(). For combo box, application should validate new value: for editable combo box, value could be any string; for uneditable combo box, only value in options array are valid.
Parameters
valuestring - Field's value to be set.
controlAnnot - Widget annot which trigger this event.

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