Click or drag to resize

Field Class

Flatten/Merge existing form field appearances with the page content and remove widget annotation. Form 'flattening' refers to the operation that changes active form fields into a static area that is part of the PDF document, just like the other text and images in the document. A completely flattened PDF form does not have any widget annotations or interactive fields.

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.

PDFNet fully supports reading, writing, and editing PDF forms and provides many utility methods so that work with forms is simple and efficient. Using PDFNet forms API arbitrary subsets of form fields can be imported or exported from the document, new forms can be created from scratch, and the appearance of existing forms can be modified.

Examples
In PDFNet Fields are accessed through FieldIterator-s. For a full sample, please refer to 'InteractiveForms' sample project. The list of all Fields present in the document can be traversed as follows:
for(FieldIterator itr = doc.getFieldIterator(); itr.hasNext();) {
Field current=(Field)(itr.next());
System.out.println("Field name: " + current.getName());
System.out.println("Field partial name: " + current.getPartialName());
}
To search field by name use FieldFind method. For example:
// Search for a specific field
FieldIterator itr = doc.fieldFind("employee.name.first");
if (itr.hasNext()) System.out.println("Field search for " + ((Field)(itr.next())).getName() + " was successful");
else System.out.println("Field search failed");
If a given field name was not found or if the end of the field list was reached the iterator HasNext() will return false. If you have a valid iterator you can access the Field using Current() method. For example:
Field field = itr.Current();
Using Flatten(...) method it is possible to merge field appearances with the page content. Form 'flattening' refers to the operation that changes active form fields into a static area that is part of the PDF document, just like the other text and images in the document. A completely flattened PDF form does not have any widget annotations or interactive fields.
Inheritance Hierarchy
SystemObject
  pdftron.PDFField

Namespace:  pdftron.PDF
Assembly:  pdftron (in pdftron.dll) Version: 255.255.255.255
Syntax
public sealed class Field : IClosable

The Field type exposes the following members.

Constructors
  NameDescription
Public methodField
Construct a Field from a SDF dictionary representing a terminal field node.
Top
Methods
  NameDescription
Public methodClose
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodEraseAppearance
Removes any appearances associated with the field.
Public methodFindInheritedAttribute
Some of the Field attributes are designated as inheritable. If such an attribute is omitted from a Field object, its value is inherited from an ancestor node in the Field tree. If the attribute is a required one, a value must be supplied in an ancestor node; if it is optional and no inherited value is specified, the default value should be used. The function walks up the Field inhritance tree in search for specified attribute.
Public methodFlatten
Flatten/Merge existing form field appearances with the page content and remove widget annotation. Form 'flattening' refers to the operation that changes active form fields into a static area that is part of the PDF document, just like the other text and images in the document. A completely flattened PDF form does not have any widget annotations or interactive fields.
Public methodGetDefaultAppearance
Gets the default graphics state.
Public methodGetDefaultValue
Gets the default value.
Public methodGetDefaultValueAsString
Gets the default value as string.
Public methodGetFlag
Gets the flag.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetJustification
Gets the justification.
Public methodGetMaxLen
Gets the maximum length.
Public methodGetName
Gets the name.
Public methodGetOpt
Gets the name of the option in a list or combo box for a given index.
Public methodGetOptCount
Gets the number of options for a list box or combo box.
Public methodGetPartialName
Gets the partial name.
Public methodGetSDFObj
Gets the SDFObj.
Public methodGetTriggerAction
Get the Action associated with the selected Field Trigger event
Public methodGetType
Gets the type.
Public methodGetUpdateRect
Return the rectangle that should be refreshed after changing a field.
Public methodGetValue
Gets the value.
Public methodGetValueAsBool
Gets the value as bool.
Public methodGetValueAsString
Gets the value as string.
Public methodIsAnnot
Checks if is annot.
Public methodIsLockedByDigitalSignature
Returns whether modifying this field would invalidate a digital signature in the document.
Public methodIsValid
Checks if current field is valid.
Public methodRefreshAppearance
Regenerates the appearance stream for the Widget Annotation containing variable text. Call this method if you modified field's value and would like to update field's appearance.
Public methodRename
Modifies the field name.
Public methodSet
Sets to given Field object
Public methodSetFlag
Set the value of given FieldFlag.
Public methodSetJustification
Sets the justification to be used in displaying the text field.
Public methodSetMaxLen
Sets the maximum length of the field's text, in Characters.
Public methodSetValue(Boolean)
Sets the value.
Public methodSetValue(String)
Sets the value.
Public methodSetValue(Obj)
Sets the value of the Field (i.e. the value of the field's /V key). The format of field's value varies depending on the field type.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUseSignatureHandler
Sets the signature handler to use for adding a signature to this field. If the signature handler is not found in PDFDoc's signature handlers list, this field will not be signed. To add signature handlers, use PDFDoc.AddSignatureHandler method. If a signature handler is already assigned to this field and this method is called once again, the associated signature handler for this field will be updated with the new handler.
Top
Remarks
An alternative approach to set the field as read only is using Field.SetFlag(Field::e_read_only, true) method. Unlike Field.SetFlag(...), the result of FlattenField() operation can not be programatically reversed.
See Also