FoxitPDFSDKforWeb  8.5.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...
 
 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...
 
 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...
 
 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 indicated 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
index{number} - 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 indicated 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.

◆ getMaxLength()

PDFField::getMaxLength ( )
inline

Get text field's max length.

Returns
{Array[string]} - 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[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
trigger{number} - The trigger of action. Please refer to Action_Trigger.
action{string|Action} - Action or string. If it is a string, it must be valid JavaScript..
Returns
{Promise<*>}

◆ setAlignment()

PDFField::setAlignment (   alignment)
inline

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

Parameters
alignment{number} - Alignment. Please Refer to Alignment.
Returns
{Promise.<*>}

◆ 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
borderColor{Array[T]} - Border color for field. Supported color format:
  • number, such as 0xff0000, 16711680
  • PDF color array, such as ['RGB',1,1,1] which means white..
  • 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
style{string} - Border style, should be one of 'solid','dashed','inset','beveled'. Nothing will be done with invalid string
Returns
{Promise.<*>}

◆ 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
fillColor{*} - 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..
  • HTML color format, such as '#ff0000', 'rgb(255,0,0)', 'rgba(255,0,0,1)'
Returns
{Promise.<*>}

◆ setFlags()

PDFField::setFlags (   flags)
inline

Set field's flags.

Parameters
{number}- 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

◆ setMaxLength()

PDFField::setMaxLength (   maxLength)
inline

Set text field's max length.

Parameters
maxLength{number} - 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
options{Array[Object]} - 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
None.

◆ 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
value{string} - Field's value to be set.
control{Annot} - Widget annot which trigger this event.

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