Form

Inheritance: java.lang.Object

All Implemented Interfaces: java.lang.Iterable

public final class Form implements Iterable<WidgetAnnotation>

Class representing form object.

Constructors

ConstructorDescription
Form(IDocument document)Constructor

Methods

MethodDescription
getSignDependentElementsRenderingModeWhenConverted()Forms can contain signing information, i.e.
setSignDependentElementsRenderingModeWhenConverted(int signDependentElementsRenderingModeWhenConverted)Forms can contain signing information, i.e.
getDocument()For internal usage only
get_xfa()For internal usage only
isSynchronized()Returns true if object is thread-safe.
getSyncRoot()Returns synchronization object.
getAutoRecalculate()If set, all form fields will be recalculated when any field is changed.
setAutoRecalculate(boolean value)If set, all form fields will be recalculated when any field is changed.
getAutoRestoreForm()If set, absent form fields will be automatically created if they present in annotations.
setAutoRestoreForm(boolean value)If set, absent form fields will be automatically created if they present in annotations.
size()Gets number of the fields on this form.
getDefaultResources()Gets default resources placed on this form.
getDefaultAppearance()Gets default appearance of the form (object which describes default font, text size and color for fields on the form).
setDefaultAppearance(DefaultAppearance value)Sets default appearance of the form (object which describes default font, text size and color for fields on the form).
getXFA()Gets XFA data of the form (if presents).
getIgnoreNeedsRendering()If this property is true the value of NeedsRendering key will be ignored during conversion XFA form to Standard form.
setIgnoreNeedsRendering(boolean value)If this property is true the value of NeedsRendering key will be ignored during conversion XFA form to Standard form.
getRemovePermission()If this property is true the “Perms” dictionary will be removed from the pdf document after conversion dynamic documents to standard.
setRemovePermission(boolean value)If this property is true the “Perms” dictionary will be removed from the pdf document after conversion dynamic documents to standard.
getEmulateRequierdGroups()If this property is true then additional red boundary rectangles will be drawn for required Xfa exclGroup elements containers This property was introduced because absences of analogies for the exclGroup during conversion Xfa representation of forms to standard.
setEmulateRequierdGroups(boolean value)If this property is true then additional red boundary rectangles will be drawn for required Xfa exclGroup elements containers This property was introduced because absences of analogies for the exclGroup during conversion Xfa representation of forms to standard.
getType()Gets type of the form.
setType(FormType value)Gets type of the form.
copyTo(Field[] array, int index)Copies fields placed on the form into array.
iterator()Gets enumeration of form fields.
get(String name)Searches field by field name.
get(int index)
delete(Field field)Delete field from the form.
delete(String fieldName)Deletes field from the form by its name.
flatten()Removes all static form fields and place their values directly on the page.
add(WidgetAnnotation field)Adds field on the form.
clear()Deletes all fields from form.
contains(WidgetAnnotation field)Determines if field is presented on form..
copyTo(WidgetAnnotation[] array, int arrayIndex)Copies form’s fields to array.
isReadOnly()Determines if collection is readonly.
remove(WidgetAnnotation field)Deletes field from the form.
get_Item(String name)Gets field of the form by field name.
get_Item(int index)Gets field of the form by field index.
add(Field field, int pageNumber)Adds field on the form.
add(Field field)Adds field on the form.
add(Field field, String partialName, int pageNumber)Adds new field to the form; If this field is already placed on other or this form, the copy of field is created.
addFieldAppearance(Field field, int pageNumber, Rectangle rect)Adds additional appearance of the field to specified page of the document in the specified location.
removeFieldAppearance(Field field, int appearanceIndex)Removes appearance of the field at specified index.
addFieldToAcroForm(Field field)Adds additional appearance of the field to specified page of the document.
hasXfa()Returns true if hasXfa
assignXfa(System.Xml.XmlDocument xml)Sets XFA of the form to specified value.
getFields()Gets list of all fields in lowest level of hierarhical form.
hasField(Field field)Check if the form already has specified field.
hasField(String fieldName)Determines if the field with specified name already added to the Form.
hasField(String fieldName, boolean searchChildren)Determines if the field with specified name already added to the Form, with ability to look into children hierarchy of fields.
getFieldsInRect(Rectangle rect)Returns fields inside of specified rectangle.
setCalculatedFields(List value)Allows to set order of field calculation.
getSignaturesExist()If set, the document contains at least one signature field.
setSignaturesExist(boolean value)If set, the document contains at least one signature field.
getSignaturesAppendOnly()If set, the document contains signatures that may be invalidated if the file is saved (written) in a way that alters its previous contents, as opposed to an incremental update.
setSignaturesAppendOnly(boolean value)If set, the document contains signatures that may be invalidated if the file is saved (written) in a way that alters its previous contents, as opposed to an incremental update.

Form(IDocument document)

public Form(IDocument document)

Constructor

Parameters:

ParameterTypeDescription
documentIDocumentIDocument object

getSignDependentElementsRenderingModeWhenConverted()

public int getSignDependentElementsRenderingModeWhenConverted()

Forms can contain signing information, i.e. can be signed or unsigned. And form’s view sometimes must depend on whether form is signed or not. This property tells to form’s converter (f.e. during conversion XFA form to Standard form) whether result form must be rendered as signed or as unsigned.

Returns: int - SignDependentElementsRenderingModes element

setSignDependentElementsRenderingModeWhenConverted(int signDependentElementsRenderingModeWhenConverted)

public void setSignDependentElementsRenderingModeWhenConverted(int signDependentElementsRenderingModeWhenConverted)

Forms can contain signing information, i.e. can be signed or unsigned. And form’s view sometimes must depend on whether form is signed or not. This property tells to form’s converter (f.e. during conversion XFA form to Standard form) whether result form must be rendered as signed or as unsigned.

Parameters:

ParameterTypeDescription
signDependentElementsRenderingModeWhenConvertedintSignDependentElementsRenderingModes element

getDocument()

public IDocument getDocument()

For internal usage only

Returns: IDocument - IDocument object

get_xfa()

public XFA get_xfa()

For internal usage only

Returns: XFA - XFA object

isSynchronized()

public boolean isSynchronized()

Returns true if object is thread-safe.

Returns: boolean - boolean value

getSyncRoot()

public Object getSyncRoot()

Returns synchronization object.

Returns: java.lang.Object - Object for synchronization

getAutoRecalculate()

public final boolean getAutoRecalculate()

If set, all form fields will be recalculated when any field is changed. Default value is true. Set to false in order to increase performance when filling form with large amount of calculated fields.

Returns: boolean - boolean value

setAutoRecalculate(boolean value)

public final void setAutoRecalculate(boolean value)

If set, all form fields will be recalculated when any field is changed. Default value is true. Set to false in order to increase performance when filling form with large amount of calculated fields.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getAutoRestoreForm()

public final boolean getAutoRestoreForm()

If set, absent form fields will be automatically created if they present in annotations.

Returns: boolean - boolean value

setAutoRestoreForm(boolean value)

public final void setAutoRestoreForm(boolean value)

If set, absent form fields will be automatically created if they present in annotations.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

size()

public final int size()

Gets number of the fields on this form.

Returns: int - int value

getDefaultResources()

public Resources getDefaultResources()

Gets default resources placed on this form.

Returns: Resources - Resources value

getDefaultAppearance()

public DefaultAppearance getDefaultAppearance()

Gets default appearance of the form (object which describes default font, text size and color for fields on the form).

Returns: DefaultAppearance - DefaultAppearance object

setDefaultAppearance(DefaultAppearance value)

public void setDefaultAppearance(DefaultAppearance value)

Sets default appearance of the form (object which describes default font, text size and color for fields on the form).

Parameters:

ParameterTypeDescription
valueDefaultAppearanceDefaultAppearance object

getXFA()

public XFA getXFA()

Gets XFA data of the form (if presents).

Returns: XFA - XFA value

getIgnoreNeedsRendering()

public boolean getIgnoreNeedsRendering()

If this property is true the value of NeedsRendering key will be ignored during conversion XFA form to Standard form. It is false by default.

Returns: boolean - boolean value

setIgnoreNeedsRendering(boolean value)

public void setIgnoreNeedsRendering(boolean value)

If this property is true the value of NeedsRendering key will be ignored during conversion XFA form to Standard form. It is false by default.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getRemovePermission()

public boolean getRemovePermission()

If this property is true the “Perms” dictionary will be removed from the pdf document after conversion dynamic documents to standard. The “Perms” dictionary can contain a rules that disturb displaying selection of mandatory fields in Adobe Acrobat reader. It is false by default.

Returns: boolean - boolean value

setRemovePermission(boolean value)

public void setRemovePermission(boolean value)

If this property is true the “Perms” dictionary will be removed from the pdf document after conversion dynamic documents to standard. The “Perms” dictionary can contain a rules that disturb displaying selection of mandatory fields in Adobe Acrobat reader. It is false by default.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getEmulateRequierdGroups()

public boolean getEmulateRequierdGroups()

If this property is true then additional red boundary rectangles will be drawn for required Xfa exclGroup elements containers This property was introduced because absences of analogies for the exclGroup during conversion Xfa representation of forms to standard. It is false by default.

Returns: boolean - boolean value

setEmulateRequierdGroups(boolean value)

public void setEmulateRequierdGroups(boolean value)

If this property is true then additional red boundary rectangles will be drawn for required Xfa exclGroup elements containers This property was introduced because absences of analogies for the exclGroup during conversion Xfa representation of forms to standard. It is false by default.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getType()

public FormType getType()

Gets type of the form. Possible values are: Standard, Static, Dynamic.

Returns: FormType - FormType value

setType(FormType value)

public void setType(FormType value)

Gets type of the form. Possible values are: Standard, Static, Dynamic.

Parameters:

ParameterTypeDescription
valueFormTypeFormType value

copyTo(Field[] array, int index)

public void copyTo(Field[] array, int index)

Copies fields placed on the form into array.

Parameters:

ParameterTypeDescription
arrayField[]Array where fields must be placed.
indexintStarting index.

iterator()

public Iterator<WidgetAnnotation> iterator()

Gets enumeration of form fields.

Returns: java.util.Iterator<com.aspose.pdf.WidgetAnnotation> - Field enumerator.

get(String name)

public WidgetAnnotation get(String name)

Searches field by field name. Returns null if field was not found.

Parameters:

ParameterTypeDescription
namejava.lang.StringField name.

Returns: WidgetAnnotation - Field object.

get(int index)

public WidgetAnnotation get(int index)

Parameters:

ParameterTypeDescription
indexint

Returns: WidgetAnnotation

delete(Field field)

public void delete(Field field)

Delete field from the form.

Parameters:

ParameterTypeDescription
fieldFieldField which must be deleted.

delete(String fieldName)

public void delete(String fieldName)

Deletes field from the form by its name.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of the filed which must be deleted.

flatten()

public void flatten()

Removes all static form fields and place their values directly on the page.

add(WidgetAnnotation field)

public boolean add(WidgetAnnotation field)

Adds field on the form.

Parameters:

ParameterTypeDescription
fieldWidgetAnnotationField which must be added.

Returns: boolean - boolean value

clear()

public void clear()

Deletes all fields from form. Not supported.

contains(WidgetAnnotation field)

public boolean contains(WidgetAnnotation field)

Determines if field is presented on form..

Parameters:

ParameterTypeDescription
fieldWidgetAnnotationField to search.

Returns: boolean - boolean value

copyTo(WidgetAnnotation[] array, int arrayIndex)

public void copyTo(WidgetAnnotation[] array, int arrayIndex)

Copies form’s fields to array.

Parameters:

ParameterTypeDescription
arrayWidgetAnnotation[]Array to copy.
arrayIndexintIndex of array’s item where copying begins.

isReadOnly()

public boolean isReadOnly()

Determines if collection is readonly. Always returns false.

Returns: boolean - boolean value

remove(WidgetAnnotation field)

public boolean remove(WidgetAnnotation field)

Deletes field from the form.

Parameters:

ParameterTypeDescription
fieldWidgetAnnotationField to delete.

Returns: boolean - True if field was deleted. False if field was not found on form.

get_Item(String name)

public WidgetAnnotation get_Item(String name)

Gets field of the form by field name. Throws excpetion if the field was not found.

Parameters:

ParameterTypeDescription
namejava.lang.StringName of the field.

Returns: WidgetAnnotation - Retreived field.

get_Item(int index)

public WidgetAnnotation get_Item(int index)

Gets field of the form by field index.

Parameters:

ParameterTypeDescription
indexintIndex of the field.

Returns: WidgetAnnotation - Retreived field.

add(Field field, int pageNumber)

public void add(Field field, int pageNumber)

Adds field on the form.

Parameters:

ParameterTypeDescription
fieldFieldField which must be added.
pageNumberintPage index where added field will be placed.

add(Field field)

public void add(Field field)

Adds field on the form.

Parameters:

ParameterTypeDescription
fieldFieldField which must be added.

add(Field field, String partialName, int pageNumber)

public Field add(Field field, String partialName, int pageNumber)

Adds new field to the form; If this field is already placed on other or this form, the copy of field is created.

Parameters:

ParameterTypeDescription
fieldFieldField name.
partialNamejava.lang.StringName of field on the form.
pageNumberintPage number where field will be added.

Returns: Field - Added field returned. If copy of the field was created it will be returned.

addFieldAppearance(Field field, int pageNumber, Rectangle rect)

public void addFieldAppearance(Field field, int pageNumber, Rectangle rect)

Adds additional appearance of the field to specified page of the document in the specified location.

Parameters:

ParameterTypeDescription
fieldFieldField which appearance should be added on form.
pageNumberintNumber of the page where field must be placed.
rectRectangleRectangle where field will be placed.

removeFieldAppearance(Field field, int appearanceIndex)

public final void removeFieldAppearance(Field field, int appearanceIndex)

Removes appearance of the field at specified index. If only one child appearance left, method embeds it into the field.

Parameters:

ParameterTypeDescription
fieldFieldField with appearances.
appearanceIndexintAppearances index.

addFieldToAcroForm(Field field)

public void addFieldToAcroForm(Field field)

Adds additional appearance of the field to specified page of the document.

Parameters:

ParameterTypeDescription
fieldFieldField object

hasXfa()

public boolean hasXfa()

Returns true if hasXfa

Returns: boolean - boolean value

assignXfa(System.Xml.XmlDocument xml)

public void assignXfa(System.Xml.XmlDocument xml)

Sets XFA of the form to specified value.

Parameters:

ParameterTypeDescription
xmlcom.aspose.ms.System.Xml.XmlDocumentXml document which concains new XFA data.

getFields()

public Field[] getFields()

Gets list of all fields in lowest level of hierarhical form.

Returns: com.aspose.pdf.Field[] - Array with found fields.

hasField(Field field)

public final boolean hasField(Field field)

Check if the form already has specified field.

Parameters:

ParameterTypeDescription
fieldFieldField to check.

Returns: boolean - true if the specified field name added to Form; otherwise, false .

hasField(String fieldName)

public final boolean hasField(String fieldName)

Determines if the field with specified name already added to the Form.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringField.PartialName or Annotation.FullName of the field.

Returns: boolean - true if the specified field name added to Form; otherwise false.

hasField(String fieldName, boolean searchChildren)

public final boolean hasField(String fieldName, boolean searchChildren)

Determines if the field with specified name already added to the Form, with ability to look into children hierarchy of fields.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringField.PartialName or Annotation.FullName of the field.
searchChildrenbooleanWhen set to the whole hierarchy of form fields would be searched for the requested fieldName (note that in this case the Annotation.FullNameof the required field should be passed as fieldName ).

Returns: boolean - true if the specified field name added to Form; otherwise, false.

getFieldsInRect(Rectangle rect)

public Field[] getFieldsInRect(Rectangle rect)

Returns fields inside of specified rectangle.

Parameters:

ParameterTypeDescription
rectRectangleRectangle where fields should be found.

Returns: com.aspose.pdf.Field[] - Array with found fields.

setCalculatedFields(List value)

public void setCalculatedFields(List<Field> value)

Allows to set order of field calculation.

Parameters:

ParameterTypeDescription
valuejava.util.List<com.aspose.pdf.Field>java.util.List object.

getSignaturesExist()

public final boolean getSignaturesExist()

If set, the document contains at least one signature field.

Returns: boolean - boolean value

setSignaturesExist(boolean value)

public final void setSignaturesExist(boolean value)

If set, the document contains at least one signature field.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getSignaturesAppendOnly()

public final boolean getSignaturesAppendOnly()

If set, the document contains signatures that may be invalidated if the file is saved (written) in a way that alters its previous contents, as opposed to an incremental update.

Returns: boolean - boolean value

setSignaturesAppendOnly(boolean value)

public final void setSignaturesAppendOnly(boolean value)

If set, the document contains signatures that may be invalidated if the file is saved (written) in a way that alters its previous contents, as opposed to an incremental update.

Parameters:

ParameterTypeDescription
valuebooleanboolean value