Foxit PDF SDK
foxit.pdf.interform.Field Class Reference
Inheritance diagram for foxit.pdf.interform.Field:
foxit.common.Base foxit.pdf.Signature

Public Types

enum  Flags {
  Flags.e_FlagReadOnly = 0x01, Flags.e_FlagRequired = 0x02, Flags.e_FlagNoExport = 0x04, Flags.e_FlagButtonNoToggleToOff = 0x100,
  Flags.e_FlagButtonRadiosInUnison = 0x200, Flags.e_FlagTextMultiline = 0x100, Flags.e_FlagTextPassword = 0x200, Flags.e_FlagTextDoNotScroll = 0x400,
  Flags.e_FlagTextComb = 0x800, Flags.e_FlagComboEdit = 0x100, Flags.e_FlagChoiseMultiSelect = 0x100
}
 Enumeration for form field flags. More...
 
enum  Type {
  Type.e_TypeUnknown = 0, Type.e_TypePushButton = 1, Type.e_TypeCheckBox = 2, Type.e_TypeRadioButton = 3,
  Type.e_TypeComboBox = 4, Type.e_TypeListBox = 5, Type.e_TypeTextField = 6, Type.e_TypeSignature = 7
}
 Enumeration for form field type. More...
 

Public Member Functions

 Field (PDFDoc document, PDFDictionary field_dict)
 Constructor, from field dictionary. More...
 
 Field (Field field)
 Constructor, with another form field object. More...
 
Alignment GetAlignment ()
 Get the alignment value. More...
 
string GetAlternateName ()
 Get alternate name. More...
 
Control GetControl (int index)
 Get a form control by index. More...
 
Control GetControl (PDFPage page, int index)
 Get a form control by index, in a specified PDF page. More...
 
int GetControlCount ()
 Get count of form controls. More...
 
int GetControlCount (PDFPage page)
 Get count of form controls in a specified PDF page. More...
 
DefaultAppearance GetDefaultAppearance ()
 Get the default appearance data. More...
 
string GetDefaultValue ()
 Get default value. More...
 
PDFObject GetDefaultValueObj ()
 Get the PDF object of field's default value. More...
 
PDFDictionary GetDict ()
 Get the PDF dictionary of current object. More...
 
int GetFlags ()
 Get field flags. More...
 
PDFObject GetInheritedAttribute (string attribute_name)
 Get the PDF object for specified attribute which may be inherited from the ancestor node in the field tree. More...
 
string GetMappingName ()
 Get mapping name. More...
 
int GetMaxLength ()
 Get maximum length of the field's text, in characters. More...
 
string GetName ()
 Get field name. More...
 
ChoiceOptionArray GetOptions ()
 Get options of list box or combo box. More...
 
int GetTopVisibleIndex ()
 Get top index of option for scrollable list boxes. More...
 
Field.Type GetType ()
 Get field type. More...
 
string GetValue ()
 Get value. More...
 
PDFObject GetValueObj ()
 Get the PDF object of field's value. More...
 
bool IsEmpty ()
 Check whether current object is empty or not. More...
 
bool Reset ()
 Reset data in current field to its default value. (Not support signature field) More...
 
void SetAlignment (Alignment alignment)
 Set alignment property of a form, as a document-wide default value. (Not support signature field) More...
 
void SetAlternateName (string alternate_name)
 Set alternate name. (Not support signature field) More...
 
void SetDefaultAppearance (DefaultAppearance default_ap)
 Set default appearance data. More...
 
void SetDefaultValue (string value)
 Set default value. More...
 
void SetFlags (int flags)
 Set field flags. More...
 
void SetMappingName (string name)
 Set mapping name. (Not support signature field) More...
 
void SetMaxLength (int max_length)
 Set maximum length of the field's text, in characters. More...
 
void SetOptions (ChoiceOptionArray option_array)
 Set options of list box or combo box. More...
 
void SetTopVisibleIndex (int index)
 Set top index for scrollable list boxes. More...
 
void SetValue (string value)
 Set value. More...
 

Detailed Description

In a PDF document, form fields appear on any combination of pages and all of them make up a single, global interactive form spanning the entire document. Function Form.GetField can use to get a form field from interactive form. This class offers functions to get some information/properties of a form field, reset the form field to its default value, and get form control from form field.
When a form fiels's type is foxit.pdf.interform.Field.Type.e_TypeSignature , the form field object is a signature object in fact.
To access additional actions, please construct an foxit.pdf.actions.AdditionalAction object with Field object.

See also
Form
foxit.pdf.Signature
foxit.pdf.actions.AdditionalAction

Member Enumeration Documentation

◆ Flags

Enumeration for form field flags.

Values of this enumeration can be used alone or in a combination.

Enumerator
e_FlagReadOnly 

If set, the user may not change the value of the field. Any associated widget annotations will not interact with the user; that is, they will not respond to mouse clicks or change their appearance in response to mouse motions. This flag is useful for fields whose values are computed or imported from a database.

e_FlagRequired 

If set, the field must have a value at the time it is exported by a submit-form action.

e_FlagNoExport 

if set, the field must not be exported by a submit-form action.

e_FlagButtonNoToggleToOff 

(Only useful for radio button) If set, exactly one radio button must be selected at all times; clicking the currently selected button has no effect. If clear, clicking the selected button deselects it, leaving no button selected.

e_FlagButtonRadiosInUnison 

(Only useful for radio button) If set, a group of radio buttons within a radio button field that use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked. If clear, the buttons are mutually exclusive.

e_FlagTextMultiline 

(Only useful for text field) If set, the text field can contain multiple lines of text; if clear, the field's text is restricted to a single line.

e_FlagTextPassword 

(Only useful for text field) If set, the field is intended for entering a secure password that should not be echoed visibly to the screen. Characters typed from the keyboard should instead be echoed in some unreadable form, such as asterisks or bullet characters.

Note
To protect password confidentiality, viewer applications should never store the value of the text field in the PDF file if this flag is set.
e_FlagTextDoNotScroll 

(Only useful for text field) If set, the field does not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle. Once the field is full, no further text is accepted.

e_FlagTextComb 

(Only useful for text field) If set, use combs.

If set, the field is automatically divided into as many equally spaced positions, or combs, as the value of maximum length of a field's text, and the text is laid out into those combs.

e_FlagComboEdit 

(Only useful for combo box) If set, the combo box includes an editable text control with a drop-down list, if clear, it includes only a drop-down list.

e_FlagChoiseMultiSelect 

(Only useful for combo box and list box) If set, more than one items may be selected simultaneously; if clear, no more than one item at a time may be selected.

◆ Type

Enumeration for form field type.

Values of this enumeration should be used alone.

Enumerator
e_TypeUnknown 

Form field type: unknown.

e_TypePushButton 

Form field type: push button.

e_TypeCheckBox 

Form field type: check box.

e_TypeRadioButton 

Form field type: radio button.

e_TypeComboBox 

Form field type: combo box.

e_TypeListBox 

Form field type: list box.

e_TypeTextField 

Form field type: text field.

e_TypeSignature 

Form field type: signature field.

Constructor & Destructor Documentation

◆ Field() [1/2]

foxit.pdf.interform.Field.Field ( PDFDoc  document,
PDFDictionary  field_dict 
)
inline

Constructor, from field dictionary.

Parameters
[in]documentA valid PDF document.
[in]field_dictA PDF dictionary which represents a form field. It should belong to the PDF document specified by parameter document;

◆ Field() [2/2]

foxit.pdf.interform.Field.Field ( Field  field)
inline

Constructor, with another form field object.

Parameters
[in]fieldAnother form field object.

Member Function Documentation

◆ GetAlignment()

Alignment foxit.pdf.interform.Field.GetAlignment ( )
inline

Get the alignment value.

Alignment is a property for variable text and it is only useful for text field and list box, which may contain variable text as their content.
If a text field or list box has its own alignment value, the document-wide default alignment value will be ignored; otherwise, the document-wide default alignment value will be used for the text field or list box.

Returns
The alignment value. Please refer to values starting from foxit.common.Alignment.e_AlignmentLeft and this would be one of these values.

◆ GetAlternateName()

string foxit.pdf.interform.Field.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.

Returns
The alternate name.

◆ GetControl() [1/2]

Control foxit.pdf.interform.Field.GetControl ( int  index)
inline

Get a form control by index.

Parameters
[in]indexForm control index. Valid range: from 0 to (count-1). count is returned by function Field.GetControlCount .
Returns
A form control object.

◆ GetControl() [2/2]

Control foxit.pdf.interform.Field.GetControl ( PDFPage  page,
int  index 
)
inline

Get a form control by index, in a specified PDF page.

Parameters
[in]pageA valid PDF page object. It should be in the same document as current form field.
[in]indexForm control index. Valid range: from 0 to (count-1). count is returned by function Field.GetControlCount with same parameter page.
Returns
form control object.

◆ GetControlCount() [1/2]

int foxit.pdf.interform.Field.GetControlCount ( )
inline

Get count of form controls.

Returns
The count of the form controls.

◆ GetControlCount() [2/2]

int foxit.pdf.interform.Field.GetControlCount ( PDFPage  page)
inline

Get count of form controls in a specified PDF page.

Parameters
[in]pageA valid PDF page object. It should be in the same document as current form field.
Returns
The count of the form controls in the specified PDF page.

◆ GetDefaultAppearance()

DefaultAppearance foxit.pdf.interform.Field.GetDefaultAppearance ( )
inline

Get the default appearance data.

Returns
The default appearance data.

◆ GetDefaultValue()

string foxit.pdf.interform.Field.GetDefaultValue ( )
inline

Get default value.

Applicable for all fields except push button. For field types that are not applicable, an empty string will be returned.

Returns
Default value string.

◆ GetDefaultValueObj()

PDFObject foxit.pdf.interform.Field.GetDefaultValueObj ( )
inline

Get the PDF object of field's default value.

The format of field's default value varies depending on the field type. For more details, please refer to "TABLE 8.69 Entries common to all field dictionaries" in <PDF reference 1.7> P676.

Returns
A PDF object.

◆ GetDict()

PDFDictionary foxit.pdf.interform.Field.GetDict ( )
inline

Get the PDF dictionary of current object.

Returns
The PDF dictionary of current object.

◆ GetFlags()

int foxit.pdf.interform.Field.GetFlags ( )
inline

Get field flags.

Field flags specifies various characteristics of a form field.

Returns
Form field flags. Please refer to values starting from foxit.pdf.interform.Field.Flags.e_FlagReadOnly and this would be one or a combination of these values.

◆ GetInheritedAttribute()

PDFObject foxit.pdf.interform.Field.GetInheritedAttribute ( string  attribute_name)
inline

Get the PDF object for specified attribute which may be inherited from the ancestor node in the field tree.

Some of the field attributes are designated as inheritable, such as "Ff", "V", "DV", and so on. Please refer to "TABLE 8.69 Entries common to all field dictionaries" in <PDF Reference 1.7> P675.

Parameters
[in]attribute_nameThe name of attribute to be found.
Returns
A PDF object. If not found, this function will return null.

◆ GetMappingName()

string foxit.pdf.interform.Field.GetMappingName ( )
inline

Get mapping name.

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

Returns
The mapping name.

◆ GetMaxLength()

int foxit.pdf.interform.Field.GetMaxLength ( )
inline

Get maximum length of the field's text, in characters.

Applicable for text fields. For field types that are not applicable, this function will return 0.

Returns
The maximum length of the field's text.

◆ GetName()

string foxit.pdf.interform.Field.GetName ( )
inline

Get field name.

Returns
Field name string.

◆ GetOptions()

ChoiceOptionArray foxit.pdf.interform.Field.GetOptions ( )
inline

Get options of list box or combo box.

Applicable for list box and combo box. For field types that are not applicable, this function will return an empty array.

Returns
An array that contains the options.

◆ GetTopVisibleIndex()

int foxit.pdf.interform.Field.GetTopVisibleIndex ( )
inline

Get top index of option for scrollable list boxes.

Applicable for list box. For field types that are not applicable, this function will return 0.
Top index of option is the the index of the first option visible in the list.

Returns
The index of first item which is in visible scope of list box.

◆ GetType()

Field.Type foxit.pdf.interform.Field.GetType ( )
inline

Get field type.

Returns
Form field type. Please refer to values starting from foxit.pdf.interform.Field.Type.e_TypeUnknown and this would be one of these values.

◆ GetValue()

string foxit.pdf.interform.Field.GetValue ( )
inline

Get value.

Applicable for all fields except push button. For field types that are not applicable, an empty string will be returned.

Returns
Value string. Specially, when current field is a list box field with multiple values, only the first value would be returned.

◆ GetValueObj()

PDFObject foxit.pdf.interform.Field.GetValueObj ( )
inline

Get the PDF object of field's value.

The format of field's value varies depending on the field type. For more details, please refer to "TABLE 8.69 Entries common to all field dictionaries" in <PDF reference 1.7> P676.

Returns
A PDF object.

◆ IsEmpty()

bool foxit.pdf.interform.Field.IsEmpty ( )
inline

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ Reset()

bool foxit.pdf.interform.Field.Reset ( )
inline

Reset data in current field to its default value. (Not support signature field)

Returns
true means success, while false means current form field is a signature field or failure.

◆ SetAlignment()

void foxit.pdf.interform.Field.SetAlignment ( Alignment  alignment)
inline

Set alignment property of a form, as a document-wide default value. (Not support signature field)

Alignment is a property for variable text and it is only useful for text field and list box, which may contain variable text as their content.
If a text field or list box has its own alignment value, the document-wide default alignment value will be ignored; otherwise, the document-wide default alignment value will be used for the text field or list box.
If current form field is a signature field, this function will do nothing.

Parameters
[in]alignmentThe new default alignment type of variable text. Please refer to values starting from foxit.common.Alignment.e_AlignmentLeft and this should be one of these values.
If other values is used to set, foxit.common.Alignment.e_AlignmentLeft will be used by default.
Returns
None.

◆ SetAlternateName()

void foxit.pdf.interform.Field.SetAlternateName ( string  alternate_name)
inline

Set alternate name. (Not support signature field)

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.
If current form field is a signature field, this function will do nothing.

Parameters
[in]alternate_nameA new alternate name string. It should not be an empty string.
Returns
None.

◆ SetDefaultAppearance()

void foxit.pdf.interform.Field.SetDefaultAppearance ( DefaultAppearance  default_ap)
inline

Set default appearance data.

Parameters
[in]default_apThe new default appearance. flags of input data can be used to decide which information is/are to be updated with the new data; for those no updated data, they will keep to use old data.
If text_size of input default appearance data is 0, that means the text size should be calculated automatically.
Returns
None.

◆ SetDefaultValue()

void foxit.pdf.interform.Field.SetDefaultValue ( string  value)
inline

Set default value.

Applicable for all fields except push button. For field types that are not applicable, this function will do nothing.

Parameters
[in]valueNew default value string. It should not be an empty string.
Returns
None.

◆ SetFlags()

void foxit.pdf.interform.Field.SetFlags ( int  flags)
inline

Set field flags.

Field flags specifies various characteristics of a form field.

Parameters
[in]flagsNew form field flags. Please refer to values starting from foxit.pdf.interform.Field.Flags.e_FlagReadOnly and this should be one or a combination of these values.
Returns
None.

◆ SetMappingName()

void foxit.pdf.interform.Field.SetMappingName ( string  name)
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
[in]nameNew mapping name string.It should not be an empty string.
Returns
None.

◆ SetMaxLength()

void foxit.pdf.interform.Field.SetMaxLength ( int  max_length)
inline

Set maximum length of the field's text, in characters.

Applicable for text fields. For field types that are not applicable, this function will do nothing.

Parameters
[in]max_lengthNew maximum length of the field's text. It should be non-negative.
Returns
None.

◆ SetOptions()

void foxit.pdf.interform.Field.SetOptions ( ChoiceOptionArray  option_array)
inline

Set options 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
[in]option_arrayAn array of options which is to be set to list box or combo box.
Returns
None.

◆ SetTopVisibleIndex()

void foxit.pdf.interform.Field.SetTopVisibleIndex ( int  index)
inline

Set top index for scrollable list boxes.

Applicable for list box. For field types that are not applicable, this function will do nothing.
Top index of option is the the index of the first option visible in the list.

Parameters
[in]indexThe index of the first option visible in the list.
Returns
None.

◆ SetValue()

void foxit.pdf.interform.Field.SetValue ( string  value)
inline

Set value.

Applicable for all fields except push button. For field types that are not applicable, this function will do nothing.
Specially, for combo box and text field, when setting value successfully, this function will also trigger related calculation and formatting events and update the appearance of the field.

Parameters
[in]valueNew value string. Specially, when current field is a list box field, this parameter can contain multiple values:
When to set multiple values, each value should be wrapped by "()". For example, "(ABC)(CCC)" means to set 2 value "ABC" and "CCC".
If a value contains "()", or "\\" as its content, please add an additional "\\" as an escape character just in front of each character of "()" or "\\". For example:
  • "ABC" means to set the value "ABC".

  • "(ABC)" means to set the value "ABC".

  • "(ABC" means to set the value "(ABC".

  • "(\\\\(ABC\\\\)\\\\(BBB\\\\)\\\\(CCC\\\\))" means to set the value "(ABC)(BBB)(CCC)".

  • "456\\\\\\\\" means to set the value "456\\".

  • "(\\\\(ABC\\\\))" means to set the value "(ABC)".

Returns
None.