iText 7 7.1.9 API
iText.Forms.PdfAcroForm Class Reference

This class represents the static form technology AcroForm on a PDF file. More...

Inheritance diagram for iText.Forms.PdfAcroForm:
iText.Kernel.Pdf.PdfObjectWrapper< PdfDictionary >

Public Member Functions

virtual void  AddField (PdfFormField field)
  This method adds the field to the last page in the document. More...
 
virtual void  AddField (PdfFormField field, PdfPage page)
  This method adds the field to a specific page. More...
 
virtual void  AddFieldAppearanceToPage (PdfFormField field, PdfPage page)
  This method merges field with its annotation and place it on the given page. More...
 
virtual IDictionary< String, PdfFormField GetFormFields ()
  Gets the form field s as a System.Collections.IDictionary<K, V>. More...
 
virtual ICollection< PdfFormField GetFieldsForFlattening ()
  Gets a collection of form field s, prepared for flattening using PartialFormFlattening(System.String) method. More...
 
virtual PdfDocument  GetPdfDocument ()
  Gets the iText.Kernel.Pdf.PdfDocument this PdfAcroForm belongs to. More...
 
virtual iText.Forms.PdfAcroForm  SetNeedAppearances (bool needAppearances)
  Sets the NeedAppearances boolean property on the AcroForm. More...
 
virtual PdfBoolean  GetNeedAppearances ()
  Gets the NeedAppearances boolean property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetSignatureFlags (int sigFlags)
  Sets the SigFlags integer property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetSignatureFlag (int sigFlag)
  Changes the SigFlags integer property on the AcroForm. More...
 
virtual int  GetSignatureFlags ()
  Gets the SigFlags integer property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetCalculationOrder (PdfArray calculationOrder)
  Sets the CO array property on the AcroForm. More...
 
virtual PdfArray  GetCalculationOrder ()
  Gets the CO array property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetDefaultResources (PdfDictionary defaultResources)
  Sets the DR dictionary property on the AcroForm. More...
 
virtual PdfDictionary  GetDefaultResources ()
  Gets the DR dictionary property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetDefaultAppearance (String appearance)
  Sets the DA String property on the AcroForm. More...
 
virtual PdfString  GetDefaultAppearance ()
  Gets the DA String property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetDefaultJustification (int justification)
  Sets the Q integer property on the AcroForm. More...
 
virtual PdfNumber  GetDefaultJustification ()
  Gets the Q integer property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetXFAResource (PdfStream xfaResource)
  Sets the XFA property on the AcroForm. More...
 
virtual iText.Forms.PdfAcroForm  SetXFAResource (PdfArray xfaResource)
  Sets the XFA property on the AcroForm. More...
 
virtual PdfObject  GetXFAResource ()
  Gets the XFA property on the AcroForm. More...
 
virtual PdfFormField  GetField (String fieldName)
  Gets a form field by its name. More...
 
virtual bool  IsGenerateAppearance ()
  Gets the attribute generateAppearance, which tells FlattenFields() to generate an appearance Stream for all form field s that don't have one. More...
 
virtual void  SetGenerateAppearance (bool generateAppearance)
  Sets the attribute generateAppearance, which tells FlattenFields() to generate an appearance Stream for all form field s that don't have one. More...
 
virtual void  FlattenFields ()
  Flattens interactive form field s in the document. More...
 
virtual bool  RemoveField (String fieldName)
  Tries to remove the form field with the specified name from the document. More...
 
virtual void  PartialFormFlattening (String fieldName)
  Adds a form field , identified by name, to the list of fields to be flattened. More...
 
virtual void  RenameField (String oldName, String newName)
  Changes the identifier of a form field. More...
 
virtual PdfFormField  CopyField (String name)
  Creates an in-memory copy of a iText.Forms.Fields.PdfFormField. More...
 
virtual void  ReplaceField (String name, PdfFormField field)
  Replaces the iText.Forms.Fields.PdfFormField of a certain name with another iText.Forms.Fields.PdfFormField. More...
 
virtual bool  HasXfaForm ()
  Determines whether the AcroForm contains XFA data. More...
 
virtual XfaForm  GetXfaForm ()
  Gets the iText.Forms.Xfa.XfaForm atribute. More...
 
virtual void  RemoveXfaForm ()
  Removes the XFA stream from the document. More...
 
virtual iText.Forms.PdfAcroForm  Put (PdfName key, PdfObject value)
 
virtual void  Release ()
  Releases underlying pdf object and other pdf entities used by wrapper. More...
 
- Public Member Functions inherited from iText.Kernel.Pdf.PdfObjectWrapper< PdfDictionary >
virtual T  GetPdfObject ()
 
virtual iText.Kernel.Pdf.PdfObjectWrapper< T >  MakeIndirect (PdfDocument document, PdfIndirectReference reference)
  Marks object behind wrapper to be saved as indirect. More...
 
virtual iText.Kernel.Pdf.PdfObjectWrapper< T >  MakeIndirect (PdfDocument document)
  Marks object behind wrapper to be saved as indirect. More...
 
virtual iText.Kernel.Pdf.PdfObjectWrapper< T >  SetModified ()
 
virtual void  Flush ()
 
virtual bool  IsFlushed ()
 

Static Public Member Functions

static iText.Forms.PdfAcroForm  GetAcroForm (PdfDocument document, bool createIfNotExist)
  Retrieves AcroForm from the document. More...
 

Static Public Attributes

const int  SIGNATURE_EXIST = 1
  To be used with SetSignatureFlags(int). More...
 
const int  APPEND_ONLY = 2
  To be used with SetSignatureFlags(int). More...
 

Protected Member Functions

override bool  IsWrappedObjectMustBeIndirect ()
  Defines if the object behind this wrapper must be an indirect object in the resultant document. More...
 

Detailed Description

This class represents the static form technology AcroForm on a PDF file.

Member Function Documentation

◆ AddField() [1/2]

virtual void iText.Forms.PdfAcroForm.AddField ( PdfFormField  field )
inlinevirtual

This method adds the field to the last page in the document.

This method adds the field to the last page in the document. If there's no pages, creates a new one.

Parameters
field the iText.Forms.Fields.PdfFormField to be added to the form

◆ AddField() [2/2]

virtual void iText.Forms.PdfAcroForm.AddField ( PdfFormField  field,
PdfPage  page 
)
inlinevirtual

This method adds the field to a specific page.

Parameters
field the iText.Forms.Fields.PdfFormField to be added to the form
page the iText.Kernel.Pdf.PdfPage on which to add the field

◆ AddFieldAppearanceToPage()

virtual void iText.Forms.PdfAcroForm.AddFieldAppearanceToPage ( PdfFormField  field,
PdfPage  page 
)
inlinevirtual

This method merges field with its annotation and place it on the given page.

This method merges field with its annotation and place it on the given page. This method won't work if the field has no or more than one widget annotations.

Parameters
field the iText.Forms.Fields.PdfFormField to be added to the form
page the iText.Kernel.Pdf.PdfPage on which to add the field

◆ CopyField()

virtual PdfFormField iText.Forms.PdfAcroForm.CopyField ( String  name )
inlinevirtual

Creates an in-memory copy of a iText.Forms.Fields.PdfFormField.

Creates an in-memory copy of a iText.Forms.Fields.PdfFormField . This new field is not added to the document.

Parameters
name the name of the form field to be copied
Returns
a clone of the original iText.Forms.Fields.PdfFormField

◆ FlattenFields()

virtual void iText.Forms.PdfAcroForm.FlattenFields ( )
inlinevirtual

Flattens interactive form field s in the document.

Flattens interactive form field s in the document. If no fields have been explicitly included via PartialFormFlattening(System.String) , then all fields are flattened. Otherwise only the included fields are flattened.

◆ GetAcroForm()

static iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.GetAcroForm ( PdfDocument  document,
bool  createIfNotExist 
)
inlinestatic

Retrieves AcroForm from the document.

Retrieves AcroForm from the document. If there is no AcroForm in the document Catalog and createIfNotExist flag is true then the AcroForm dictionary will be created and added to the document.

Parameters
document the document to retrieve the PdfAcroForm from
createIfNotExist when true, this method will create a PdfAcroForm if none exists for this document
Returns
the document 's AcroForm, or a new one provided that createIfNotExist parameter is true, otherwise null.

◆ GetCalculationOrder()

virtual PdfArray iText.Forms.PdfAcroForm.GetCalculationOrder ( )
inlinevirtual

Gets the CO array property on the AcroForm.

Gets the CO array property on the AcroForm.

CO, Calculation Order, is an array of indirect references to field dictionaries with calculation actions, defining the calculation order in which their values will be recalculated when the value of any field changes (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Returns
an array of indirect references

◆ GetDefaultAppearance()

virtual PdfString iText.Forms.PdfAcroForm.GetDefaultAppearance ( )
inlinevirtual

Gets the DA String property on the AcroForm.

Gets the DA String property on the AcroForm.
This method returns the default (fallback value) for the DA attribute of variable text form field s.

Returns
the form-wide default appearance, as a String

◆ GetDefaultJustification()

virtual PdfNumber iText.Forms.PdfAcroForm.GetDefaultJustification ( )
inlinevirtual

Gets the Q integer property on the AcroForm.

Gets the Q integer property on the AcroForm.
This method gets the default (fallback value) for the Q attribute of variable text form field s.

Returns
an integer representing a justification value
See also
iText.Forms.Fields.PdfFormField.GetJustification()

◆ GetDefaultResources()

virtual PdfDictionary iText.Forms.PdfAcroForm.GetDefaultResources ( )
inlinevirtual

Gets the DR dictionary property on the AcroForm.

Gets the DR dictionary property on the AcroForm.

DR is a resource dictionary containing default resources (such as fonts, patterns, or colour spaces) that shall be used by form field appearance streams. At a minimum, this dictionary shall contain a Font entry specifying the resource name and font dictionary of the default font for displaying text. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Returns
a resource dictionary

◆ GetField()

virtual PdfFormField iText.Forms.PdfAcroForm.GetField ( String  fieldName )
inlinevirtual

Gets a form field by its name.

Parameters
fieldName the name of the form field to retrieve
Returns
the form field , or null if it isn't present

◆ GetFieldsForFlattening()

virtual ICollection<PdfFormField> iText.Forms.PdfAcroForm.GetFieldsForFlattening ( )
inlinevirtual

Gets a collection of form field s, prepared for flattening using PartialFormFlattening(System.String) method.

Gets a collection of form field s, prepared for flattening using PartialFormFlattening(System.String) method. If returned collection is empty, all form fields will be flattened on flattenFields call.

Returns
a collection of form field s for flattening

◆ GetFormFields()

virtual IDictionary<String, PdfFormField> iText.Forms.PdfAcroForm.GetFormFields ( )
inlinevirtual

Gets the form field s as a System.Collections.IDictionary<K, V>.

Returns
a map of field names and their associated form field objects

◆ GetNeedAppearances()

virtual PdfBoolean iText.Forms.PdfAcroForm.GetNeedAppearances ( )
inlinevirtual

Gets the NeedAppearances boolean property on the AcroForm.

Gets the NeedAppearances boolean property on the AcroForm. NeedAppearances has been deprecated in PDF 2.0.

NeedAppearances is a flag specifying whether to construct appearance streams and appearance dictionaries for all widget annotations in the document. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Returns
the NeedAppearances property as a iText.Kernel.Pdf.PdfBoolean . Default value is false

◆ GetPdfDocument()

virtual PdfDocument iText.Forms.PdfAcroForm.GetPdfDocument ( )
inlinevirtual

Gets the iText.Kernel.Pdf.PdfDocument this PdfAcroForm belongs to.

Returns
the document of this form

◆ GetSignatureFlags()

virtual int iText.Forms.PdfAcroForm.GetSignatureFlags ( )
inlinevirtual

Gets the SigFlags integer property on the AcroForm.

Gets the SigFlags integer property on the AcroForm.

SigFlags is a set of flags specifying various document-level characteristics related to signature fields (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Returns
current value for SigFlags.

◆ GetXfaForm()

virtual XfaForm iText.Forms.PdfAcroForm.GetXfaForm ( )
inlinevirtual

Gets the iText.Forms.Xfa.XfaForm atribute.

Returns
the XFA form object

◆ GetXFAResource()

virtual PdfObject iText.Forms.PdfAcroForm.GetXFAResource ( )
inlinevirtual

Gets the XFA property on the AcroForm.

Returns
an object representing the entire XDP. It can either be a iText.Kernel.Pdf.PdfStream or a iText.Kernel.Pdf.PdfArray.

◆ HasXfaForm()

virtual bool iText.Forms.PdfAcroForm.HasXfaForm ( )
inlinevirtual

Determines whether the AcroForm contains XFA data.

Returns
a boolean

◆ IsGenerateAppearance()

virtual bool iText.Forms.PdfAcroForm.IsGenerateAppearance ( )
inlinevirtual

Gets the attribute generateAppearance, which tells FlattenFields() to generate an appearance Stream for all form field s that don't have one.

Returns
bolean value indicating if the appearances need to be generated

◆ IsWrappedObjectMustBeIndirect()

override bool iText.Forms.PdfAcroForm.IsWrappedObjectMustBeIndirect ( )
inlineprotectedvirtual

Defines if the object behind this wrapper must be an indirect object in the resultant document.

Defines if the object behind this wrapper must be an indirect object in the resultant document.

If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.

Return value of this method shouldn't depend on any logic, it should return always true or false.

Returns
true if in the resultant document the object behind the wrapper must be indirect, otherwise false.

Implements iText.Kernel.Pdf.PdfObjectWrapper< PdfDictionary >.

◆ PartialFormFlattening()

virtual void iText.Forms.PdfAcroForm.PartialFormFlattening ( String  fieldName )
inlinevirtual

Adds a form field , identified by name, to the list of fields to be flattened.

Adds a form field , identified by name, to the list of fields to be flattened. Does not perform a flattening operation in itself.

Parameters
fieldName the name of the form field to be flattened

◆ Release()

virtual void iText.Forms.PdfAcroForm.Release ( )
inlinevirtual

Releases underlying pdf object and other pdf entities used by wrapper.

Releases underlying pdf object and other pdf entities used by wrapper. This method should be called instead of direct call to iText.Kernel.Pdf.PdfObject.Release() if the wrapper is used.

◆ RemoveField()

virtual bool iText.Forms.PdfAcroForm.RemoveField ( String  fieldName )
inlinevirtual

Tries to remove the form field with the specified name from the document.

Parameters
fieldName the name of the form field to remove
Returns
a boolean representing whether or not the removal succeeded.

◆ RemoveXfaForm()

virtual void iText.Forms.PdfAcroForm.RemoveXfaForm ( )
inlinevirtual

Removes the XFA stream from the document.

◆ RenameField()

virtual void iText.Forms.PdfAcroForm.RenameField ( String  oldName,
String  newName 
)
inlinevirtual

Changes the identifier of a form field.

Parameters
oldName the current name of the field
newName the new name of the field. Must not be used currently.

◆ ReplaceField()

virtual void iText.Forms.PdfAcroForm.ReplaceField ( String  name,
PdfFormField  field 
)
inlinevirtual

Replaces the iText.Forms.Fields.PdfFormField of a certain name with another iText.Forms.Fields.PdfFormField.

Parameters
name the name of the form field to be replaced
field the new iText.Forms.Fields.PdfFormField

◆ SetCalculationOrder()

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetCalculationOrder ( PdfArray  calculationOrder )
inlinevirtual

Sets the CO array property on the AcroForm.

Sets the CO array property on the AcroForm.

CO, Calculation Order, is an array of indirect references to field dictionaries with calculation actions, defining the calculation order in which their values will be recalculated when the value of any field changes (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Parameters
calculationOrder an array of indirect references
Returns
current AcroForm

◆ SetDefaultAppearance()

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetDefaultAppearance ( String  appearance )
inlinevirtual

Sets the DA String property on the AcroForm.

Sets the DA String property on the AcroForm.
This method sets a default (fallback value) for the DA attribute of variable text form field s.

Parameters
appearance a String containing a sequence of valid PDF syntax
Returns
current AcroForm
See also
iText.Forms.Fields.PdfFormField.SetDefaultAppearance(System.String)

◆ SetDefaultJustification()

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetDefaultJustification ( int  justification )
inlinevirtual

Sets the Q integer property on the AcroForm.

Sets the Q integer property on the AcroForm.
This method sets a default (fallback value) for the Q attribute of variable text form field s.

Parameters
justification an integer representing a justification value
Returns
current AcroForm
See also
iText.Forms.Fields.PdfFormField.SetJustification(int)

◆ SetDefaultResources()

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetDefaultResources ( PdfDictionary  defaultResources )
inlinevirtual

Sets the DR dictionary property on the AcroForm.

Sets the DR dictionary property on the AcroForm.

DR is a resource dictionary containing default resources (such as fonts, patterns, or colour spaces) that shall be used by form field appearance streams. At a minimum, this dictionary shall contain a Font entry specifying the resource name and font dictionary of the default font for displaying text. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Parameters
defaultResources a resource dictionary
Returns
current AcroForm

◆ SetGenerateAppearance()

virtual void iText.Forms.PdfAcroForm.SetGenerateAppearance ( bool  generateAppearance )
inlinevirtual

Sets the attribute generateAppearance, which tells FlattenFields() to generate an appearance Stream for all form field s that don't have one.

Sets the attribute generateAppearance, which tells FlattenFields() to generate an appearance Stream for all form field s that don't have one.

Not generating appearances will speed up form flattening but the results can be unexpected in Acrobat. Don't use it unless your environment is well controlled. The default is true.

If generateAppearance is set to true, then NeedAppearances is set to false. This does not apply vice versa.

Note, this method does not change default behaviour of iText.Forms.Fields.PdfFormField.SetValue(System.String) method.

Parameters
generateAppearance a boolean

◆ SetNeedAppearances()

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetNeedAppearances ( bool  needAppearances )
inlinevirtual

Sets the NeedAppearances boolean property on the AcroForm.

Sets the NeedAppearances boolean property on the AcroForm. NeedAppearances has been deprecated in PDF 2.0.

NeedAppearances is a flag specifying whether to construct appearance streams and appearance dictionaries for all widget annotations in the document. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Parameters
needAppearances a boolean. Default value is false
Returns
current AcroForm.

◆ SetSignatureFlag()

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetSignatureFlag ( int  sigFlag )
inlinevirtual

Changes the SigFlags integer property on the AcroForm.

Changes the SigFlags integer property on the AcroForm. This method allows only to add flags, not to remove them.

SigFlags is a set of flags specifying various document-level characteristics related to signature fields. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Parameters
sigFlag an integer. Use SIGNATURE_EXIST and/or APPEND_ONLY. Use bitwise OR operator to combine these values. Default is 0
Returns
current AcroForm.

◆ SetSignatureFlags()

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetSignatureFlags ( int  sigFlags )
inlinevirtual

Sets the SigFlags integer property on the AcroForm.

Sets the SigFlags integer property on the AcroForm.

SigFlags is a set of flags specifying various document-level characteristics related to signature fields. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

Parameters
sigFlags an integer. Use SIGNATURE_EXIST and/or APPEND_ONLY. Use bitwise OR operator to combine these values. Default value is 0
Returns
current AcroForm.

◆ SetXFAResource() [1/2]

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetXFAResource ( PdfArray  xfaResource )
inlinevirtual

Sets the XFA property on the AcroForm.

Sets the XFA property on the AcroForm.
XFA can either be a iText.Kernel.Pdf.PdfStream or a iText.Kernel.Pdf.PdfArray. Its contents must be valid XFA.

Parameters
xfaResource an array of text string and stream pairs representing the individual packets comprising the XML Data Package. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")
Returns
current AcroForm

◆ SetXFAResource() [2/2]

virtual iText.Forms.PdfAcroForm iText.Forms.PdfAcroForm.SetXFAResource ( PdfStream  xfaResource )
inlinevirtual

Sets the XFA property on the AcroForm.

Sets the XFA property on the AcroForm.
XFA can either be a iText.Kernel.Pdf.PdfStream or a iText.Kernel.Pdf.PdfArray. Its contents must be valid XFA.

Parameters
xfaResource a stream containing the XDP
Returns
current AcroForm

Member Data Documentation

◆ APPEND_ONLY

const int iText.Forms.PdfAcroForm.APPEND_ONLY = 2
static

To be used with SetSignatureFlags(int).

To be used with SetSignatureFlags(int).

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. Merely updating the file by appending new information to the end of the previous version is safe. Conforming readers may use this flag to inform a user requesting a full save that signatures will be invalidated and require explicit confirmation before continuing with the operation. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")

◆ SIGNATURE_EXIST

const int iText.Forms.PdfAcroForm.SIGNATURE_EXIST = 1
static

To be used with SetSignatureFlags(int).

To be used with SetSignatureFlags(int).

If set, the document contains at least one signature field. This flag allows a conforming reader to enable user interface items (such as menu items or pushbuttons) related to signature processing without having to scan the entire document for the presence of signature fields. (ISO 32000-1, section 12.7.2 "Interactive Form Dictionary")