Create digital signatures for PDF documents with PHP


Digital sign PDF documents with PHP

Simple Usage Demo

This demo shows a simple PDF signature process in pure PHP.

// or if you use composer require_once('vendor/autoload.php');

// create a Http writer
$writer = new SetaPDF_Core_Writer_Http('simple-signer-demo.pdf', true);
// load document by filename
$document = SetaPDF_Core_Document::loadByFilename('Boombastic-Box.pdf', $writer);

// create a signer instance for the document
$signer = new SetaPDF_Signer($document);

// set some signature properties
$signer->setReason('Just for testing');
$signer->setContactInfo('+49 5351 523901-0');

// create an OpenSSL module instance
$module = new SetaPDF_Signer_Signature_Module_OpenSsl();
// set the sign certificate
// set the private key for the sign certificate
$module->setPrivateKey(array(file_get_contents('private-key.pem'), 'password'));

// sign/certify the document