SetaPDF_FormFiller_Field_Text A text field

File: /SetaPDF v2/FormFiller/Field/Text.php

Class hierarchy

Uses

Implements

Summary

Constants

OVERFLOWS_HORIZONTALLY

Constant saying that text overflows horizontally

OVERFLOWS_NONE

Constant saying that no text overflows the visible area

OVERFLOWS_VERTICALLY

Constant saying that text overflows vertically


Properties

$_annotation

$_appearanceCanvas

The canvas object of the appearance

$_appearanceCreated

$_appearanceValueCallback

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

$_fieldDictionary

$_fieldObject

$_fields

A reference to the fields instance

$_font

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

$_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

$_observeTextOverflow

Defines whether observing text overflow is enabled or not

$_originalQualifiedName

The name without the suffix

$_page

The page instance on which the form field is placed

$_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

$_textOverflow

Flag indicating that the text overflows the visible area of the field.

$_textTranslateData

Data to be used for translation of the initial x/y coordinates of the field appearance.


Methods

__construct()

public SetaPDF_FormFiller_Field_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 SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

_checkPermission()

Checks for form-filling permissions.

Parameters
$permission : integer
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_getAppearanceReference()

Get the reference to the normal appearance stream object.

_getBorderWidthAndStyle()

Resolve the border width and style

Exceptions

Throws SetaPDF_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 SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_getTDictionary()

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

_postDelete()

A method called after deleting a field.

This method forwards the deletion info to the fields instance.

_preDelete()

A method called before deleting a field.

This method forwards the deletion info to the fields instance.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_preFlatten()

A method called before flattening a field.

This method forwards the flatten info to the fields instance.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_purgeValue()

protected SetaPDF_FormFiller_Field_Text::_purgeValue (
string $value
): string

Purges the value accoring to field properties like "multiline" or "max-length".

Parameters
$value : string

Value in UTF-16BE encoding

_recreateAppearance()

protected SetaPDF_FormFiller_Field_AbstractField::_recreateAppearance (
[ bool $circle = false [, null|SetaPDF_Core_Canvas $canvas = null ]]
): SetaPDF_Core_Canvas

Recreate or creates the background appearance of the form field.

Parameters
$circle : bool
 
$canvas : null|SetaPDF_Core_Canvas
 
Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Exception_NotImplemented

cleanUp()

public SetaPDF_FormFiller_Field_Text::cleanUp (
void
): void

Release cycled references and release memory.

flatten()

public SetaPDF_FormFiller_Field_AbstractField::flatten (
[ boolean $recreateAppearanceIfNeedAppearancesIsSet = false ]
): void

Flatten the field to the pages content stream.

Parameters
$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_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception

Throws SetaPDF_Exception_NotImplemented

See

getAdditionalActions()

Gets the additional actions object instance for this field.

getAlign()

Get the field alignment.

getAnnotation()

Get the widget annotation object from this field.

Exceptions

Throws SetaPDF_Core_Type_Exception

getAppearanceCanvas()

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

Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Exception_NotImplemented

getAppearanceTextColorSpace()

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

getAppearanceValue()

public SetaPDF_FormFiller_Field_Text::getAppearanceValue (
[ string $encoding = 'UTF-8' ]
): string

Get the appearance value.

Parameters
$encoding : string
 

getDefaultValue()

public SetaPDF_FormFiller_Field_Text::getDefaultValue (
[ string $encoding = 'UTF-8' ]
): null|string

Returns the default value of the field.

This value is used if the form is reset.

Parameters
$encoding : string
 
See

getFieldDictionary()

getFieldFlags()

Returns the current field flags.

getFieldObject()

Get the indirect object of the form field.

getFields()

getLineHeightFactor()

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 SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

See

getMaxLength()

public SetaPDF_FormFiller_Field_Text::getMaxLength (
void
): boolean|integer

Get the max length property if available.

getName()

getNoExport()

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

Pass true to force a recreation

Exceptions

Throws SetaPDF_Core_Type_Exception

getObserveTextOverflow()

Get whether observing text overflow is enabled or not.

getOriginalQualifiedName()

Get the original qualified name (without suffix).

getPage()

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

Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_FormFiller_Field_Exception

getQualifiedName()

Returns the qualified name.

getTextOverflow()

public SetaPDF_FormFiller_Field_Text::getTextOverflow (
void
): null|integer

Check if the visible text overflows the visible area.

Return Values

If text does not overflow 0 is returned. Otherwise 1 if the text overflows vertically or 2 if the text overflows horizontally. 3 for both. Null is returned if the overflow is not calculated yet.

getTooltip()

public SetaPDF_FormFiller_Field_AbstractField::getTooltip (
[ string $encoding = 'UTF-8' ]
): bool|string

Get the tooltip value.

Parameters
$encoding : string
 

getValue()

public SetaPDF_FormFiller_Field_Text::getValue (
[ string $encoding = 'UTF-8' ]
): string

Get the field value.

Parameters
$encoding : string

The output encoding

See

getVisibleValue()

public SetaPDF_FormFiller_Field_Text::getVisibleValue (
[ string $encoding = 'UTF-8' ]
): string

Returns the field specific visible value.

Parameters
$encoding : string
 

isCombField()

public SetaPDF_FormFiller_Field_Text::isCombField (
void
): boolean

Check if the comb field flag is set.

isDoNotScrollSet()

Check if the "do not scroll" flag is set.

isDoNotSpellCheckSet()

Check if the "do not spell check" flag is set.

isFieldFlagSet()

public SetaPDF_FormFiller_Field_AbstractField::isFieldFlagSet (
integer $flag
): boolean

Checks if a specific field flag is set.

Parameters
$flag : integer
 

isMultiline()

public SetaPDF_FormFiller_Field_Text::isMultiline (
void
): boolean

Check if the multiline flag is set.

isPasswordField()

Check if the password field flag is set.

isReadOnly()

Checks if the field is set to read-only.

isRequired()

Checks if the field is set to be required.

setAlign()

public SetaPDF_FormFiller_Field_VariableTextTrait::setAlign (
string $align [, bool $recreateAppearanceOnChange = true ]
): void

Set the field alignment.

Parameters
$align : string

Possible values are: SetaPDF_Core_Text::ALIGN_LEFT, SetaPDF_Core_Text::ALIGN_CENTER, SetaPDF_Core_Text::ALIGN_RIGHT.

$recreateAppearanceOnChange : bool
 
Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

setAppearanceFont()

Set the appearance font object.

Parameters
$font : SetaPDF_Core_Font_FontInterface
 
$size : float
 

setAppearanceFontSize()

public SetaPDF_FormFiller_Field_AbstractField::setAppearanceFontSize (
float|null $fontSize
): void

Set an individual font size.

Parameters
$fontSize : float|null
 

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|null
 

setAppearanceValueCallback()

public SetaPDF_FormFiller_Field_Text::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
 

setCombField()

public SetaPDF_FormFiller_Field_Text::setCombField (
[ boolean $comb = true ]
): void

Set the comb field flag.

Changing this flag will re-create the field appearance.

Parameters
$comb : boolean
 
Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

setDefaultValue()

public SetaPDF_FormFiller_Field_Text::setDefaultValue (
null|string $value [, string $encoding = 'UTF-8' ]
): void

Set the default value of the field.

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

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_FormFiller_Exception

setDoNotScroll()

public SetaPDF_FormFiller_Field_Text::setDoNotScroll (
[ boolean $doNotScroll = true ]
): void

Set the "do not scroll" flag.

Parameters
$doNotScroll : boolean
 

setDoNotSpellCheck()

public SetaPDF_FormFiller_Field_Text::setDoNotSpellCheck (
[ boolean $doNotSpellCheck = true ]
): void

Set the "do not spell check" flag.

Parameters
$doNotSpellCheck : boolean
 
Exceptions

Throws SetaPDF_FormFiller_Field_Exception

setFieldFlags()

public SetaPDF_FormFiller_Field_AbstractField::setFieldFlags (
integer $flags [, boolean|null $add = true ]
): void

Sets a field flag.

Parameters
$flags : integer
 
$add : boolean|null

Add = true, remove = false, set = null

setLineHeightFactor()

public SetaPDF_FormFiller_Field_AbstractField::setLineHeightFactor (
null|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 : null|float
 
See

setMaxLength()

public SetaPDF_FormFiller_Field_Text::setMaxLength (
integer $maxLength
): void

Set the max length property.

Changing this flag will reset the value to a value that fits into the given maximal length.

Parameters
$maxLength : integer
 
Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

setMultiline()

public SetaPDF_FormFiller_Field_Text::setMultiline (
[ bool|true $multiline = true ]
): void

Set the multiline flag.

Changing this flag will re-create the field appearance.

Parameters
$multiline : bool|true
 
Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

setNoExport()

public SetaPDF_FormFiller_Field_AbstractField::setNoExport (
[ boolean $noExport = true ]
): void

Set the no-export flag.

Parameters
$noExport : boolean
 

setObserveTextOverflow()

public SetaPDF_FormFiller_Field_Text::setObserveTextOverflow (
boolean $observeTextOverflow
): void

Set whether observing text overflow is enabled or not.

Parameters
$observeTextOverflow : boolean
 

setPasswordField()

public SetaPDF_FormFiller_Field_Text::setPasswordField (
[ boolean $password = true ]
): void

Set the password field flag.

Changing this flag will re-create the field appearance.

Parameters
$password : boolean
 
Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

setReadOnly()

public SetaPDF_FormFiller_Field_AbstractField::setReadOnly (
[ boolean $readOnly = true ]
): void

Sets the read-only flag.

Parameters
$readOnly : boolean
 
Exceptions

Throws DOMException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

setRequired()

public SetaPDF_FormFiller_Field_AbstractField::setRequired (
[ boolean $required = true ]
): void

Sets the required flag.

Parameters
$required : boolean
 

setTextTranslate()

public SetaPDF_FormFiller_Field_Text::setTextTranslate (
[ integer $x = 0 [, integer $y = 0 ]]
): void

Set translate data for the text appearance.

Parameters
$x : integer

The value by which the text should be translated on the abscissa.

$y : integer

The value by which the text should be translated on the ordinate.

setTooltip()

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

Set the tooltip value.

Parameters
$value : string|false
 
$encoding : string
 

setValue()

public SetaPDF_FormFiller_Field_Text::setValue (
string $value [, string $encoding = 'UTF-8' ]
): void

Set the field value.

If the fields multiline flag is set (see isMultiline()) the method accepts a string of several lines.

All common line delimiters are possible: \r\n, \n or \r

Internally they get normalized. So if you need to compare a value of the getValue() method keep this in mind.

Parameters
$value : string

The text field value

$encoding : string

The input encoding

Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Parser_Pdf_InvalidTokenException

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_FormFiller_Exception

Throws SetaPDF_FormFiller_Field_Exception

unsetFieldFlags()

Removes a field flag.

Parameters
$flags : integer