setasign\SetaPDF2\FormFiller
Fields Class allowing transparent access to form fields of a PDF document
File: /SetaPDF v2/FormFiller/Fields.php
Old class name (alias):
\SetaPDF_FormFiller_Fields
Class hierarchy
Implements
Summary
Methods
- __construct()
- _readFormFields()
- beforeFieldFlattenOrDelete()
- cleanUp()
- count()
- current()
- delete()
- ensureIndividualAppearanceStreams()
- flatten()
- forwardValueToRelated()
- get()
- getAll()
- getFormFiller()
- getNames()
- getRelatedFieldNames()
- getRelatedFields()
- isForwardValueActive()
- key()
- next()
- offsetExists()
- offsetGet()
- offsetSet()
- offsetUnset()
- onFieldDeleted()
- release()
- rewind()
- valid()
Properties
$_formFiller
The form filler instance
$_handleAllFieldsActive
Defines whether a delete or flatten action is done for all available fields.
Methods
__construct()
_readFormFields()
Reads the form field objects and prepares them for later usage.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
beforeFieldFlattenOrDelete()
This method is called before a field is deleted.
Parameters
Exceptions
count()
Implementation of Countable.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
current()
Implementation of the Iterator interface.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
delete()
Delete a field.
Parameters
- $field : null|string|\SetaPDF_FormFiller_Field_FieldInterface
The name or an instance of the field, or null to delete all fields
Exceptions
Throws \setasign\SetaPDF2\Core\Exception
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
Throws Field\Exception
ensureIndividualAppearanceStreams()
Ensure that each field have it's own appearance stream.
Some PDFs share the appearance stream in different fields (e.g. for empty fields). This would make it impossible to fill these fields individually. This method checks for such fields and "repairs" them by creating a new empty appearance stream.
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
flatten()
bool $recreateAppearanceIfNeedAppearancesIsSet = false
Flatten a field to the pages content stream.
Parameters
- $field : null|string|\SetaPDF_FormFiller_Field_FieldInterface
The name or an instance of the field, or null to flatten all fields
- $recreateAppearanceIfNeedAppearancesIsSet : bool
Defines whether the field appearance is re-created if the NeedAppearances flag is set.
Exceptions
Throws \setasign\SetaPDF2\Core\Document\ObjectNotFoundException
Throws \setasign\SetaPDF2\Core\Exception
Throws \setasign\SetaPDF2\Core\Parser\Pdf\InvalidTokenException
Throws \setasign\SetaPDF2\Core\Reader\Exception
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws \setasign\SetaPDF2\Exception
Throws \setasign\SetaPDF2\NotImplementedException
Throws Exception
forwardValueToRelated()
\SetaPDF_FormFiller_Field_FieldInterface $field,
string $encoding = 'UTF-8',
string $method = 'setValue'
This method forwards a setValue call to related/same named form fields.
Parameters
- $value : mixed
The value
- $field : \SetaPDF_FormFiller_Field_FieldInterface
The initial form field, which was changed
- $encoding : string
The encoding of the value
- $method : string
The method that forwards the value
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
get()
Gets a single field by field name.
Parameters
- $name : string
The name of the field
- $cache : bool
Cache the field instance in the fields object.
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
getAll()
Get all available field objects.
Parameters
- $cache : bool
Cache the field instance in the fields object.
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
getNames()
Get all available field names.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
getRelatedFieldNames()
Get all names of related form fields.
Parameters
- $field : string|\SetaPDF_FormFiller_Field_FieldInterface
The name or an instance to get related form fields
- $leftOriginFieldName : bool
Left the origin passed field in the resulting array or not
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
getRelatedFields()
Get all same named/related form fields.
Parameters
- $field : \SetaPDF_FormFiller_Field_FieldInterface|string
The initial field
- $leftOriginField : bool
Left the origin passed field in the resulting array or not
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
key()
Implementation of the Iterator interface.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
next()
Implementation of the Iterator interface.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
offsetExists()
Implementation of the ArrayAccess interface.
Parameters
- $offset : string
An offset to check for
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
offsetGet()
Implementation of the ArrayAccess interface.
Parameters
- $offset : string
The offset to retrieve
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
offsetSet()
Implementation of the ArrayAccess interface.
Parameters
- $offset : string
The offset to assign the value to
- $value : mixed
The value to set
Exceptions
Throws \BadMethodCallException
offsetUnset()
Implementation of the ArrayAccess interface.
Parameters
- $offset : string
The offset to unset
Exceptions
Throws \setasign\SetaPDF2\Core\Exception
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
Throws Exception
Throws Field\Exception
onFieldDeleted()
This method is called when a field is deleted.
Parameters
- $field : \SetaPDF_FormFiller_Field_FieldInterface
The field instance that is deleted
rewind()
Implementation of the Iterator interface.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
valid()
Implementation of the Iterator interface.
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception