PHP code example of setasign / setapdf-signer-addon-aws-kms
1. Go to this page and download the library: Download setasign/setapdf-signer-addon-aws-kms library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
setasign / setapdf-signer-addon-aws-kms example snippets
use Aws\Kms\KmsClient;
use setasign\SetaPDF\Signer\Module\AwsKMS\Module;
use setasign\SetaPDF2\Core\Document;
use setasign\SetaPDF2\Core\Writer\FileWriter;
use setasign\SetaPDF2\Signer\Signer;
$kmsClient = new KmsClient([
'region' => $region,
'version' => $version,
]);
$awsKmsModule = new Module($keyId, $kmsClient);
$cert = file_get_contents('your-cert.crt');
$awsKmsModule->setCertificate($cert);
$awsKmsModule->setSignatureAlgorithm($algorithm);
// the file to sign
$fileToSign = __DIR__ . '/Laboratory-Report.pdf';
// create a writer instance
$writer = new FileWriter('signed.pdf');
// create the document instance
$document = Document::loadByFilename($fileToSign, $writer);
// create the signer instance
$signer = new Signer($document);
$signer->sign($awsKmsModule);