From 08e6a7108cee57108332ff4727a2a664af4f4156 Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Tue, 28 Jun 2022 10:30:56 +0200 Subject: [PATCH 1/2] Update Module.php Added getCertificate() method. --- src/Module.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Module.php b/src/Module.php index 419a89f..7358ab7 100644 --- a/src/Module.php +++ b/src/Module.php @@ -67,6 +67,14 @@ public function setCertificate($certificate) $this->padesModule->setCertificate($certificate); } + /** + * @return \SetaPDF_Signer_X509_Certificate|string + */ + public function getCertificate() + { + return $this->padesModule->getCertificate(); + } + /** * @param string $signatureAlgorithm */ @@ -169,7 +177,7 @@ public function getCms() public function createSignature(SetaPDF_Core_Reader_FilePath $tmpPath) { // ensure certificate - $certificate = $this->padesModule->getCertificate(); + $certificate = $this->getCertificate(); if ($certificate === null) { throw new \BadMethodCallException('Missing certificate!'); } From c47fae2876d497b57965ac61bd477e9603042b6c Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Tue, 28 Jun 2022 10:31:03 +0200 Subject: [PATCH 2/2] Create appearance-demo.php --- examples/appearance-demo.php | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 examples/appearance-demo.php diff --git a/examples/appearance-demo.php b/examples/appearance-demo.php new file mode 100644 index 0000000..94524c0 --- /dev/null +++ b/examples/appearance-demo.php @@ -0,0 +1,49 @@ + $region, + 'version' => $version, +]); +$awsKmsModule = new Module($keyId, $kmsClient); + +$awsKmsModule->setCertificate($cert); +$awsKmsModule->setSignatureAlgorithm($signatureAlgorithm); + +// create a writer instance +$writer = new SetaPDF_Core_Writer_File($resultPath); +// create the document instance +$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); + +// create the signer instance +$signer = new SetaPDF_Signer($document); + +$field = $signer->addSignatureField( + 'Signature', + 1, + SetaPDF_Signer_SignatureField::POSITION_RIGHT_TOP, + ['x' => -160, 'y' => -100], + 180, + 60 +); + +$signer->setSignatureFieldName($field->getQualifiedName()); + +$appearance = new SetaPDF_Signer_Signature_Appearance_Dynamic($awsKmsModule); +$signer->setAppearance($appearance); + +$signer->sign($awsKmsModule);