Class PdfFormAnnotation
This class represents a single annotation in form fields hierarchy in an AcroForm.
public class PdfFormAnnotation : AbstractPdfFormField
- Inheritance
-
PdfFormAnnotation
- Inherited Members
Remarks
This class represents a single annotation in form fields hierarchy in an AcroForm.
To be able to be wrapped with this PdfObjectWrapper<T> the PdfObject must be indirect.Constructors
PdfFormAnnotation(PdfWidgetAnnotation, PdfDocument)
Creates a form field annotation as a wrapper of a PdfWidgetAnnotation.
protected PdfFormAnnotation(PdfWidgetAnnotation widget, PdfDocument pdfDocument)
Parameters
widget
PdfWidgetAnnotationThe widget which will be a kid of the PdfFormField
pdfDocument
PdfDocumentThe PdfDocument instance.
PdfFormAnnotation(PdfDictionary)
Creates a form field annotation as a wrapper object around a PdfDictionary.
protected PdfFormAnnotation(PdfDictionary pdfObject)
Parameters
pdfObject
PdfDictionarythe dictionary to be wrapped, must have an indirect reference.
Remarks
Creates a form field annotation as a wrapper object around a PdfDictionary. This PdfDictionary must be an indirect object.
Fields
HIDDEN
public const int HIDDEN = 1
Field Value
HIDDEN_BUT_PRINTABLE
public const int HIDDEN_BUT_PRINTABLE = 3
Field Value
OFF_STATE_VALUE
Value which represents "off" state of form field.
public const string OFF_STATE_VALUE = "Off"
Field Value
ON_STATE_VALUE
Value which represents "on" state of form field.
public const string ON_STATE_VALUE = "Yes"
Field Value
VISIBLE
public const int VISIBLE = 4
Field Value
VISIBLE_BUT_DOES_NOT_PRINT
public const int VISIBLE_BUT_DOES_NOT_PRINT = 2
Field Value
backgroundColor
protected Color backgroundColor
Field Value
borderColor
protected Color borderColor
Field Value
borderWidth
protected float borderWidth
Field Value
Methods
DrawBorder(PdfCanvas, PdfFormXObject, float, float)
Draws a border using the borderWidth and borderColor of the form field.
protected virtual void DrawBorder(PdfCanvas canvas, PdfFormXObject xObject, float width, float height)
Parameters
canvas
PdfCanvasThe PdfCanvas on which to draw
xObject
PdfFormXObjectThe PdfFormXObject
width
floatThe width of the rectangle to draw
height
floatThe height of the rectangle to draw
DrawCheckBoxAndSaveAppearance(string)
Draw a checkbox and save its appearance.
protected virtual void DrawCheckBoxAndSaveAppearance(string onStateName)
Parameters
onStateName
stringthe name of the appearance state for the checked state
DrawComboBoxAndSaveAppearance()
Draws the appearance of a Combo box form field and saves it into an appearance stream.
protected virtual void DrawComboBoxAndSaveAppearance()
DrawListFormFieldAndSaveAppearance()
Draws the appearance of a list box form field and saves it into an appearance stream.
protected virtual void DrawListFormFieldAndSaveAppearance()
DrawPushButtonFieldAndSaveAppearance()
Draws the appearance of a push button and saves it into an appearance stream.
protected virtual void DrawPushButtonFieldAndSaveAppearance()
DrawRadioButtonAndSaveAppearance(string)
Draws the appearance of a radio button with a specified value and saves it into an appearance stream.
protected virtual void DrawRadioButtonAndSaveAppearance(string value)
Parameters
value
stringthe value of the radio button.
DrawSignatureFormFieldAndSaveAppearance()
Draws the appearance of a signature field and saves it into an appearance stream.
protected virtual void DrawSignatureFormFieldAndSaveAppearance()
DrawTextFormFieldAndSaveAppearance()
Draws the appearance of a text form field and saves it into an appearance stream.
protected virtual void DrawTextFormFieldAndSaveAppearance()
GetAppearanceStates()
Gets the appearance state names.
public override string[] GetAppearanceStates()
Returns
- string[]
an array of Strings containing the names of the appearance states.
GetBorder()
Get border object specified in the widget annotation dictionary.
public virtual Border GetBorder()
Returns
GetBorderWidth()
Gets the border width for the field.
public virtual float GetBorderWidth()
Returns
- float
the current border width.
GetDefaultAppearance()
public override PdfString GetDefaultAppearance()
Returns
GetRect(PdfDictionary)
Gets a Rectangle that matches the current size and position of this form field.
protected virtual Rectangle GetRect(PdfDictionary field)
Parameters
field
PdfDictionarycurrent form field.
Returns
GetRotation()
Get rotation property specified in this form annotation.
public virtual int GetRotation()
Returns
- int
int
value which represents field's rotation
GetWidget()
Gets PdfWidgetAnnotation that this form field refers to.
public virtual PdfWidgetAnnotation GetWidget()
Returns
MakeFormAnnotation(PdfObject, PdfDocument)
Creates a PdfFormAnnotation object.
public static PdfFormAnnotation MakeFormAnnotation(PdfObject pdfObject, PdfDocument document)
Parameters
pdfObject
PdfObjectassumed to be either a PdfDictionary , or a PdfIndirectReference to a PdfDictionary.
document
PdfDocumentthe PdfDocument to create the field in.
Returns
- PdfFormAnnotation
a new PdfFormAnnotation , or
null
ifpdfObject
is not a widget annotation.
RegenerateField()
public override bool RegenerateField()
Returns
SetAction(PdfAction)
Sets the action on widget of this annotation form field.
public virtual PdfFormAnnotation SetAction(PdfAction action)
Parameters
action
PdfActionThe action.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
SetAppearance(PdfName, string, PdfStream)
Sets an appearance for (the widgets related to) the form field.
public virtual PdfFormAnnotation SetAppearance(PdfName appearanceType, string appearanceState, PdfStream appearanceStream)
Parameters
appearanceType
PdfNamethe type of appearance stream to be added
- PdfName.N: normal appearance
- PdfName.R: rollover appearance
- PdfName.D: down appearance
appearanceState
stringthe state of the form field that needs to be true for the appearance to be used. Differentiates between several streams of the same type.
appearanceStream
PdfStreamthe appearance instructions, as a PdfStream.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
SetBackgroundColor(Color)
Basic setter for the backgroundColor
property.
public virtual PdfFormAnnotation SetBackgroundColor(Color backgroundColor)
Parameters
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
Remarks
Basic setter for the backgroundColor
property. Regenerates
the field appearance after setting the new value.
SetBorderColor(Color)
Sets the Border Color.
public virtual PdfFormAnnotation SetBorderColor(Color color)
Parameters
color
Colorthe new value for the Border Color.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
SetBorderStyle(PdfDictionary)
Sets the border style for the field.
public virtual PdfFormAnnotation SetBorderStyle(PdfDictionary style)
Parameters
style
PdfDictionarythe new border style.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
SetBorderWidth(float)
Sets the border width for the field.
public virtual PdfFormAnnotation SetBorderWidth(float borderWidth)
Parameters
borderWidth
floatThe new border width.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
SetCaption(string)
Basic setter for the push button caption.
public virtual PdfFormAnnotation SetCaption(string caption)
Parameters
caption
stringbutton caption to be set.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
Remarks
Basic setter for the push button caption. Regenerates the field appearance after setting the new caption.
SetCaption(string, bool)
Basic setter for the push button caption.
public virtual PdfFormAnnotation SetCaption(string caption, bool regenerateField)
Parameters
caption
stringbutton caption to be set.
regenerateField
booltrue if field should be regenerated, false otherwise.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
Remarks
Basic setter for the push button caption. Regenerates the field appearance after setting the new caption if corresponding parameter is specified.
SetCheckBoxAppearanceOnStateName(string)
Sets on state name for the checkbox annotation normal appearance and regenerates widget.
public virtual PdfFormAnnotation SetCheckBoxAppearanceOnStateName(string onStateName)
Parameters
onStateName
stringthe new appearance name representing on state.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
SetFormFieldElement(IFormField)
This method sets the model element associated with the current annotation and can be useful to take into account when drawing those properties that the annotation does not have.
public virtual PdfFormAnnotation SetFormFieldElement(IFormField element)
Parameters
element
IFormFieldmodel element to set.
Returns
Remarks
This method sets the model element associated with the current annotation and can be useful to take into account when drawing those properties that the annotation does not have. Note that annotation properties will take precedence, so such properties cannot be overridden by using this method (e.g. background, text color, etc.).
Also note that the model element won't be used for annotations for choice form field.SetPage(int)
Specifies on which page the form field's widget must be shown.
public virtual PdfFormAnnotation SetPage(int pageNum)
Parameters
pageNum
intthe page number.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
SetRotation(int)
Basic setter for the degRotation
property.
public virtual PdfFormAnnotation SetRotation(int degRotation)
Parameters
degRotation
intThe new degRotation to be set
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
Remarks
Basic setter for the degRotation
property. Regenerates
the field appearance after setting the new value.
SetVisibility(int)
Set the visibility flags of the form field annotation.
public virtual PdfFormAnnotation SetVisibility(int visibility)
Parameters
visibility
intvisibility option.
Returns
- PdfFormAnnotation
The edited PdfFormAnnotation.
Remarks
Set the visibility flags of the form field annotation. Options are: HIDDEN, HIDDEN_BUT_PRINTABLE, VISIBLE, VISIBLE_BUT_DOES_NOT_PRINT.