This is the superclass for a Field element in a PDF.
Based on the COS object model from PDFBox.
findFieldType
public String findFieldType()
Find the field type and optionally do a recursive upward search. Sometimes the fieldtype
will be specified on the parent instead of the direct object. This will look at this
object for the field type, if none is specified then it will look to the parent if there
is a parent. If there is no parent and no field type has been found then this
will return null.
- The field type or null if none was found.
findKid
public PDField findKid(String[] name,
int nameIndex)
throws IOException
This will find one of the child elements. The name array are the components
of the name to search down the tree of names. The nameIndex is where to
start in that array. This method is called recursively until it finds
the end point based on the name array.
name
- An array that picks the path to the field.nameIndex
- The index into the array.
- The field at the endpoint or null if none is found.
getAcroForm
public PDAcroForm getAcroForm()
This will get the acroform that this field is part of.
- The form this field is on.
getActions
public PDFormFieldAdditionalActions getActions()
Get the additional actions for this field. This will return null
if there are no additional actions for this field.
- The actions of the field.
getCOSObject
public COSBase getCOSObject()
Convert this standard java object to a COS object.
- getCOSObject in interface COSObjectable
- The cos object that matches this Java object.
getDictionary
public COSDictionary getDictionary()
This will get the dictionary associated with this field.
- The dictionary that this class wraps.
getFieldFlags
public int getFieldFlags()
This will get the flags for this field.
getFieldType
public String getFieldType()
Get the FT entry of the field. This is a read only field and is set depending
on the actual type. The field type is an inheritable attribute. This method will
return only the direct value on this object. Use the findFieldType for an upward
recursive search.
getFullyQualifiedName
public String getFullyQualifiedName()
throws IOException
Returns the fully qualified name of the field, which is a concatenation of
the names of all the parents fields.
getKids
public List getKids()
throws IOException
This will get all the kids of this field. The values in the list
will either be PDWidget or PDField. Normally they will be PDWidget objects
unless this is a non-terminal field and they will be child PDField objects.
- A list of either PDWidget or PDField objects.
getParent
public PDField getParent()
throws IOException
Get the parent field to this field, or null if none exists.
getPartialName
public String getPartialName()
Returns the partial name of the field.
getValue
public abstract String getValue()
throws IOException
getValue gets the fields value to as a string.
- The string value of this field.
getWidget
public PDAnnotationWidget getWidget()
throws IOException
This will get the single associated widget that is part of this field. This
occurs when the Widget is embedded in the fields dictionary. Sometimes there
are multiple sub widgets associated with this field, in which case you want to
use getKids(). If the kids entry is specified, then the first entry in that
list will be returned.
- The widget that is associated with this field.
importFDF
public void importFDF(FDFField fdfField)
throws IOException
This will import a fdf field from a fdf document.
fdfField
- The fdf field to import.
isNoExport
public boolean isNoExport()
- true if the field is not to be exported.
isReadonly
public boolean isReadonly()
- true if the field is readonly
isRequired
public boolean isRequired()
- true if the field is required
setAcroForm
public void setAcroForm(PDAcroForm value)
This will set the form this field is on.
value
- The new form to use.
setFieldFlags
public void setFieldFlags(int flags)
This will set the flags for this field.
setKids
public void setKids(List kids)
This will set the list of kids.
kids
- The list of child widgets.
setNoExport
public void setNoExport(boolean noExport)
sets the field to be not exported..
noExport
- The new flag for noExport.
setParent
public void setParent(PDField parent)
Set the parent of this field.
parent
- The parent to this field.
setPartialName
public void setPartialName(String name)
This will set the partial name of the field.
name
- The new name for the field.
setReadonly
public void setReadonly(boolean readonly)
sets the field to be read-only.
readonly
- The new flag for readonly.
setRequired
public void setRequired(boolean required)
sets the field to be required.
required
- The new flag for required.
setValue
public abstract void setValue(String value)
throws IOException
setValue sets the fields value to a given string.
toString
public String toString()
This will return a string representation of this field.
- A string representation of this field.