Foxit PDF SDK

Public Member Functions | List of all members
com.foxit.sdk.pdf.interform.Form Class Reference
Inheritance diagram for com.foxit.sdk.pdf.interform.Form:

## Public Member Functions
| Form (PDFDoc document) throws com.foxit.sdk.PDFException
| Constructor, with PDF document. More...
| Form (Form other)
| Constructor, with another form object. More...
Control | addControl (PDFPage page, String field_name, int field_type, RectF rect) throws com.foxit.sdk.PDFException
| Add a new form control to a specified form field. If the form field does not exist, this function will add a form field as well. (Not support signature field) More...
synchronized void | delete ()
| Clean up related C++ resources immediately. More...
boolean | exportToCSV (String csv_file_path, String pdf_file_name, boolean is_append) throws com.foxit.sdk.PDFException
| Export the form data to a CSV file. More...
boolean | exportToCSV (StreamCallback csv_file, String pdf_file_name, boolean is_append) throws com.foxit.sdk.PDFException
| Export the form data to a CSV file. More...
boolean | exportToHTML (String html_file_path, FieldArray field_array, boolean is_include) throws com.foxit.sdk.PDFException
| Export data of specified form fields to an HTML file. More...
boolean | exportToHTML (FileWriterCallback html_file, FieldArray field_array, boolean is_include) throws com.foxit.sdk.PDFException
| Export data of specified form fields to an HTML file. More...
boolean | exportToTXT (String txt_file_path, FieldArray field_array, boolean is_include) throws com.foxit.sdk.PDFException
| Export data of specified form fields to a TXT file. More...
boolean | exportToTXT (FileWriterCallback txt_file, FieldArray field_array, boolean is_include) throws com.foxit.sdk.PDFException
| Export data of specified form fields to a TXT file. More...
boolean | exportToXML (String file_path) throws com.foxit.sdk.PDFException
| Export the form data to an XML file. More...
boolean | exportToXML (String file_path, FieldArray field_array, boolean is_include) throws com.foxit.sdk.PDFException
| Export data of specified form fields to an XML file. More...
boolean | exportToXML (FileWriterCallback xml_file, FieldArray field_array, boolean is_include) throws com.foxit.sdk.PDFException
| Export data of specified form fields to an XML file. More...
void | fixPageFields (int page_index) throws com.foxit.sdk.PDFException
| Fix the fields which are in a PDF page but cannot be counted by current form object. More...
int | getAlignment () throws com.foxit.sdk.PDFException
| Get the alignment value which is used as document-wide default value. More...
Control | getControl (PDFPage page, int index) throws com.foxit.sdk.PDFException
| Get a form control by index, in a specified PDF page. More...
Control | getControlAtDevicePoint (PDFPage page, PointF point, float tolerance, int type, Matrix2D matrix) throws com.foxit.sdk.PDFException
| Get the form control at a specified position, in device coordinate system. More...
Control | getControlAtPoint (PDFPage page, PointF point, float tolerance, int type) throws com.foxit.sdk.PDFException
| Get the form control at a specified position, in PDF coordinate system. More...
int | getControlCount (PDFPage page) throws com.foxit.sdk.PDFException
| Get count of form controls in a specified PDF page. More...
DefaultAppearance | getDefaultAppearance () throws com.foxit.sdk.PDFException
| Get the default appearance data. More...
PDFDictionary | getDict () throws com.foxit.sdk.PDFException
| Get the dictionary of current object. More...
PDFDoc | getDocument () throws com.foxit.sdk.PDFException
| Get the PDF document, with which current form object is associated. More...
Field | getField (int index, String filter) throws com.foxit.sdk.PDFException
| Get a form field by index, whose names satisfy the specified name filter. More...
int | getFieldCount (String filter) throws com.foxit.sdk.PDFException
| Get the count of form fields, whose names satisfy the specified name filter. More...
FieldArray | getFieldsInCalculationOrder () throws com.foxit.sdk.PDFException
| Get an array of form fields in calculation order. More...
Filler | getFormFiller () throws com.foxit.sdk.PDFException
| Get the form filler. More...
boolean | importFromXML (String file_path) throws com.foxit.sdk.PDFException
| Import the form data from an XML file. More...
boolean | isEmpty ()
| Check whether current object is empty or not. More...
boolean | moveControl (Control control, String field_name) throws com.foxit.sdk.PDFException
| Move the control to a field specified by field name. More...
boolean | needConstructAppearances () throws com.foxit.sdk.PDFException
| Check whether to construct appearance when loading form controls. More...
void | removeControl (Control control) throws com.foxit.sdk.PDFException
| Remove a form control. (Not support to remove a form control from a signature field) More...
void | removeField (Field field) throws com.foxit.sdk.PDFException
| Remove a form field. (Not support signature field) More...
boolean | renameField (Field field, String new_field_name) throws com.foxit.sdk.PDFException
| Rename a field with a new name. More...
boolean | reset () throws com.foxit.sdk.PDFException
| Reset data of all fields (except signature fields) to their default value. More...
void | setAlignment (int alignment) throws com.foxit.sdk.PDFException
| Set alignment value which is used as document-wide default value. More...
void | setConstructAppearances (boolean need_construct) throws com.foxit.sdk.PDFException
| Set a flag that specifies whether to construct appearances when loading form controls. More...
void | setDefaultAppearance (DefaultAppearance default_ap) throws com.foxit.sdk.PDFException
| Set default appearance data. More...
void | setFieldsInCalculationOrder (FieldArray field_array) throws com.foxit.sdk.PDFException
| Set an array of form fields in calculation order. More...
boolean | validateFieldName (int type, String field_name) throws com.foxit.sdk.PDFException
| Validate whether a field name can be used for a new field in specified field type. More...
Public Member Functions inherited from com.foxit.sdk.common.Base
synchronized void | delete ()
| Clean up related C++ resources immediately. More...

## Detailed Description

An interactive form – sometimes referred to as an AcroForm – is a collection of fields for gathering information interactively from the user. A PDF document may contain any number of fields appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document. Arbitrary subsets of these fields can be imported or exported from the document.
Function pdf.PDFDoc.hasForm can be used to judge if a PDF document has interactive form.
A form object can be constructed form a specified PDF document. This class offers functions to retrieve form fields or form controls, import/export form data and other features. For example:

- To retrieve form fields, please use functions Form.getFieldCount and Form.getField .

- To retrieve form controls from a PDF page, please use functions Form.getControlCount and Form.getControl .

- To import form data from an XML file, please use function Form.importFromXML ; to export form data to an XML file, please use function Form.exportToXML .

- To retrieve form filler object, please use function Form.getFormFiller .

To import form data from a FDF/XFDF file or export such data to a FDF/XFDF file, please refer to functions pdf.PDFDoc.importFromFDF and pdf.PDFDoc.exportToFDF .
To fill the form, please construct a form filler object by current form object or retrieve the filler object by function Form.getFormFiller if such object has been constructed. (There should be only one form filler object for an interactive form).

See also
  com.foxit.sdk.pdf.PDFDoc
  Filler

## Constructor & Destructor Documentation

## ◆ Form() [1/2]

com.foxit.sdk.pdf.interform.Form.Form | ( | PDFDoc | document | ) | throws com.foxit.sdk.PDFException

Constructor, with PDF document.

If PDF document does not have AcroForm, this constructor will add an empty AcroForm to the PDF document in order that new fields can be added to the PDF document later.

Parameters

  [in] | document | A valid PDF document.

## ◆ Form() [2/2]

com.foxit.sdk.pdf.interform.Form.Form | ( | Form | other | ) |

Constructor, with another form object.

Parameters

  [in] | other | Another form object.

## Member Function Documentation

## ◆ addControl()

Control com.foxit.sdk.pdf.interform.Form.addControl | ( | PDFPage | page,
|  | String | field_name,
|  | int | field_type,
|  | RectF | rect
| ) |  | throws com.foxit.sdk.PDFException

Add a new form control to a specified form field. If the form field does not exist, this function will add a form field as well. (Not support signature field)

Application can use this function to add a new form control:

- If the specified form field exists, a new form control will be created and set to the field.

- If the specified form field does not exist, a new form field will be created according to parameter field_name and field_type and added to form, along with a newly created form control.

Whether a form field exists or not, it will be judged with input parameters field_name and field_type.
If user wants to add a new signature field, please use function pdf.PDFPage.addSignature instead of current function.
The newly added form control has no appearance, so user should use setting methods in class Control or in related pdf field or widget annotation to set properties which will affect appearance. Some setting methods of class com.foxit.sdk.pdf.interform.Control and Field may directly update appearance, but functionannots.Annot.resetAppearanceStream of related widget annotation is still recommended to be called to ensure the appearance will indeed be updated.
For push button, check box, radio button, if user calls function annots.Annot.resetAppearanceStream directly without setting any properties, the default appearance style will be used:

- push button: In related widget annotation, background color (in the MK dictionary) = 0xC0C0C0, highlighting mode = com.foxit.sdk.pdf.annots.Annot.e_HighlightingPush .

- check box/radio button: In related widget annotation, border width = 1.0, border style = com.foxit.sdk.pdf.annots.BorderInfo.e_Solid , background color (in the MK dictionary) = 0xFFFFFF, border color (in the MK dictionary) = 0xFFFFFF.

Parameters

  [in] | page | A valid PDF page, in which the new form control will be added. It should belong to the same PDF document as current form.
  [in] | field_name | Field name. It should not be an empty string.
  [in] | field_type | Field type. Please refer to values starting from com.foxit.sdk.pdf.interform.Field.e_TypePushButton and this should be one of these values except com.foxit.sdk.pdf.interform.Field.e_TypeSignature . If this is com.foxit.sdk.pdf.interform.Field.e_TypeSignature , this function will throw exception com.foxit.sdk.common.Constants.e_ErrUnsupported .
  [in] | rect | Rectangle of the new form control which specifies the position in PDF page. It should be in [PDF coordinate system] (com.foxit.sdk.pdf.PDFPage).

Returns
  The newly added form control object.

## ◆ delete()

synchronized void com.foxit.sdk.pdf.interform.Form.delete | ( |  | ) |

Clean up related C++ resources immediately.

Returns
  None.

Note
  Once this function is called, current object cannot be used anymore.

## ◆ exportToCSV() [1/2]

boolean com.foxit.sdk.pdf.interform.Form.exportToCSV | ( | String | csv_file_path,
|  | String | pdf_file_name,
|  | boolean | is_append
| ) |  | throws com.foxit.sdk.PDFException

Export the form data to a CSV file.

Parameters

  [in] | csv_file_path | A full file path of a CSV file. This specifies the CSV file that form data will be exported to. This should not be an empty string.
  [in] | pdf_file_name | File name of current PDF document. This file name will be written into the CSV file. This can be an empty string.
  [in] | is_append | A boolean value used to decide whether the form data is appended to the CSV file if the CSV file exists: true means to append form data to an existed CSV file, while false means not.

Returns
  true means success, while false means failure.

## ◆ exportToCSV() [2/2]

boolean com.foxit.sdk.pdf.interform.Form.exportToCSV | ( | StreamCallback | csv_file,
|  | String | pdf_file_name,
|  | boolean | is_append
| ) |  | throws com.foxit.sdk.PDFException

Export the form data to a CSV file.

Parameters

  [in] | csv_file | A com.foxit.sdk.common.fxcrt.StreamCallback object which is implemented by user to save form data to a CSV file. This should not be null. Please do not use append mode in writing callback functions.
  [in] | pdf_file_name | File name of current PDF document. This file name will be written into the CSV file. This can be an empty string.
  [in] | is_append | A boolean value used to decide whether the form data is appended to the CSV file if the CSV file exists: true means to append form data to an existed CSV file, while false means not.

Returns
  true means success, while false means failure.

## ◆ exportToHTML() [1/2]

boolean com.foxit.sdk.pdf.interform.Form.exportToHTML | ( | String | html_file_path,
|  | FieldArray | field_array,
|  | boolean | is_include
| ) |  | throws com.foxit.sdk.PDFException

Export data of specified form fields to an HTML file.

Parameters

  [in] | html_file_path | A full file path of an HTML file, to which data of specified form fields will be exported. This should not be an empty string.
  [in] | field_array | An array of form fields. Parameter is_include will decide whether data of these form fields are to exported or not. If this is an empty array, that means data of all form fields would be exported.
  [in] | is_include | A boolean value used to decide whether data of specified form fields are to be exported or not: true means data of specified form fields are to be exported, while false means data of specified form fields are not to be exported.

Returns
  true means success, while false means failure.

## ◆ exportToHTML() [2/2]

boolean com.foxit.sdk.pdf.interform.Form.exportToHTML | ( | FileWriterCallback | html_file,
|  | FieldArray | field_array,
|  | boolean | is_include
| ) |  | throws com.foxit.sdk.PDFException

Export data of specified form fields to an HTML file.

Parameters

  [in] | html_file | A com.foxit.sdk.common.fxcrt.FileWriterCallback object which is implemented by user to save data of specified form fields to an HTML file. This should not be null.
  [in] | field_array | An array of form fields. Parameter is_include will decide whether data of these form fields are to exported or not. If this is an empty array, that means data of all form fields would be exported.
  [in] | is_include | A boolean value used to decide whether data of specified form fields are to be exported or not: true means data of specified form fields are to be exported, while false means data of specified form fields are not to be exported.

Returns
  true means success, while false means failure.

## ◆ exportToTXT() [1/2]

boolean com.foxit.sdk.pdf.interform.Form.exportToTXT | ( | String | txt_file_path,
|  | FieldArray | field_array,
|  | boolean | is_include
| ) |  | throws com.foxit.sdk.PDFException

Export data of specified form fields to a TXT file.

Parameters

  [in] | txt_file_path | A full file path of a TXT file, to which data of specified form fields will be exported. This should not be an empty string.
  [in] | field_array | An array of form fields. Parameter is_include will decide whether data of these form fields are to exported or not. If this is an empty array, that means data of all form fields would be exported.
  [in] | is_include | A boolean value used to decide whether data of specified form fields are to be exported or not: true means data of specified form fields are to be exported, while false means data of specified form fields are not to be exported.

Returns
  true means success, while false means failure.

## ◆ exportToTXT() [2/2]

boolean com.foxit.sdk.pdf.interform.Form.exportToTXT | ( | FileWriterCallback | txt_file,
|  | FieldArray | field_array,
|  | boolean | is_include
| ) |  | throws com.foxit.sdk.PDFException

Export data of specified form fields to a TXT file.

Parameters

  [in] | txt_file | A com.foxit.sdk.common.fxcrt.FileWriterCallback object which is implemented by user to save data of specified form fields to a TXT file. This should not be null.
  [in] | field_array | An array of form fields. Parameter is_include will decide whether data of these form fields are to exported or not. If this is an empty array, that means data of all form fields would be exported.
  [in] | is_include | A boolean value used to decide whether data of specified form fields are to be exported or not: true means data of specified form fields are to be exported, while false means data of specified form fields are not to be exported.

Returns
  true means success, while false means failure.

## ◆ exportToXML() [1/3]

boolean com.foxit.sdk.pdf.interform.Form.exportToXML | ( | String | file_path | ) | throws com.foxit.sdk.PDFException

Export the form data to an XML file.

Parameters

  [in] | file_path | A full file_path of an XML file. This specifies the XML file that form data will be exported to.

Returns
  true means success, while false means failure.

## ◆ exportToXML() [2/3]

boolean com.foxit.sdk.pdf.interform.Form.exportToXML | ( | String | file_path,
|  | FieldArray | field_array,
|  | boolean | is_include
| ) |  | throws com.foxit.sdk.PDFException

Export data of specified form fields to an XML file.

Parameters

  [in] | file_path | A full file_path of an XML file, to which data of specified form fields will be exported.
  [in] | field_array | An array of form fields. Parameter is_include will decide whether data of these form fields are to exported or not. If this is an empty array, that means data of all form fields would be exported.
  [in] | is_include | A boolean value used to decide whether data of specified form fields are to be exported or not: true means data of specified form fields are to be exported, while false means data of specified form fields are not to be exported.

Returns
  true means success, while false means failure.

## ◆ exportToXML() [3/3]

boolean com.foxit.sdk.pdf.interform.Form.exportToXML | ( | FileWriterCallback | xml_file,
|  | FieldArray | field_array,
|  | boolean | is_include
| ) |  | throws com.foxit.sdk.PDFException

Export data of specified form fields to an XML file.

Parameters

  [in] | xml_file | A com.foxit.sdk.common.fxcrt.FileWriterCallback object which is implemented by user to save data of specified form fields to an XML file. This should not be null.
  [in] | field_array | An array of form fields. Parameter is_include will decide whether data of these form fields are to exported or not. If this is an empty array, that means data of all form fields would be exported.
  [in] | is_include | A boolean value used to decide whether data of specified form fields are to be exported or not: true means data of specified form fields are to be exported, while false means data of specified form fields are not to be exported.

Returns
  true means success, while false means failure.

## ◆ fixPageFields()

void com.foxit.sdk.pdf.interform.Form.fixPageFields | ( | int | page_index | ) | throws com.foxit.sdk.PDFException

Fix the fields which are in a PDF page but cannot be counted by current form object.

It may cost much time if there are many fields in the specified page.

Parameters

  [in] | page_index | The page index. Valid range: from 0 to (count-1). count is returned by function PDFDoc.getPageCount .

Returns
  None.

## ◆ getAlignment()

int com.foxit.sdk.pdf.interform.Form.getAlignment | ( |  | ) | throws com.foxit.sdk.PDFException

Get the alignment value which is used as document-wide default value.

Alignment is a property for variable text. It is only applicable for text field, list box and combo 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 value will be used for the text field or list box.

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

## ◆ getControl()

Control com.foxit.sdk.pdf.interform.Form.getControl | ( | PDFPage | page,
|  | int | index
| ) |  | throws com.foxit.sdk.PDFException

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

Parameters

  [in] | page | A valid PDF page object. It should belong to the same PDF document as current form.
  [in] | index | Index of form control to be retrieved. Valid range: from 0 to (count-1). count is returned by function Field.getControlCount with same parameter page.

Returns
  A form control object.

## ◆ getControlAtDevicePoint()

Control com.foxit.sdk.pdf.interform.Form.getControlAtDevicePoint | ( | PDFPage | page,
|  | PointF | point,
|  | float | tolerance,
|  | int | type,
|  | Matrix2D | matrix
| ) |  | throws com.foxit.sdk.PDFException

Get the form control at a specified position, in device coordinate system.

Parameters

  [in] | page | A valid PDF page object. It should be in the same document as current form.
  [in] | point | A position, in device coordinate system.
  [in] | tolerance | Tolerance value. Valid range: 0.0f to 30.0f.
  [in] | type | The field type whose form control will be retrieved. Please refer to values starting from com.foxit.sdk.pdf.interform.Field.e_TypeUnknown and this should be one of these values. com.foxit.sdk.pdf.interform.Field.e_TypeUnknown means not to care about the field type and just to retrieve the first form control at the specified position.
  [in] | matrix | A transformation matrix. Usually this is returned by function pdf.PDFPage.getDisplayMatrix . If this is null, current function will have the same feature as function Form.getControlAtPoint . Default value: null.

Returns
  A form control object. If the return value of function Control.isEmpty for the returned form control object is true, that means no suitable form control is around the specified position.

## ◆ getControlAtPoint()

Control com.foxit.sdk.pdf.interform.Form.getControlAtPoint | ( | PDFPage | page,
|  | PointF | point,
|  | float | tolerance,
|  | int | type
| ) |  | throws com.foxit.sdk.PDFException

Get the form control at a specified position, in PDF coordinate system.

Parameters

  [in] | page | A valid PDF page object. It should be in the same document as current form.
  [in] | point | A position, in PDF coordinate system.
  [in] | tolerance | Tolerance value. Valid range: 0.0f to 30.0f.
  [in] | type | The field type whose form control will be retrieved. Please refer to values starting from com.foxit.sdk.pdf.interform.Field.e_TypeUnknown and this should be one of these values. com.foxit.sdk.pdf.interform.Field.e_TypeUnknown means not to care about the field type and just to retrieve the first form control at the specified position.

Returns
  A form control object. If the return value of function Control.isEmpty for the returned form control object is true, that means no suitable form control is around the specified position.

## ◆ getControlCount()

int com.foxit.sdk.pdf.interform.Form.getControlCount | ( | PDFPage | page | ) | throws com.foxit.sdk.PDFException

Get count of form controls in a specified PDF page.

Parameters

  [in] | page | A valid PDF page object. It should belong to the same PDF document as current form.

Returns
  The count of the form controls in the specified PDF page.

## ◆ getDefaultAppearance()

DefaultAppearance com.foxit.sdk.pdf.interform.Form.getDefaultAppearance | ( |  | ) | throws com.foxit.sdk.PDFException

Get the default appearance data.

Returns
  The default appearance data.

## ◆ getDict()

PDFDictionary com.foxit.sdk.pdf.interform.Form.getDict | ( |  | ) | throws com.foxit.sdk.PDFException

Get the dictionary of current object.

Returns
  The dictionary of current object. If there is any error, this function will return null.

## ◆ getDocument()

PDFDoc com.foxit.sdk.pdf.interform.Form.getDocument | ( |  | ) | throws com.foxit.sdk.PDFException

Get the PDF document, with which current form object is associated.

Returns
  A PDF document object.

## ◆ getField()

Field com.foxit.sdk.pdf.interform.Form.getField | ( | int | index,
|  | String | filter
| ) |  | throws com.foxit.sdk.PDFException

Get a form field by index, whose names satisfy the specified name filter.

Parameters

  [in] | index | Index of form field to be retrieved. Valid range: from 0 to (count-1). count is returned by function Form.getFieldCount with same parameter filter.
  [in] | filter | A filter string. If this is an empty string, that means to count all form fields; if this is valid, that means to count those form fields whose names are partially matched parameter filter. For example, if parameter filter is "text1", the filter will match text1.0, text1.2.0, etc; but not match test10 or test11.1. Default value: an empty string.

Returns
  A form field object.

## ◆ getFieldCount()

int com.foxit.sdk.pdf.interform.Form.getFieldCount | ( | String | filter | ) | throws com.foxit.sdk.PDFException

Get the count of form fields, whose names satisfy the specified name filter.

Parameters

  [in] | filter | A filter string. If this is an empty string, that means to count all form fields; if this is valid, that means to count those form fields whose names are partially matched parameter filter. For example, if parameter filter is "text1", the filter will match text1.0, text1.2.0, etc; but not match test10 or test11.1. Default value: an empty string.

Returns
  The count of the form fields with specified name filter.

## ◆ getFieldsInCalculationOrder()

FieldArray com.foxit.sdk.pdf.interform.Form.getFieldsInCalculationOrder | ( |  | ) | throws com.foxit.sdk.PDFException

Get an array of form fields in calculation order.

The calculation order defines the order in which the values of fields will be recalculated when value of any field is changed. Usually, these fields have calculation actions.

Returns
  An array of form field in calculation order.

## ◆ getFormFiller()

Filler com.foxit.sdk.pdf.interform.Form.getFormFiller | ( |  | ) | throws com.foxit.sdk.PDFException

Get the form filler.

Returns
  The filler object. If the return value of function Filler.isEmpty for the returned filler object is true, that means form filler has not been constructed yet. For this case, please construct a filler with current form.

## ◆ importFromXML()

boolean com.foxit.sdk.pdf.interform.Form.importFromXML | ( | String | file_path | ) | throws com.foxit.sdk.PDFException

Import the form data from an XML file.

Parameters

  [in] | file_path | A full file_path of an existing XML file. This specifies the XML file that form data will be imported from.

Returns
  true means success, while false means failure.

## ◆ isEmpty()

boolean com.foxit.sdk.pdf.interform.Form.isEmpty | ( |  | ) |

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.

## ◆ moveControl()

boolean com.foxit.sdk.pdf.interform.Form.moveControl | ( | Control | control,
|  | String | field_name
| ) |  | throws com.foxit.sdk.PDFException

Move the control to a field specified by field name.

Operation of current function for different cases:

- If the field specified by field name does not exist, a new field will be created with the field name and the control will be moved to this new field.

- If the field specified by field name exists and the field type is same as the field that control currently belongs to, the control will be combined into this field.

- If the field specified by field name exists but the field type is different from the field that control currently belongs to, this function will throw exception com.foxit.sdk.common.Constants.e_ErrConflict .

Parameters

  [in] | control | A valid form control object.
  [in] | field_name | A field name. It should not be an empty string.

Returns
  true means success, while false means failure.

## ◆ needConstructAppearances()

boolean com.foxit.sdk.pdf.interform.Form.needConstructAppearances | ( |  | ) | throws com.foxit.sdk.PDFException

Check whether to construct appearance when loading form controls.

Returns
  true means to construct appearances when loading form controls, while false means not.

## ◆ removeControl()

void com.foxit.sdk.pdf.interform.Form.removeControl | ( | Control | control | ) | throws com.foxit.sdk.PDFException

Remove a form control. (Not support to remove a form control from a signature field)

If the specified form control is the only form control of related form field, the related form field will be removed as well.

Parameters

  [in] | control | A form control to be removed. If the field type of related form field is com.foxit.sdk.pdf.interform.Field.e_TypeSignature , this function will throw exception com.foxit.sdk.common.Constants.e_ErrUnsupported .

Returns
  None.

## ◆ removeField()

void com.foxit.sdk.pdf.interform.Form.removeField | ( | Field | field | ) | throws com.foxit.sdk.PDFException

Remove a form field. (Not support signature field)

If the form field appears on more than one PDF page, all representations will be removed.
If user wants to remove a signature field, please use function pdf.PDFDoc.removeSignature instead of current function.

Parameters

  [in] | field | A form field to be removed. If the field type is com.foxit.sdk.pdf.interform.Field.e_TypeSignature , this function will throw exception com.foxit.sdk.common.Constants.e_ErrUnsupported .

Returns
  None.

## ◆ renameField()

boolean com.foxit.sdk.pdf.interform.Form.renameField | ( | Field | field,
|  | String | new_field_name
| ) |  | throws com.foxit.sdk.PDFException

Rename a field with a new name.

Parameters

  [in] | field | A valid form field object.
  [in] | new_field_name | A new field name. It should not be an empty string.

Returns
  true means success, while false means failure.

## ◆ reset()

boolean com.foxit.sdk.pdf.interform.Form.reset | ( |  | ) | throws com.foxit.sdk.PDFException

Reset data of all fields (except signature fields) to their default value.

Returns
  true means success, while false means failure.

## ◆ setAlignment()

void com.foxit.sdk.pdf.interform.Form.setAlignment | ( | int | alignment | ) | throws com.foxit.sdk.PDFException

Set alignment value which is used as document-wide default value.

Alignment is a property for variable text. It is only applicable for text field, list box and combo 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 value will be used for the text field or list box.

Parameters

  [in] | alignment | The new default alignment type of variable text. Please refer to values starting from com.foxit.sdk.common.Constants.e_AlignmentLeft and this should be one of these values. If other values is used to set, com.foxit.sdk.common.Constants.e_AlignmentLeft will be used by default.

Returns
  None.

## ◆ setConstructAppearances()

void com.foxit.sdk.pdf.interform.Form.setConstructAppearances | ( | boolean | need_construct | ) | throws com.foxit.sdk.PDFException

Set a flag that specifies whether to construct appearances when loading form controls.

Parameters

  [in] | need_construct | true means to construct appearances when loading form controls, and false means not.

Returns
  None.

## ◆ setDefaultAppearance()

void com.foxit.sdk.pdf.interform.Form.setDefaultAppearance | ( | DefaultAppearance | default_ap | ) | throws com.foxit.sdk.PDFException

Set default appearance data.

Parameters

  [in] | default_ap | The 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.

## ◆ setFieldsInCalculationOrder()

void com.foxit.sdk.pdf.interform.Form.setFieldsInCalculationOrder | ( | FieldArray | field_array | ) | throws com.foxit.sdk.PDFException

Set an array of form fields in calculation order.

The calculation order defines the order in which the values of fields will be recalculated when value of any field is changed. Usually, these fields have calculation actions.

Parameters

  [in] | field_array | An array of form fields to specify the new calculation order.

Returns
  None.

## ◆ validateFieldName()

boolean com.foxit.sdk.pdf.interform.Form.validateFieldName | ( | int | type,
|  | String | field_name
| ) |  | throws com.foxit.sdk.PDFException

Validate whether a field name can be used for a new field in specified field type.

This method can be used to check whether a field name can be used for a new field in specified field type. User is recommended to call this function before using function Form.addControl to add a new field with a new control.

Parameters

  [in] | type | Field type, for which the input field name will be validated.
  [in] | field_name | A string value. It should not be an empty string.

Returns
  true means the input field name is valid for the specified field type, false means not.