setasign\SetaPDF2\Signer\Signature\Appearance

Dynamic Class representing a dynamic visible signature appearance

File: /SetaPDF v2/Signer/Signature/Appearance/Dynamic.php
Old class name (alias): \SetaPDF_Signer_Signature_Appearance_Dynamic

This signature appearance allows you to define a background image or xobject and a logo. The appearance will also display certificate details extracted from the used certificate and some signature properties like location.

Class hierarchy

Summary

Constants

CONFIG_BACKGROUND_LOGO

public const Dynamic::CONFIG_BACKGROUND_LOGO = 'backgroundLogo'

CONFIG_BACKGROUND_LOGO_OPACITY

public const Dynamic::CONFIG_BACKGROUND_LOGO_OPACITY = 'backgroundLogoOpacity'

CONFIG_DATE

public const Dynamic::CONFIG_DATE = 'date'

CONFIG_DISTINGUISHED_NAME

public const Dynamic::CONFIG_DISTINGUISHED_NAME = 'distinguishedName'

CONFIG_GRAPHIC

public const Dynamic::CONFIG_GRAPHIC = 'graphic'

CONFIG_GRAPHIC_ALIGN

public const Dynamic::CONFIG_GRAPHIC_ALIGN = 'graphicAlign'

CONFIG_GRAPHIC_ALIGN_LEFT

public const Dynamic::CONFIG_GRAPHIC_ALIGN_LEFT = 'left'

CONFIG_GRAPHIC_ALIGN_RIGHT

public const Dynamic::CONFIG_GRAPHIC_ALIGN_RIGHT = 'right'

CONFIG_GRAPHIC_COLOR

public const Dynamic::CONFIG_GRAPHIC_COLOR = 'graphicColor'

CONFIG_LABELS

public const Dynamic::CONFIG_LABELS = 'labels'

CONFIG_LOCATION

public const Dynamic::CONFIG_LOCATION = 'location'

CONFIG_NAME

public const Dynamic::CONFIG_NAME = 'name'

CONFIG_REASON

public const Dynamic::CONFIG_REASON = 'reason'

CONFIG_SHOW_DATE

public const Dynamic::CONFIG_SHOW_DATE = 'showDate'

CONFIG_SHOW_DATE_FORMAT

public const Dynamic::CONFIG_SHOW_DATE_FORMAT = 'showDateFormat'

CONFIG_SHOW_DATE_TPL

public const Dynamic::CONFIG_SHOW_DATE_TPL = 'showDateTpl'

CONFIG_SHOW_DISTINGUISHED_NAME

public const Dynamic::CONFIG_SHOW_DISTINGUISHED_NAME = 'showDistinguishedName'

CONFIG_SHOW_DISTINGUISHED_NAME_TPL

public const Dynamic::CONFIG_SHOW_DISTINGUISHED_NAME_TPL = 'showDistinguishedNameTpl'

CONFIG_SHOW_LABELS

public const Dynamic::CONFIG_SHOW_LABELS = 'showLabels'

CONFIG_SHOW_LOCATION

public const Dynamic::CONFIG_SHOW_LOCATION = 'showLocation'

CONFIG_SHOW_LOCATION_TPL

public const Dynamic::CONFIG_SHOW_LOCATION_TPL = 'showLocationTpl'

CONFIG_SHOW_NAME

public const Dynamic::CONFIG_SHOW_NAME = 'showName'

CONFIG_SHOW_NAME_TPL

public const Dynamic::CONFIG_SHOW_NAME_TPL = 'showNameTpl'

CONFIG_SHOW_REASON

public const Dynamic::CONFIG_SHOW_REASON = 'showReason'

CONFIG_SHOW_REASON_TPL

public const Dynamic::CONFIG_SHOW_REASON_TPL = 'showReasonTpl'

CONFIG_TEXT_ALIGN

public const Dynamic::CONFIG_TEXT_ALIGN = 'textAlign'

CONFIG_TEXT_COLOR

public const Dynamic::CONFIG_TEXT_COLOR = 'textColor'

Properties

$_certificate

$_certificateInfo

protected ?array Dynamic::$_certificateInfo

The certificate info returned from openssl_x509_parse()

$_config

protected array Dynamic::$_config = array(...)

The configuration array

$_font

A font that is used for rendering text.


Methods

__construct()

The constructor.

Just pass a signature module that offers a getCertificate() method or a certificate argument to the constructor. The data for the appearance will be extracted automatically.

Parameters
$moduleOrCertificate : \SetaPDF_Signer_Signature_Module_ModuleInterface|\SetaPDF_Signer_X509_Certificate|string
 
Exceptions

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Signer\Asn1\Exception

_drawBackground()

Draw the background logo of the signature appearance.

Parameters
$xObject : \SetaPDF_Core_XObject_Form
 
$document : \SetaPDF_Core_Document
 

_drawGraphic()

Draws the graphic on the left or right side of the signature appearance.

Parameters
$xObject : \SetaPDF_Core_XObject_Form
 
$document : \SetaPDF_Core_Document
 
$signer : \SetaPDF_Signer
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Signer\Exception

_drawText()

protected Dynamic::_drawText (
string $text,
\SetaPDF_Core_XObject_Form $xObject,
\SetaPDF_Core_Document $document
): void

Draws the text on the appearance.

If no graphic is set the text will be placed on the full width of the appearance.

Parameters
$text : string
 
$xObject : \SetaPDF_Core_XObject_Form
 
$document : \SetaPDF_Core_Document
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_getN2XObject()

_prepareText()

protected Dynamic::_prepareText (
\SetaPDF_Signer $signer
): string

Prepares the text string.

Parameters
$signer : \SetaPDF_Signer
 
Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

Throws \Exception

cleanUp()

public Dynamic::cleanUp (
void
): void

Release memory/cycled references.

createAppearance()

Creates the XObject structure and "layers" (n0 + n2).

Parameters
$field : \SetaPDF_Signer_SignatureField
 
$document : \SetaPDF_Core_Document
 
$signer : \SetaPDF_Signer
 

getBackgroundLogo()

public Dynamic::getBackgroundLogo (
void
): mixed

Get the current background logo.

getBackgroundLogoOpacity()

public Dynamic::getBackgroundLogoOpacity (
void
): float

Get the background logo opacity.

getCertificateInfo()

public Dynamic::getCertificateInfo (
void
): ?array

Returns information about the supplied certificate.

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

getConfig()

public Dynamic::getConfig (
string $key
): bool|mixed

Get a specific configuration value.

Parameters
$key : string

The key of the config. See and use Dynamic::CONFIG_XXX for a valid key.

Return Values

Returns false if the key is invalid.

getFont()

Get the font that should be used for displaying text.

getGraphic()

public Dynamic::getGraphic (
void
): mixed

Get if and how the graphic on is displayed.

getGraphicAlign()

public Dynamic::getGraphicAlign (
void
): string

Get whether the graphic should be displayed on the left or right.

getGraphicColor()

public Dynamic::getGraphicColor (
void
): string

Get the graphic text color.

getShow()

public Dynamic::getShow (
string $name
): bool

Get whether a text part will be shown or not.

Parameters
$name : string
 
See

getShowFormat()

public Dynamic::getShowFormat (
string $name
): bool|mixed

Get the format for a specific value.

Parameters
$name : string
 
See

getShowTpl()

public Dynamic::getShowTpl (
string $name
): string

Get a defined template for a specific text part.

Parameters
$name : string
 
See

getTextAlign()

public Dynamic::getTextAlign (
void
): string

Get the text align.

getTextColor()

public Dynamic::getTextColor (
void
): string

Get the text color.

setBackgroundLogo()

public Dynamic::setBackgroundLogo (
?\SetaPDF_Core_XObject $xObject = null,
float $opacity = 1.0
): self

Set a background logo and its opacity.

The background logo is displayed in the center of the appearance.

Parameters
$xObject : ?\SetaPDF_Core_XObject
 
$opacity : float
 

setBackgroundLogoOpacity()

public Dynamic::setBackgroundLogoOpacity (
float $opacity
): $this

Set the background logo opacity.

Parameters
$opacity : float

A value between 0 (not visible) an 1 (full opacity)

setConfig()

public Dynamic::setConfig (
string $key,
mixed $value
): bool|\SetaPDF_Signer_Signature_Appearance_Dynamic

Set a specific configuration value.

Parameters
$key : string

The key of the config. See and use Dynamic::CONFIG_XXX for a valid key.

$value : mixed
 
Return Values

Returns false if the key is invalid.

setFont()

public Dynamic::setFont (): void

Set the font that should be used for displaying text.

Parameters
$font : ?\SetaPDF_Core_Font_FontInterface
 

setGraphic()

public Dynamic::setGraphic (
\SetaPDF_Core_XObject|bool $graphic
): $this

Set how and if a graphic is displayed on the appearance.

If a XObject is passed it will be used as the graphic, if true is passed the common name of the certificate will be used. If false is passed no graphic will be shown.

Parameters
$graphic : \SetaPDF_Core_XObject|bool

A XObject or a boolean value

setGraphicAlign()

public Dynamic::setGraphicAlign (
string $align
): void

Set whether the graphic should be displayed on the left or right.

Parameters
$align : string

A self::CONFIG_GRAPHIC_ALIGN_* constant.

See

setGraphicColor()

public Dynamic::setGraphicColor (
string $graphicColor
): $this

Set the graphic text color.

Parameters
$graphicColor : string
 

setShow()

public Dynamic::setShow (
string $name,
bool $show = true
): $this|bool

Defines whether a text part will be shown or not.

Available names are:

Parameters
$name : string
 
$show : bool
 

setShowFormat()

public Dynamic::setShowFormat (
string $name,
string $format
): $this|bool

Sets a format for a specific value.

Currently only the $name Dynamic::CONFIG_DATE is supported.

Parameters
$name : string
 
$format : string
 

setShowTpl()

public Dynamic::setShowTpl (
string $name,
string $tpl
): $this|bool

Defines a template for a specific text.

The template will be used as a label of a specific value. The value is passed via sprintf() to this template.

Following names are possible:

Parameters
$name : string
 
$tpl : string
 

setTextAlign()

public Dynamic::setTextAlign (
string $textAlign
): $this

Set the text align.

Parameters
$textAlign : string
 
See

setTextColor()

public Dynamic::setTextColor (
string $textColor
): $this

Set the text color.

Parameters
$textColor : string