SetaPDF Demos

There seems to be a problem loading the components. Please check your PHP error logs for details!

Common issues could be that you missed to install the trial license or that you are using a trial version on an unsupported PHP version.

Several Visible Signatures

This demo shows you how to add more than one signature with a visible appearance. This is simply done by restarting the whole process and use a new signature field.

PHP
<?php

// load and register the autoload function
require_once __DIR__ . '/../../../../../bootstrap.php';

// create a temporary writer
$tempWriter = new \SetaPDF_Core_Writer_String();

$document = \SetaPDF_Core_Document::loadByFilename(
    $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf',
    $tempWriter
);

// create a signer instance
$signer = new \SetaPDF_Signer($document);
// add a visible signature field
$field = $signer->addSignatureField(
    \SetaPDF_Signer_SignatureField::DEFAULT_FIELD_NAME,
    1,
    \SetaPDF_Signer_SignatureField::POSITION_RIGHT_TOP,
    ['x' => -160, 'y' => -100],
    180,
    70
);
// and define that you want to use this field
$signer->setSignatureFieldName($field->getQualifiedName());

$certificatePath = $assetsDirectory . '/certificates/setapdf-no-pw.pem';

// now create a signature module
$module = new \SetaPDF_Signer_Signature_Module_Pades();
// pass the path to the certificate
$module->setCertificate('file://' . $certificatePath);
$module->setPrivateKey('file://' . $certificatePath, '');

// creat an appearance module instance
$appearance = new \SetaPDF_Signer_Signature_Appearance_Dynamic($module);
// pass it to the signer instance
$signer->setAppearance($appearance);

// sign the document with the module
$signer->sign($module);


// now simply re-start the process


// create the final writer
$writer = new \SetaPDF_Core_Writer_Http('several-signatures.pdf', true);

// create a new document instance based on the temporary result
$document = \SetaPDF_Core_Document::loadByString($tempWriter, $writer);

// create a signer instance
$signer = new \SetaPDF_Signer($document);
// add a visible signature field
$field = $signer->addSignatureField(
    \SetaPDF_Signer_SignatureField::DEFAULT_FIELD_NAME,
    1,
    \SetaPDF_Signer_SignatureField::POSITION_RIGHT_TOP,
    ['x' => -160, 'y' => -200],
    180,
    70
);
// and define that you want to use this field
$signer->setSignatureFieldName($field->getQualifiedName());

$certificatePath = $assetsDirectory . '/certificates/setapdf-no-pw.pem';

// now create a signature module
$module = new \SetaPDF_Signer_Signature_Module_Pades();
// pass the path to the certificate
$module->setCertificate('file://' . $certificatePath);
$module->setPrivateKey('file://' . $certificatePath, '');

// creat an appearance module instance
$appearance = new \SetaPDF_Signer_Signature_Appearance_Dynamic($module);
// pass it to the signer instance
$signer->setAppearance($appearance);

// sign the document and wriote the final document to the final writer
$signer->sign($module);