SetaPDF_Signer_Signature_Appearance_Dynamic Class representing a dynamic visible signature appearance
File: /SetaPDF v2/Signer/Signature/Appearance/Dynamic.php
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
Methods
- __construct()
- _drawBackground()
- _drawGraphic()
- _drawText()
- _getN2XObject()
- _prepareText()
- cleanUp()
- createAppearance()
- getBackgroundLogo()
- getBackgroundLogoOpacity()
- getCertificateInfo()
- getConfig()
- getFont()
- getGraphic()
- getGraphicAlign()
- getGraphicColor()
- getShow()
- getShowFormat()
- getShowTpl()
- getTextAlign()
- getTextColor()
- setBackgroundLogo()
- setBackgroundLogoOpacity()
- setConfig()
- setFont()
- setGraphic()
- setGraphicAlign()
- setGraphicColor()
- setShow()
- setShowFormat()
- setShowTpl()
- setTextAlign()
- setTextColor()
Constants
- CONFIG_BACKGROUND_LOGO
- CONFIG_BACKGROUND_LOGO_OPACITY
- CONFIG_DATE
- CONFIG_DISTINGUISHED_NAME
- CONFIG_GRAPHIC
- CONFIG_GRAPHIC_ALIGN
- CONFIG_GRAPHIC_ALIGN_LEFT
- CONFIG_GRAPHIC_ALIGN_RIGHT
- CONFIG_GRAPHIC_COLOR
- CONFIG_LABELS
- CONFIG_LOCATION
- CONFIG_NAME
- CONFIG_REASON
- CONFIG_SHOW_DATE
- CONFIG_SHOW_DATE_FORMAT
- CONFIG_SHOW_DATE_TPL
- CONFIG_SHOW_DISTINGUISHED_NAME
- CONFIG_SHOW_DISTINGUISHED_NAME_TPL
- CONFIG_SHOW_LABELS
- CONFIG_SHOW_LOCATION
- CONFIG_SHOW_LOCATION_TPL
- CONFIG_SHOW_NAME
- CONFIG_SHOW_NAME_TPL
- CONFIG_SHOW_REASON
- CONFIG_SHOW_REASON_TPL
- CONFIG_TEXT_ALIGN
- CONFIG_TEXT_COLOR
Constants
CONFIG_BACKGROUND_LOGO
CONFIG_BACKGROUND_LOGO_OPACITY
CONFIG_DATE
CONFIG_DISTINGUISHED_NAME
CONFIG_GRAPHIC
CONFIG_GRAPHIC_ALIGN
CONFIG_GRAPHIC_ALIGN_LEFT
CONFIG_GRAPHIC_ALIGN_RIGHT
CONFIG_GRAPHIC_COLOR
CONFIG_LABELS
CONFIG_LOCATION
CONFIG_NAME
CONFIG_REASON
CONFIG_SHOW_DATE
CONFIG_SHOW_DATE_FORMAT
CONFIG_SHOW_DATE_TPL
CONFIG_SHOW_DISTINGUISHED_NAME
CONFIG_SHOW_DISTINGUISHED_NAME_TPL
CONFIG_SHOW_LABELS
CONFIG_SHOW_LOCATION
CONFIG_SHOW_LOCATION_TPL
CONFIG_SHOW_NAME
CONFIG_SHOW_NAME_TPL
CONFIG_SHOW_REASON
CONFIG_SHOW_REASON_TPL
CONFIG_TEXT_ALIGN
CONFIG_TEXT_COLOR
Properties
$_certificate
The certificate
$_certificateInfo
The certificate info returned from openssl_x509_parse()
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
_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 SetaPDF_Core_Type_Exception
Throws SetaPDF_Signer_Exception
_drawText()
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 SetaPDF_Core_Type_Exception
_getN2XObject()
Creates the "n2" layer appearance.
Parameters
- $field : SetaPDF_Signer_SignatureField
- $document : SetaPDF_Core_Document
- $signer : SetaPDF_Signer
Exceptions
Throws SetaPDF_Core_Type_Exception
Throws SetaPDF_Signer_Exception
_prepareText()
Prepares the text string.
Parameters
- $signer : SetaPDF_Signer
Exceptions
Throws SetaPDF_Signer_Exception
Throws Exception
createAppearance()
Creates the XObject structure and "layers" (n0 + n2).
Parameters
- $field : SetaPDF_Signer_SignatureField
- $document : SetaPDF_Core_Document
- $signer : SetaPDF_Signer
getCertificateInfo()
getConfig()
Get a specific configuration value.
Parameters
- $key : string
The key of the config. See and use
SetaPDF_Signer_Signature_Appearance_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.
setBackgroundLogo()
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()
Set the background logo opacity.
Parameters
- $opacity : float
A value between 0 (not visible) an 1 (full opacity)
setConfig()
Set a specific configuration value.
Parameters
- $key : string
The key of the config. See and use
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_XXX
for a valid key.- $value : mixed
Return Values
Returns false if the key is invalid.
setFont()
Set the font that should be used for displaying text.
Parameters
- $font : SetaPDF_Core_Font_FontInterface|null
setGraphic()
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|boolean
A XObject or a boolean value
setGraphicAlign()
Set whether the graphic should be displayed on the left or right.
Parameters
- $align : string
A self::CONFIG_GRAPHIC_ALIGN_* constant.
See
- self::CONFIG_GRAPHIC_ALIGN_RIGHT
- self::CONFIG_GRAPHIC_ALIGN_LEFT
setShow()
Defines whether a text part will be shown or not.
Available names are:
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_NAME
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_REASON
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_DATE
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_LABELS
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_DISTINGUISHED_NAME
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_LOCATION
Parameters
- $name : string
- $show : boolean
setShowFormat()
Sets a format for a specific value.
Currently only the $name SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_DATE
is supported.
Parameters
- $name : string
- $format : string
setShowTpl()
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:
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_NAME
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_REASON
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_DATE
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_DISTINGUISHED_NAME
-
SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_LOCATION
Parameters
- $name : string
- $tpl : string