Skip to content
Snippets Groups Projects
Commit 0ad7ca91 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #14565 TIME 1:30 Improve text appearance in digital signature + config

parent c012cd1d
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
<contactInfo>Maarch SAS, société du groupe Archiveco</contactInfo> <contactInfo>Maarch SAS, société du groupe Archiveco</contactInfo>
</certInfo> </certInfo>
</electronicSignature> </electronicSignature>
<textWithDigitalSignature>true</textWithDigitalSignature>
<docaposteSignature> <docaposteSignature>
<enable>false</enable> <enable>false</enable>
<url>https://test.contralia.fr:443/Contralia/api/v2</url> <url>https://test.contralia.fr:443/Contralia/api/v2</url>
......
...@@ -149,19 +149,20 @@ class CertificateSignatureController ...@@ -149,19 +149,20 @@ class CertificateSignatureController
$imageXObject = $image->toXObject($document); $imageXObject = $image->toXObject($document);
$width = $signatureInfo['signWidth']; $width = $signatureInfo['signWidth'];
$height = $imageXObject->getHeight($width); $height = $imageXObject->getHeight($width);
$signatureFieldWith = $width > 200 ? $width : 200;
$fieldName = $signer->addSignatureField( $fieldName = $signer->addSignatureField(
'Signature_' . rand(), 'Signature_' . rand(),
$signatureInfo['page'], $signatureInfo['page'],
\SetaPDF_Signer_SignatureField::POSITION_LEFT_TOP, \SetaPDF_Signer_SignatureField::POSITION_LEFT_TOP,
['x' => $signatureInfo['positionX'], 'y' => -$signatureInfo['positionY']], ['x' => $signatureInfo['positionX'], 'y' => -$signatureInfo['positionY']],
$width, $signatureFieldWith,
$height + 50 $height + 50
)->getQualifiedName(); )->getQualifiedName();
$signer->setSignatureFieldName($fieldName); $signer->setSignatureFieldName($fieldName);
$xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height + 50]); $xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $signatureFieldWith, $height + 50]);
$canvas = $xObject->getCanvas(); $canvas = $xObject->getCanvas();
$imageXObject->draw($canvas, 0, 50, $width, $height); $imageXObject->draw($canvas, 0, 50, $width, $height);
...@@ -170,12 +171,15 @@ class CertificateSignatureController ...@@ -170,12 +171,15 @@ class CertificateSignatureController
__DIR__ . '/fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf' __DIR__ . '/fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf'
); );
$textBlock = new \SetaPDF_Core_Text_Block($font, 7); $loadedXml = CoreConfigModel::getConfig();
$textBlock->setWidth($width); if ($loadedXml->textWithDigitalSignature == 'true') {
$textBlock->setLineHeight(14); $textBlock = new \SetaPDF_Core_Text_Block($font, 6);
$textBlock->setPadding(2); $textBlock->setWidth($signatureFieldWith);
$textBlock->setText("Signé électroniquement par : " . $user['firstname'] . ' ' . $user['lastname'] . "\nLe " . date('c')); $textBlock->setLineHeight(14);
$textBlock->draw($canvas, 0, 30); $textBlock->setPadding(2);
$textBlock->setText("Signé électroniquement par : " . $user['firstname'] . ' ' . $user['lastname'] . "\nLe " . date('c'));
$textBlock->draw($canvas, 0, 30);
}
$appearance = new \SetaPDF_Signer_Signature_Appearance_XObject($xObject); $appearance = new \SetaPDF_Signer_Signature_Appearance_XObject($xObject);
$signer->setAppearance($appearance); $signer->setAppearance($appearance);
......
...@@ -196,19 +196,20 @@ class DigitalSignatureController ...@@ -196,19 +196,20 @@ class DigitalSignatureController
$imageXObject = $image->toXObject($document); $imageXObject = $image->toXObject($document);
$width = $args['signatureInfo']['signWidth']; $width = $args['signatureInfo']['signWidth'];
$height = $imageXObject->getHeight($width); $height = $imageXObject->getHeight($width);
$signatureFieldWith = $width > 200 ? $width : 200;
$fieldName = $signer->addSignatureField( $fieldName = $signer->addSignatureField(
'Signature_' . rand(), 'Signature_' . rand(),
$args['signatureInfo']['page'], $args['signatureInfo']['page'],
\SetaPDF_Signer_SignatureField::POSITION_LEFT_TOP, \SetaPDF_Signer_SignatureField::POSITION_LEFT_TOP,
['x' => $args['signatureInfo']['positionX'], 'y' => -$args['signatureInfo']['positionY']], ['x' => $args['signatureInfo']['positionX'], 'y' => -$args['signatureInfo']['positionY']],
$width, $signatureFieldWith,
$height + 50 $height + 50
)->getQualifiedName(); )->getQualifiedName();
$signer->setSignatureFieldName($fieldName); $signer->setSignatureFieldName($fieldName);
$xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height + 50]); $xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $signatureFieldWith, $height + 50]);
$canvas = $xObject->getCanvas(); $canvas = $xObject->getCanvas();
$imageXObject->draw($canvas, 0, 50, $width, $height); $imageXObject->draw($canvas, 0, 50, $width, $height);
...@@ -217,12 +218,15 @@ class DigitalSignatureController ...@@ -217,12 +218,15 @@ class DigitalSignatureController
__DIR__ . '/fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf' __DIR__ . '/fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf'
); );
$textBlock = new \SetaPDF_Core_Text_Block($font, 7); $loadedXml = CoreConfigModel::getConfig();
$textBlock->setWidth($width); if ($loadedXml->textWithDigitalSignature == 'true') {
$textBlock->setLineHeight(14); $textBlock = new \SetaPDF_Core_Text_Block($font, 7);
$textBlock->setPadding(2); $textBlock->setWidth($signatureFieldWith);
$textBlock->setText("Signé électroniquement par : " . $user['firstname'] . ' ' . $user['lastname'] . "\nLe " . date('c')); $textBlock->setLineHeight(14);
$textBlock->draw($canvas, 0, 30, $width, null); $textBlock->setPadding(2);
$textBlock->setText("Signé électroniquement par : " . $user['firstname'] . ' ' . $user['lastname'] . "\nLe " . date('c'));
$textBlock->draw($canvas, 0, 30);
}
$appearance = new \SetaPDF_Signer_Signature_Appearance_XObject($xObject); $appearance = new \SetaPDF_Signer_Signature_Appearance_XObject($xObject);
$signer->setAppearance($appearance); $signer->setAppearance($appearance);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment