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
$kmsClient = new Aws\Kms\KmsClient\KmsClient([
'region' => $region,
'version' => $version,
]);
$awsKmsModule = new setasign\SetaPDF\Signer\Module\AwsKms\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 SetaPDF_Core_Writer_File('signed.pdf');
// create the document instance
$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer);
// create the signer instance
$signer = new SetaPDF_Signer($document);
$signer->sign($awsKmsModule);