SetaPDF_FormFiller_Fields Class allowing transparent access to form fields of a PDF document

File: /SetaPDF v2/FormFiller/Fields.php

Class hierarchy

Implements

Summary

Properties

$_fieldObjects

protected array SetaPDF_FormFiller_Fields::$_fieldObjects = array()

The pdf object of each form field / collection (at PDF level)

$_fields

$_fieldsRead

protected boolean SetaPDF_FormFiller_Fields::$_fieldsRead = false

Flag defines that the fields are read from the document

$_formFiller

The form filler instance

$_forwardValue

protected boolean SetaPDF_FormFiller_Fields::$_forwardValue = false

Flag defines that the forwarding of setValue calls is active

$_handleAllFieldsActive

Defines whether a delete or flatten action is done for all available fields.

$_relatedFields

protected array SetaPDF_FormFiller_Fields::$_relatedFields = array()

An array of names of related fields


Methods

__construct()

The constructor.

Parameters
$formFiller : SetaPDF_FormFiller

The form filler instance

_readFormFields()

protected SetaPDF_FormFiller_Fields::_readFormFields (
void
): void

Reads the form field objects and prepares them for later usage.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

beforeFieldFlattenOrDelete()

cleanUp()

public SetaPDF_FormFiller_Fields::cleanUp (
void
): void

Releases memory and resources.

count()

delete()

public SetaPDF_FormFiller_Fields::delete (
[ null|string|SetaPDF_FormFiller_Field_FieldInterface $field = null ]
): void

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 SetaPDF_Core_Exception

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_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 SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_Core_SecHandler_Exception

flatten()

public SetaPDF_FormFiller_Fields::flatten (
[ null|string|SetaPDF_FormFiller_Field_FieldInterface $field = null [, boolean $recreateAppearanceIfNeedAppearancesIsSet = false ]]
): void

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 : boolean

Defines whether the field appearance is re-created if the NeedAppearances flag is set.

Exceptions

Throws SetaPDF_Core_Document_ObjectNotFoundException

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_Reader_Exception

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

forwardValueToRelated()

public SetaPDF_FormFiller_Fields::forwardValueToRelated (
mixed $value, SetaPDF_FormFiller_Field_FieldInterface $field [, string $encoding = 'UTF-8' [, string $method = 'setValue' ]]
): void

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 SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

get()

public SetaPDF_FormFiller_Fields::get (
string $name [, boolean $cache = true ]
): SetaPDF_FormFiller_Field_FieldInterface

Gets a single field by field name.

Parameters
$name : string

The name of the field

$cache : boolean

Cache the field instance in the fields object.

Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_Core_SecHandler_Exception

getAll()

Get all available field objects.

Parameters
$cache : boolean

Cache the field instance in the fields object.

Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_Core_SecHandler_Exception

getFormFiller()

Get the form filler instance.

getNames()

public SetaPDF_FormFiller_Fields::getNames (
void
): string[]

Get all available field names.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

getRelatedFieldNames()

public SetaPDF_FormFiller_Fields::getRelatedFieldNames (
string|SetaPDF_FormFiller_Field_FieldInterface $field [, boolean $leftOriginFieldName = true ]
): string[]

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 : boolean

Left the origin passed field in the resulting array or not

Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_Core_SecHandler_Exception

getRelatedFields()

Get all same named/related form fields.

Parameters
$field : SetaPDF_FormFiller_Field_FieldInterface|string

The initial field

$leftOriginField : boolean

Left the origin passed field in the resulting array or not

Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_Core_SecHandler_Exception

isForwardValueActive()

Returns whether the "forwarding"-flag is set active.

key()

public SetaPDF_FormFiller_Fields::key (
void
): string|null

Implementation of the Iterator interface.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

next()

public SetaPDF_FormFiller_Fields::next (
void
): void

Implementation of the Iterator interface.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

offsetExists()

public SetaPDF_FormFiller_Fields::offsetExists (
string $offset
): bool

Implementation of the ArrayAccess interface.

Parameters
$offset : string

An offset to check for

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

offsetGet()

Implementation of the ArrayAccess interface.

Parameters
$offset : string

The offset to retrieve

Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_Core_SecHandler_Exception

offsetSet()

public SetaPDF_FormFiller_Fields::offsetSet (
string $offset, mixed $value
): void

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()

public SetaPDF_FormFiller_Fields::offsetUnset (
string $offset
): void

Implementation of the ArrayAccess interface.

Parameters
$offset : string

The offset to unset

Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

onFieldDeleted()

This method is called when a field is deleted.

Parameters
$field : SetaPDF_FormFiller_Field_FieldInterface

The field instance that is deleted

release()

public SetaPDF_FormFiller_Fields::release (
string $name
): bool

Releases the cached instance of the field.

Parameters
$name : string

The field name.

Return Values

Whether the cached instance was removed or not.

rewind()

public SetaPDF_FormFiller_Fields::rewind (
void
): void

Implementation of the Iterator interface.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

valid()

public SetaPDF_FormFiller_Fields::valid (
void
): bool

Implementation of the Iterator interface.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception