Create digital signatures for PDF documents with PHP


Digital sign PDF documents with PHP

Certified Document Demo

This demo shows you how to add a certification signature to an existing PDF document.

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

// create a Http writer
$writer = new SetaPDF_Core_Writer_Http('certified.pdf', true);
// load document by filename
$document = SetaPDF_Core_Document::loadByFilename('Laboratory-Report.pdf', $writer);

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

// set some signature properties
$signer->setReason('This document is fixed');
$signer->setContactInfo('+49 5351 3803603');

// 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'));

// set the certification level: don't allow any changes

// sign/certify the document