setasign\SetaPDF2\Signer

SignatureField Helper class to create/handle a signature field

File: /SetaPDF v2/Signer/SignatureField.php
Old class name (alias): \SetaPDF_Signer_SignatureField

Class hierarchy

Summary

Constants

DEFAULT_FIELD_NAME

public const string SignatureField::DEFAULT_FIELD_NAME = 'Signature'

The default signature field name

LOCK_DOCUMENT_ALL

public const string SignatureField::LOCK_DOCUMENT_ALL = 'All'

Lock value

See

LOCK_DOCUMENT_EXCLUDE

public const string SignatureField::LOCK_DOCUMENT_EXCLUDE = 'Exclude'

Lock value

See

LOCK_DOCUMENT_INCLUDE

public const string SignatureField::LOCK_DOCUMENT_INCLUDE = 'Include'

Lock value

See

LOCK_DOCUMENT_NONE

public const string SignatureField::LOCK_DOCUMENT_NONE = false

Lock value

See

POSITION_CENTER_BOTTOM

public const string SignatureField::POSITION_CENTER_BOTTOM = 'CB'

Position constant

POSITION_CENTER_MIDDLE

public const string SignatureField::POSITION_CENTER_MIDDLE = 'CM'

Position constant

POSITION_CENTER_TOP

public const string SignatureField::POSITION_CENTER_TOP = 'CT'

Position constant

POSITION_LEFT_BOTTOM

public const string SignatureField::POSITION_LEFT_BOTTOM = 'LB'

Position constant

POSITION_LEFT_MIDDLE

public const string SignatureField::POSITION_LEFT_MIDDLE = 'LM'

Position constant

POSITION_LEFT_TOP

public const string SignatureField::POSITION_LEFT_TOP = 'LT'

Position constant

POSITION_RIGHT_BOTTOM

public const string SignatureField::POSITION_RIGHT_BOTTOM = 'RB'

Position constant

POSITION_RIGHT_MIDDLE

public const string SignatureField::POSITION_RIGHT_MIDDLE = 'RM'

Position constant

POSITION_RIGHT_TOP

public const string SignatureField::POSITION_RIGHT_TOP = 'RT'

Position constant

TYPE_3D

Annotation type

TYPE_CARET

Annotation type

TYPE_CIRCLE

Annotation type

TYPE_FILE_ATTACHMENT

Annotation type

TYPE_FREE_TEXT

Annotation type

TYPE_HIGHLIGHT

Annotation type

TYPE_INK

Annotation type

TYPE_LINE

Annotation type

TYPE_LINK

Annotation type

TYPE_MOVIE

Annotation type

TYPE_POLYGON

Annotation type

TYPE_POLY_LINE

Annotation type

TYPE_POPUP

Annotation type

TYPE_PRINTER_MARK

Annotation type

TYPE_REDACT

Annotation type

TYPE_SCREEN

Annotation type

TYPE_SOUND

Annotation type

TYPE_SQUARE

Annotation type

TYPE_SQUIGGLY

Annotation type

TYPE_STAMP

Annotation type

TYPE_STRIKE_OUT

Annotation type

TYPE_TEXT

Annotation type

TYPE_TRAP_NET

Annotation type

TYPE_UNDERLINE

Annotation type

TYPE_WATERMARK

Annotation type

TYPE_WIDGET

Annotation type


Properties


Static Methods

_createAnnotationDictionary()

Creates an annotation dictionary with default values.

Parameters
$rect : \SetaPDF_Core_DataStructure_Rectangle|array
 
$subtype : string
 

_removeDocMDP()

Remove the DocMDP entry from the Perms dictionary if it is the value of the given signature field.

Parameters
$document : \SetaPDF_Core_Document
 
$field : \SetaPDF_Signer_SignatureField
 
Return Values

Wether the field value was used in the DocMDP entry or not.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

add()

public static SignatureField::add (
\SetaPDF_Core_Document $document,
string $fieldName = SignatureField::DEFAULT_FIELD_NAME,
int $pageNumber = 1,
int|string $xOrPosition = 0,
int|array $yOrTranslate = 0,
int $width = 0,
int $height = 0
): \SetaPDF_Signer_SignatureField

Adds a new signature field to a documents page.

It is possible to position the field relatively to the page boundary by passing a string value to the $xOrPosition parameter.

Additionally it is possible to define own x- and y-values through the desired parameter. Anyhow this will not take care of page rotation.

Parameters
$document : \SetaPDF_Core_Document
 
$fieldName : string

The field name in UTF-8 encoding

$pageNumber : int

The page number on which the signature field shall appear.

$xOrPosition : int|string

Integer with the x-position or SignatureField::POSITION_XXX

$yOrTranslate : int|array

Integer with the y-position (if $xOrPosition is an integer) or an array with the keys 'x' and 'y'

$width : int

Width of the signature field

$height : int

Height of the signature field

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

clear()

public static SignatureField::clear (
\SetaPDF_Core_Document $document,
string $fieldName,
bool $clearAppearance = true
): bool

Clears the signature from a signature field by its name.

Parameters
$document : \SetaPDF_Core_Document
 
$fieldName : string
 
$clearAppearance : bool

Define whether the appearance is cleared or not, too.

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

createAnnotationDictionary()

public static SignatureField::createAnnotationDictionary (
string $fieldName,
array|\SetaPDF_Core_DataStructure_Rectangle $rect = array ( 0 => 0, 1 => 0, 2 => 0, 3 => 0, )
): \SetaPDF_Core_Type_Dictionary

Function to create a signature field annotation dictionary.

Parameters
$fieldName : string

The field name in UTF-8 encoding.

$rect : array|\SetaPDF_Core_DataStructure_Rectangle
 
Exceptions

Throws \InvalidArgumentException

delete()

public static SignatureField::delete (
\SetaPDF_Core_Document $document,
string $fieldName
): bool

Deletes a signature field by its name.

ATTENTION: If there are other signature fields in use their signature will get invalid.

Parameters
$document : \SetaPDF_Core_Document
 
$fieldName : string
 
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

get()

public static SignatureField::get (
\SetaPDF_Core_Document $document,
string $fieldName = SignatureField::DEFAULT_FIELD_NAME,
bool $create = true
): bool|\SetaPDF_Signer_SignatureField

Get a signature field instance and creates it if it is not already available.

If no field is found a hidden field on page one will be created automatically.

Parameters
$document : \SetaPDF_Core_Document
 
$fieldName : string

The field name in UTF-8 encoding

$create : bool

Automatically creates a hidden field if none was found by the specified name

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


Methods

__construct()

The constructor.

An instance could be created by an existing dictionary, indirect object/reference or by the same parameters as createAnnotationDictionary().

Parameters
$objectOrDictionary : string|array|\SetaPDF_Core_Type_AbstractType|\SetaPDF_Core_Type_Dictionary|\SetaPDF_Core_Type_IndirectObjectInterface
 
Exceptions

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\Type\Exception

See

cleanUp()

Release memory/cycled references.

getAction()

Get the action of the annotation.

If no action is defined false will be returned.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getAdditionalActions()

getAnnotationDictionary()

WARNING: This method is marked as deprecated!

Get the annotation dictionary.

getAppearance()

Get the annotation appearance stream.

Parameters
$type : string
 
$subName : ?string
 
Exceptions

Throws \InvalidArgumentException

getAppearanceCharacteristics()

getContents()

public \setasign\SetaPDF2\Core\Document\Page\Annotation\Annotation::getContents (
string $encoding = 'UTF-8'
): ?string

Get the contents of the annotation.

Parameters
$encoding : string
 

getDictionary()

getHeight()

public \setasign\SetaPDF2\Core\Document\Page\Annotation\WidgetAnnotation::getHeight (
bool $ignoreRotation = false
): float|int

Get the height of the annotation.

If the annotation is rotated width and height will be changed accordingly. This can be affected by the $ignoreRotation parameter.

Parameters
$ignoreRotation : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getHiddenFlag()

Checks for the "Hidden" flag.

PDF 32000-1:2008 - Table 165: "If set, do not display or print the annotation or allow it to interact with the user, regardless of its annotation type or whether an annotation handler is available."

getIndirectObject()

getInvisibleFlag()

Checks for the "Invisible" flag.

PDF 32000-1:2008 - Table 165: "If set, do not display the annotation if it does not belong to one of the standard annotation types and no annotation handler is available. If clear, display such an unknown annotation using an appearance stream specified by its appearance dictionary, if any"

getLock()

public SignatureField::getLock (
void
): array|bool

Get information about lock data if available.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getLockedContents()

Checks for the "LockedContents" flag.

PDF 32000-1:2008 - Table 165: "If set, do not allow the contents of the annotation to be modified by the user. This flag does not restrict deletion of the annotation or changes to other annotation properties, such as position and size."

getLockedFlag()

Checks the "Locked" flag.

PDF 32000-1:2008 - Table 165: "If set, do not allow the annotation to be deleted or its properties (including position and size) to be modified by the user. However, this flag does not restrict changes to the annotation’s contents, such as the value of a form field."

getModificationDate()

Get the modification date.

Parameters
$asString : bool
 
Exceptions

Throws \Exception

getName()

public \setasign\SetaPDF2\Core\Document\Page\Annotation\Annotation::getName (
string $encoding = 'UTF-8'
): ?string

Get the name of the annotation.

Parameters
$encoding : string
 

getNoRotateFlag()

Checks fo the "NoRotate" flag.

PDF 32000-1:2008 - Table 165: "If set, do not rotate the annotation’s appearance to match the rotation of the page. The upper-left corner of the annotation rectangle shall remain in a fixed location on the page, regardless of the page rotation."

getNoViewFlag()

Checks for the "NoView" flag.

PDF 32000-1:2008 - Table 165: "If set, do not display the annotation on the screen or allow it to interact with the user. The annotation may be printed (depending on the setting of the Print flag) but should be considered hidden for purposes of on-screen display and user interaction."

getNoZoomFlag()

Checks fo the "NoZoom" flag.

PDF 32000-1:2008 - Table 165: "If set, do not scale the annotation’s appearance to match the magnification of the page. The location of the annotation on the page (defined by the upper- left corner of its annotation rectangle) shall remain fixed, regardless of the page magnification."

getPrintFlag()

Checks for the "Print" flag.

PDF 32000-1:2008 - Table 165: "If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of whether it is displayed on the screen."

getQualifiedName()

public SignatureField::getQualifiedName (
void
): string

Returns the qualified name.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getReadOnlyFlag()

Checks the "ReadOnly" flag.

PDF 32000-1:2008 - Table 165: "If set, do not allow the annotation to interact with the user. The annotation may be displayed or printed (depending on the settings of the NoView and Print flags) but should not respond to mouse clicks or change its appearance in response to mouse motions.

This flag shall be ignored for widget annotations; its function is subsumed by the ReadOnly flag of the associated form field"

getRect()

getToggleNoView()

Checks for the "ToggleNoView" flag.

PDF 32000-1:2008 - Table 165: "If set, invert the interpretation of the NoView flag for certain events."

getType()

Get the annotation type specified in the Subtype entry.

getValue()

Get the signature value dictionary of this field, if present.

getWidth()

public \setasign\SetaPDF2\Core\Document\Page\Annotation\WidgetAnnotation::getWidth (
bool $ignoreRotation = false
): float|int

Get the width of the annotation.

If the annotation is rotated width and height will be changed accordingly. This can be affected by the $ignoreRotation parameter.

Parameters
$ignoreRotation : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

isAnnotationFlagSet()

Checks if a specific annotation flag is set.

Parameters
$flag : int
 

setAction()

Set the action of the annotation.

The action could be an instance of \setasign\SetaPDF2\Core\Document\Action\Action or a plain dictionary representing the action.

Parameters
$action : \SetaPDF_Core_Document_Action|\SetaPDF_Core_Type_Dictionary
 
Exceptions

Throws \InvalidArgumentException

setAnnotationFlags()

Sets an annotation flag.

Parameters
$flags : int
 
$set : bool

Set or unset

setAppearance()

public \setasign\SetaPDF2\Core\Document\Page\Annotation\Annotation::setAppearance (
\SetaPDF_Core_XObject_Form $xObject,
string $type = 'N',
?string $subState = null
): void

Set the annotation appearance stream.

Parameters
$xObject : \SetaPDF_Core_XObject_Form
 
$type : string
 
$subState : ?string
 

setColor()

Set the color of the annotation.

Parameters
$color : null|bool|int|float|string|array|\SetaPDF_Core_DataStructure_Color
 

setContents()

public \setasign\SetaPDF2\Core\Document\Page\Annotation\Annotation::setContents (
?string $contents,
string $encoding = 'UTF-8'
): void

Set the contents of the annotation.

Parameters
$contents : ?string
 
$encoding : string
 

setHiddenFlag()

setInvisibleFlag()

setLock()

public SignatureField::setLock (
\SetaPDF_Core_Document $document,
string|false $action = SignatureField::LOCK_DOCUMENT_ALL,
?array $fields = null
): void

Set if an how the document should be locked after a signature is applied to this field.

NOTICE: Currently only SignatureField::LOCK_DOCUMENT_ALL or none is supported.

Parameters
$document : \SetaPDF_Core_Document
 
$action : string|false

A name which indicates if all, none or indiviual fields should be locked or not locked.

$fields : ?array
 
Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

Throws \setasign\SetaPDF2\Core\Type\Exception

setLocked()

setLockedContents()

Set the "LockedContents" flag.

Parameters
$lockedContents : bool
 
See

setModificationDate()

Set the modification date.

Parameters
$date : \SetaPDF_Core_DataStructure_Date|\DateTime|string|bool

If true is passed, the current date and time will be used.

Exceptions

Throws \Exception

setName()

public \setasign\SetaPDF2\Core\Document\Page\Annotation\Annotation::setName (
?string $name,
string $encoding = 'UTF-8'
): void

Set the name of the annotation.

The annotation name, a text string uniquely identifying it among all the annotations on its page.

Parameters
$name : ?string
 
$encoding : string
 

setNoRotateFlag()

setNoViewFlag()

setNoZoomFlag()

setPrintFlag()

setReadOnlyFlag()

setToggleNoView()

Set the "ToggleNoView" flag.

Parameters
$toggleNoView : bool
 
See

unsetAnnotationFlags()

Removes a field flag.

Parameters
$flags : int