setasign\SetaPDF2\FormFiller

Xfa Class offering access to XFA data of a PDF form.

File: /SetaPDF v2/FormFiller/Xfa.php
Old class name (alias): \SetaPDF_FormFiller_Xfa

Class hierarchy

Summary

Properties

$_bridge

The bridge instance.

$_data

protected \DOMNode Xfa::$_data

The data node.

$_dataNodeUpdated

protected bool Xfa::$_dataNodeUpdated = false

Flag indicating if the data has to be set back to the data stream on save.

$_domDocument

The document instance of the full XDP packet.

$_form

protected \DOMNode Xfa::$_form

The form node.

$_formFiller

The form filler instance

$_setValueIsActive

protected bool Xfa::$_setValueIsActive = false

Flag identicating that a setValue() process is working.

$_template

protected \DOMNode Xfa::$_template

The template node.

$_templateNodeUpdated

protected bool Xfa::$_templateNodeUpdated = false

Flag indicating that the template node was changed.


Methods

__construct()

public Xfa::__construct (
\SetaPDF_FormFiller $formFiller
)

The constructor.

Parameters
$formFiller : \SetaPDF_FormFiller

The form filler instance

_evaluateValue()

private Xfa::_evaluateValue (
mixed $value,
\DOMElement $fieldNode
): \DOMNode|string

Evaluates a native value to a data value.

Parameters
$value : mixed
 
$fieldNode : \DOMElement
 

_findPacketStream()

private Xfa::_findPacketStream (
\SetaPDF_Core_Type_Array $array,
string $name,
bool $create = false
): bool|\SetaPDF_Core_Type_Stream

Finds a packets stream by its name.

Parameters
$array : \SetaPDF_Core_Type_Array
 
$name : string
 
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_setValueInForm()

protected Xfa::_setValueInForm (
string $fieldName,
mixed $value
): bool

Creates the data node and sets the value in the form package.

Parameters
$fieldName : string
 
$value : mixed
 
Exceptions

Throws \DOMException

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws Exception

cleanUp()

public Xfa::cleanUp (
void
): void

Releases memory and resources.

getData()

public Xfa::getData (
bool $create = false
): bool|\DOMElement

Get the data node.

Parameters
$create : bool
 
Exceptions

Throws \DOMException

Throws Exception

getDomDocument()

getFormFiller()

Get the form filler instance.

getFormNodeChecksum()

public Xfa::getFormNodeChecksum (
void
): string

Calculate and get the checksum for the form node.

Exceptions

Throws Exception

getTemplate()

public Xfa::getTemplate (
void
): bool|\DOMElement

Gets the template node from the XFA structure.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws Exception

getXml()

public Xfa::getXml (
void
): bool|string

Get the raw XFA (XML/XMP) data from the PDF document.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getXmp()

public Xfa::getXmp (
void
): bool|string

Get the raw XFA (XML/XMP) from the PDF document.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

See

isDynamic()

public Xfa::isDynamic (
void
): bool

Checks if the XFA form is a dynamic or static form.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

saveFormNode()

saveTemplate()

public Xfa::saveTemplate (
bool $onlyIfUpdated = false
): bool

Saves the template node to the PDF structure.

Parameters
$onlyIfUpdated : bool

Save only if the template node was updated internally.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws Exception

setData()

public Xfa::setData (
?string $xml
): void

Set the content of the data node.

Parameters
$xml : ?string
 
Exceptions

Throws Exception

Throws \Exception

setDefaultValue()

public Xfa::setDefaultValue (
string $fieldName,
mixed $value,
string $encoding = 'UTF-8'
): bool

Set the default value for a specific field.

Parameters
$fieldName : string
 
$value : mixed
 
$encoding : string
 
Exceptions

Throws \DOMException

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws Exception

setReadOnly()

public Xfa::setReadOnly (
string $fieldName,
bool $readOnly
): bool

Set a field to read-only or to "open".

This method is called internally by the Field\AbstractField::setReadOnly() method.

Parameters
$fieldName : string
 
$readOnly : bool
 
Exceptions

Throws \DOMException

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws Exception

setValue()

public Xfa::setValue (
string $fieldName,
mixed $value,
string $encoding = 'UTF-8'
): bool

Sets a value by a field name.

This method is called internally if a fields value is changed to keep the XML data in sync. It should be used manually with care.

Parameters
$fieldName : string
 
$value : mixed
 
$encoding : string
 
Exceptions

Throws \DOMException

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\Core\Parser\Pdf\InvalidTokenException

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

Throws Field\Exception

setXml()

public Xfa::setXml (
\DOMDocument|string $domDocumentOrXml
): void

Set the raw XFA (XML/XMP) structure.

Parameters
$domDocumentOrXml : \DOMDocument|string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws Exception

setXmp()

public Xfa::setXmp (
\DOMDocument|string $domDocumentOrXml
): void

Set the raw XFA (XML/XMP) structure.

Parameters
$domDocumentOrXml : \DOMDocument|string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws Exception

See

syncAcroFormFields()

public Xfa::syncAcroFormFields (
void
): void

Syncornizes the XFA form field values with the corresponding AcroForm fields.

If XML data were passed via the Xfa::setData() method this method will ensure that the data in the corresponding AcroForm fields representations will get updated.

Exceptions

Throws \DOMException

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\Core\Parser\Pdf\InvalidTokenException

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

Throws Field\Exception

syncDataNode()

public Xfa::syncDataNode (
void
): bool

Writes the data node back to the PDF document.

Exceptions

Throws \DOMException

Throws Exception