// options for the SoapClient instance
$clientOptions = array('stream_context' => stream_context_create(array('ssl' => array('verify_peer' => true, 'cafile' => __DIR__ . '/ais-ca-ssl.crt', 'peer_name' => 'ais.swisscom.com'))), 'local_cert' => $cert, 'passphrase' => $passphrase);
// create a HTTP writer
$writer = new SetaPDF_Core_Writer_Http('Swisscom.pdf');
// let's get the document
$document = SetaPDF_Core_Document::loadByFilename('files/tektown/Laboratory-Report.pdf', $writer);
// now let's create a signer instance
$signer = new SetaPDF_Signer($document);
$signer->setAllowSignatureContentLengthChange(false);
$signer->setSignatureContentLength(32000);
// set some signature properties
$signer->setLocation($_SERVER['SERVER_NAME']);
$signer->setContactInfo('+01 2345 67890123');
$signer->setReason('testing...');
// create an Swisscom AIS module instance
$module = new SetaPDF_Signer_SwisscomAIS_Module($customerId, $clientOptions);
// let's add PADES revoke information to the resulting signatures
$module->setAddRevokeInformation('PADES');
// additionally the signature should include a qualified timestamp
$module->setAddTimestamp(true);
// set on-demand options
$module->setOnDemandOptions($signerDn);
if ($approvalNo !== '') {
    $module->setOnDemandOptions($signerDn, $approvalNo, $approvalMsg, $approvalLang, $approvalSn);
}
try {
    // sign the document with the use of the module
    $signer->sign($module);
    // get information about the signing certificate:
    // $signatureData = SetaPDF_Signer_SwisscomAIS_Helper::getSignatureData($module);
    // echo("Signed by: " . $signatureData['subject'] . PHP_EOL);
// options for the SoapClient instance
$clientOptions = array('stream_context' => stream_context_create(array('ssl' => array('verify_peer' => true, 'cafile' => __DIR__ . '/ais-ca-ssl.crt', 'peer_name' => 'ais.swisscom.com'))), 'local_cert' => $cert, 'passphrase' => $passphrase);
// create a HTTP writer
$writer = new SetaPDF_Core_Writer_Http('Swisscom.pdf');
// let's get the document
$document = SetaPDF_Core_Document::loadByFilename('files/tektown/Laboratory-Report.pdf', $writer);
// now let's create a signer instance
$signer = new SetaPDF_Signer($document);
$signer->setAllowSignatureContentLengthChange(false);
$signer->setSignatureContentLength(32000);
// set some signature properties
$signer->setLocation($_SERVER['SERVER_NAME']);
$signer->setContactInfo('+01 2345 67890123');
$signer->setReason('testing...');
// create an Swisscom AIS module instance
$module = new SetaPDF_Signer_SwisscomAIS_Module($customerId, $clientOptions);
// let's add PADES revoke information to the resulting signatures
$module->setAddRevokeInformation('PADES');
// pass the timestamp module to the signer instance
$signer->setTimestampModule($module);
try {
    // create the document timestamp
    $signer->timestamp();
} catch (SetaPDF_Signer_SwisscomAIS_Exception $e) {
    echo 'Error in SwisscomAIS: ' . $e->getMessage() . ' with code ' . $e->getCode() . '<br />';
    /* Get the AIS Error details */
    echo "<pre>";
    var_dump($e->getResultMajor());
    var_dump($e->getResultMinor());
    echo "</pre>";
}