setasign\SetaPDF2\FormFiller\Field

ComboField A combo box

File: /SetaPDF v2/FormFiller/Field/ComboField.php
Old class name (alias): \SetaPDF_FormFiller_Field_Combo

Class hierarchy

Implements

Summary

Properties

$_annotation

The annotation object of this form field

$_appearanceCanvas

The canvas object of the appearance

$_appearanceCreated

protected bool AbstractField::$_appearanceCreated = false

$_appearanceValueCallback

protected callback ComboField::$_appearanceValueCallback = array(...)

A callback that may change the appearance value (e.g. format a number)

$_exportValues

protected array AbstractChoice::$_exportValues = array()

The plain export values in the original encoding

$_fieldDictionary

The main field dictionary

$_fieldObject

The fields indirect object

$_fields

A reference to the fields instance

$_font

The font object, which should be used to create the appearance

$_fontSize

protected ?float AbstractField::$_fontSize

The font size, which should be used to create the appearance

$_lineHeightFactor

The factor to calculate the line height based on the font size

$_originalQualifiedName

The name without the suffix

$_page

The page instance on which the form field is placed

$_qualifiedName

protected string AbstractField::$_qualifiedName

The name including a suffix if needed ("Text#1")

$_textColor

An individual color object which should be used for drawing the text appearance

$_textColorSpace

An individual color space object which should be used for setting the non-stroking color space


Methods

__construct()

public AbstractField::__construct (
\SetaPDF_FormFiller_Fields $fields,
string $qualifiedName,
\SetaPDF_Core_Type_IndirectObject $fieldObject,
string $originalQualifiedName = null
)

The constructor.

Parameters
$fields : \SetaPDF_FormFiller_Fields

The fields instance

$qualifiedName : string

The qualified name of the field

$fieldObject : \SetaPDF_Core_Type_IndirectObject

The indirect object holding the field dictionary (terminal field object)

$originalQualifiedName : string

The original qualified name of the field

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

_checkPermission()

Checks for form-filling permissions.

Parameters
$permission : int
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

_getAppearanceReference()

Get the reference to the normal appearance stream object.

_getBorderWidthAndStyle()

protected AbstractField::_getBorderWidthAndStyle (
void
): array

Resolve the border width and style

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_getFontRelation()

Get the font relation and copy the resources to the Resources entry if needed.

Parameters
$nDictionary : \SetaPDF_Core_Type_Dictionary
 
$fontName : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_getTDictionary()

Get the dictionary that holds the last "T" entry.

_postDelete()

protected AbstractField::_postDelete (
void
): void

A method called after deleting a field.

This method forwards the deletion info to the fields instance.

_preDelete()

protected AbstractField::_preDelete (
void
): void

A method called before deleting a field.

This method forwards the deletion info to the fields instance.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_preFlatten()

protected AbstractField::_preFlatten (
void
): void

A method called before flattening a field.

This method forwards the flatten info to the fields instance.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_recreateAppearance()

protected AbstractField::_recreateAppearance (
bool $circle = false,
?\SetaPDF_Core_Canvas $canvas = null
): \SetaPDF_Core_Canvas

Recreate or creates the background appearance of the form field.

Parameters
$circle : bool
 
$canvas : ?\SetaPDF_Core_Canvas
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

cleanUp()

public AbstractChoice::cleanUp (
void
): void

Release cycled references and release memory.

flatten()

public AbstractField::flatten (
bool $recreateAppearanceIfNeedAppearancesIsSet = false
): void

Flatten the field to the pages content stream.

Parameters
$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\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

See

getAdditionalActions()

Gets the additional actions object instance for this field.

getAnnotation()

Get the widget annotation object from this field.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getAppearanceCanvas()

Get the appearance canvas of the "normal" appearance object.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getAppearanceTextColorSpace()

Get the individual color space object which should be used for setting the non-stroking color space.

getDefaultValue()

public ComboField::getDefaultValue (
string $encoding = 'UTF-8'
): ?string

Returns the default value of the field.

This value is used if the form is reset

Parameters
$encoding : string
 
See

getFieldDictionary()

Get the field dictionary.

getFieldFlags()

public AbstractField::getFieldFlags (
void
): int

Returns the current field flags.

getFieldObject()

Get the indirect object of the form field.

getFields()

Get the fields instance.

getLineHeightFactor()

public AbstractField::getLineHeightFactor (
void
): float

Get the line height factor

The line height is calculated by this factor in relation to the font size:

$lineHeight = $fontSize * $lineHeightFactor

By default, this value is calculated by the font bounding box values "ury - lly / 1000".

Exceptions

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\NotImplementedException

Throws \setasign\SetaPDF2\FormFiller\Exception

Throws Exception

See

getName()

public AbstractField::getName (
void
): string

Alias for getQualifiedName().

See

getNoExport()

public AbstractField::getNoExport (
void
): bool

Checks if the no-export flag is set.

getNormalAppearanceObject()

Get or create the normal appearance object (the object referenced in the N entry).

Parameters
$createNew : bool

Pass true to force a recreation

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getOptions()

public AbstractChoice::getOptions (
string $encoding = 'UTF-8'
): array

Get the options and the export values.

Parameters
$encoding : string

The output encoding

Return Values

An array of arrays with following keys: visibleValue and exportValue

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getOriginalQualifiedName()

public AbstractField::getOriginalQualifiedName (
void
): string

Get the original qualified name (without suffix).

getPage()

Gets the page object on which the form field is placed.

Exceptions

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws Exception

getQualifiedName()

public AbstractField::getQualifiedName (
void
): string

Returns the qualified name.

getTooltip()

public AbstractField::getTooltip (
string $encoding = 'UTF-8'
): bool|string

Get the tooltip value.

Parameters
$encoding : string
 

getValue()

public ComboField::getValue (
string $encoding = 'UTF-8'
): ?string

Get the current value

Parameters
$encoding : string

The output encoding

Return Values

If no value is selected null will be returned otherwise a string.

getVisibleValue()

public ComboField::getVisibleValue (
string $encoding = 'UTF-8'
): string

Get the visible value of the current selected option

Parameters
$encoding : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

isEditable()

public ComboField::isEditable (
void
): bool

Checks if the combo box shall include an editable text box as well to a drop-down list

isFieldFlagSet()

public AbstractField::isFieldFlagSet (
int $flag
): bool

Checks if a specific field flag is set.

Parameters
$flag : int
 

isReadOnly()

public AbstractField::isReadOnly (
void
): bool

Checks if the field is set to read-only.

isRequired()

public AbstractField::isRequired (
void
): bool

Checks if the field is set to be required.

setAppearanceFont()

public AbstractField::setAppearanceFont (
\SetaPDF_Core_Font_FontInterface $font,
float $size = null
): void

Set the appearance font object.

Parameters
$font : \SetaPDF_Core_Font_FontInterface
 
$size : float
 

setAppearanceFontSize()

public AbstractField::setAppearanceFontSize (
?float $fontSize
): void

Set an individual font size.

Parameters
$fontSize : ?float
 

setAppearanceTextColor()

Set an individual appearance text color.

Parameters
$textColor : ?\SetaPDF_Core_DataStructure_Color
 

setAppearanceTextColorSpace()

Set the individual color space object which should be used for setting the non-stroking color space.

Parameters
$colorSpace : ?\SetaPDF_Core_ColorSpace
 

setAppearanceValueCallback()

public ComboField::setAppearanceValueCallback (
callback $callback
): void

Set the appearance value callback (to e.g. format a number).

The callback will be called with 2 arguments:

  1. A reference to the field instance
  2. The requested encoding

It needs to return a value in the specified encoding (internal calls need UTF-16BE throughout).

Parameters
$callback : callback
 

setDefaultValue()

public ComboField::setDefaultValue (
null|string|int $value,
string $encoding = 'UTF-8'
): void

Set the default value of the field.

Parameters
$value : null|string|int
 
$encoding : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\FormFiller\Exception

setFieldFlags()

public AbstractField::setFieldFlags (
int $flags,
?bool $add = true
): void

Sets a field flag.

Parameters
$flags : int
 
$add : ?bool

Add = true, remove = false, set = null

setLineHeightFactor()

public AbstractField::setLineHeightFactor (
?float $lineHeightFactor
): void

Set the line height factor

The line height is calculated by this factor in relation to the font size:

$lineHeight = $fontSize * $lineHeightFactor

By default, this value is calculated by the font bounding box values "ury - lly / 1000".

Parameters
$lineHeightFactor : ?float
 
See

setNoExport()

public AbstractField::setNoExport (
bool $noExport = true
): void

Set the no-export flag.

Parameters
$noExport : bool
 

setReadOnly()

public AbstractField::setReadOnly (
bool $readOnly = true
): void

Sets the read-only flag.

Parameters
$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 \setasign\SetaPDF2\FormFiller\Exception

setRequired()

public AbstractField::setRequired (
bool $required = true
): void

Sets the required flag.

Parameters
$required : bool
 

setTooltip()

public AbstractField::setTooltip (
string|false $value,
string $encoding = 'UTF-8'
): void

Set the tooltip value.

Parameters
$value : string|false
 
$encoding : string
 

setValue()

public ComboField::setValue (
string|int $value,
string $encoding = 'UTF-8'
): void

Set the fields value / Selects the option

The value could be an export value of an option or the numeric index of an option, received by getOptions(). If the field is marked as an editable text field, it is also possible to pass a string.

Parameters
$value : string|int
 
$encoding : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Document\ObjectNotFoundException

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Font\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 \setasign\SetaPDF2\FormFiller\Exception

Throws Exception

unsetFieldFlags()

public AbstractField::unsetFieldFlags (
int $flags
): void

Removes a field flag.

Parameters
$flags : int