Class AbstractPdfFormField
This class represents a single field or field group in an AcroForm.
public abstract class AbstractPdfFormField : PdfObjectWrapper<PdfDictionary>
- Inheritance
-
AbstractPdfFormField
- Derived
- Inherited Members
Remarks
This class represents a single field or field group in an AcroForm.
To be able to be wrapped with this PdfObjectWrapper<T> the PdfObject must be indirect.Constructors
AbstractPdfFormField(PdfDictionary)
Creates a form field as a wrapper object around a PdfDictionary.
protected AbstractPdfFormField(PdfDictionary pdfObject)
Parameters
pdfObject
PdfDictionarythe dictionary to be wrapped, must have an indirect reference.
Remarks
Creates a form field as a wrapper object around a PdfDictionary. This PdfDictionary must be an indirect object.
Fields
DEFAULT_FONT_SIZE
Size of text in form fields when font size is not explicitly set.
public const int DEFAULT_FONT_SIZE = 12
Field Value
MIN_FONT_SIZE
Minimal size of text in form fields.
public const int MIN_FONT_SIZE = 4
Field Value
color
protected Color color
Field Value
font
protected PdfFont font
Field Value
fontSize
protected float fontSize
Field Value
parent
Parent form field.
protected PdfFormField parent
Field Value
pdfAConformanceLevel
[Obsolete("since 8.0.4, this is not used anymore! Use pdfConformanceLevel instead")]
protected PdfAConformanceLevel pdfAConformanceLevel
Field Value
pdfConformanceLevel
protected IConformanceLevel pdfConformanceLevel
Field Value
Methods
DisableCurrentFieldRegeneration()
This method disables regeneration of the current field appearance stream.
public virtual void DisableCurrentFieldRegeneration()
DisableFieldRegeneration()
This method disables regeneration of the field and its children appearance stream.
public virtual void DisableFieldRegeneration()
Remarks
This method disables regeneration of the field and its children appearance stream. So all of its children in the hierarchy will also not be regenerated.
Note that after this method is called field will be regenerated only during EnableFieldRegeneration() call.EnableCurrentFieldRegeneration()
This method enables regeneration of the current field appearance stream and regenerates it.
public virtual void EnableCurrentFieldRegeneration()
EnableFieldRegeneration()
This method enables regeneration of the field appearance stream.
public virtual void EnableFieldRegeneration()
Remarks
This method enables regeneration of the field appearance stream. Please note that this method enables regeneration for the children of the field. Also, appearance will be regenerated during this method call.
Should be called after DisableFieldRegeneration() method call.Equals(object)
Indicate whether some other object is "equal to" this one.
public override bool Equals(object o)
Parameters
o
object
Returns
Remarks
Indicate whether some other object is "equal to" this one. Compares wrapped objects.
GetAppearanceStates()
Gets the appearance state names.
public abstract string[] GetAppearanceStates()
Returns
- string[]
an array of Strings containing the names of the appearance states.
GetColor()
Gets the current color of the form field.
public virtual Color GetColor()
Returns
GetDefaultAppearance()
Gets default appearance string containing a sequence of valid page-content graphics or text state operators that define such properties as the field's text size and color.
public abstract PdfString GetDefaultAppearance()
Returns
GetDocument()
Gets the PdfDocument that owns that form field.
public virtual PdfDocument GetDocument()
Returns
- PdfDocument
the PdfDocument that owns that form field.
GetFieldName()
Gets the current field name.
public virtual PdfString GetFieldName()
Returns
GetFont()
Gets the current font of the form field.
public virtual PdfFont GetFont()
Returns
GetFontSize()
Gets the current fontSize of the form field.
public virtual float GetFontSize()
Returns
- float
the current fontSize.
GetHashCode()
Generate a hash code for this object.
public override int GetHashCode()
Returns
GetParent()
Gets the parent dictionary.
public virtual PdfDictionary GetParent()
Returns
- PdfDictionary
another form field that this field belongs to.
GetParentField()
Gets the parent field.
public virtual PdfFormField GetParentField()
Returns
- PdfFormField
another form field that this field belongs to.
GetPdfAConformanceLevel()
Gets the declared conformance level.
[Obsolete]
public virtual PdfAConformanceLevel GetPdfAConformanceLevel()
Returns
Remarks
Gets the declared conformance level. Deprecated use AbstractPdfFormField getPdfConformanceLevel
GetPdfConformanceLevel()
Gets the declared conformance level.
public virtual IConformanceLevel GetPdfConformanceLevel()
Returns
GetPdfObject()
Gets the wrapped dictionary.
public override PdfDictionary GetPdfObject()
Returns
- PdfDictionary
the wrapped dictionary.
IsFieldRegenerationEnabled()
This method checks if field appearance stream regeneration is enabled.
public virtual bool IsFieldRegenerationEnabled()
Returns
- bool
true if regeneration is enabled for this field (and all of its ancestors), false otherwise.
IsTerminalFormField()
Determines whether current form field is terminal or not.
public virtual bool IsTerminalFormField()
Returns
- bool
true if this form field is a terminal one, false otherwise.
IsWrappedObjectMustBeIndirect()
protected override bool IsWrappedObjectMustBeIndirect()
Returns
Put(PdfName, PdfObject)
Inserts the value into the PdfDictionary of this field and associates it with the specified key.
public virtual AbstractPdfFormField Put(PdfName key, PdfObject value)
Parameters
key
PdfNamekey to insert or to override.
value
PdfObjectthe value to associate with the specified key.
Returns
- AbstractPdfFormField
the edited field.
Remarks
Inserts the value into the PdfDictionary of this field and associates it with the specified key. If the key is already present in this field dictionary, this method will override the old value with the specified one.
RegenerateField()
This method regenerates appearance stream of the field.
public abstract bool RegenerateField()
Returns
- bool
whether or not the regeneration was successful.
Remarks
This method regenerates appearance stream of the field. Use it if you changed any field parameters and didn't use setValue method which generates appearance by itself.
Release()
Releases underlying pdf object and other pdf entities used by wrapper.
public virtual void Release()
Remarks
Releases underlying pdf object and other pdf entities used by wrapper. This method should be called instead of direct call to Release() if the wrapper is used.
Remove(PdfName)
Removes the specified key from the PdfDictionary of this field.
public virtual AbstractPdfFormField Remove(PdfName key)
Parameters
key
PdfNamekey to be removed.
Returns
- AbstractPdfFormField
the edited field.
SetColor(Color)
Sets the text color and regenerates appearance stream.
public virtual AbstractPdfFormField SetColor(Color color)
Parameters
color
Colorthe new value for the Color.
Returns
- AbstractPdfFormField
the edited AbstractPdfFormField.
SetFont(PdfFont)
Basic setter for the font
property.
public virtual AbstractPdfFormField SetFont(PdfFont font)
Parameters
font
PdfFontThe new font to be set.
Returns
- AbstractPdfFormField
The edited AbstractPdfFormField.
Remarks
Basic setter for the font
property. Regenerates the field
appearance after setting the new value.
Note that the font will be added to the document so ensure that the font is embedded
if it's a pdf/a document.
SetFontAndSize(PdfFont, float)
Combined setter for the font
and fontSize
properties.
public virtual AbstractPdfFormField SetFontAndSize(PdfFont font, float fontSize)
Parameters
Returns
- AbstractPdfFormField
The edited AbstractPdfFormField.
Remarks
Combined setter for the font
and fontSize
properties. Regenerates the field appearance after setting the new value.
SetFontSize(int)
Basic setter for the fontSize
property.
public virtual AbstractPdfFormField SetFontSize(int fontSize)
Parameters
fontSize
intThe new font size to be set.
Returns
- AbstractPdfFormField
The edited AbstractPdfFormField.
Remarks
Basic setter for the fontSize
property. Regenerates the
field appearance after setting the new value.
SetFontSize(float)
Basic setter for the fontSize
property.
public virtual AbstractPdfFormField SetFontSize(float fontSize)
Parameters
fontSize
floatThe new font size to be set.
Returns
- AbstractPdfFormField
The edited AbstractPdfFormField.
Remarks
Basic setter for the fontSize
property. Regenerates the
field appearance after setting the new value.
SetFontSizeAutoScale()
Sets zero font size which will be interpreted as auto-size according to ISO 32000-1, 12.7.3.3.
public virtual AbstractPdfFormField SetFontSizeAutoScale()
Returns
- AbstractPdfFormField
the edited AbstractPdfFormField.
SetParent(PdfFormField)
Sets a parent PdfFormField for the current object.
public virtual void SetParent(PdfFormField parent)
Parameters
parent
PdfFormFieldanother form field that this field belongs to, usually a group field.