// create a re-usable array of filenames (in/out)
$files = array(array('in' => 'files/tektown/Laboratory-Report.pdf', 'out' => 'output/tektown-signed.pdf'), array('in' => 'files/lenstown/Laboratory-Report.pdf', 'out' => 'output/lenstown-signed.pdf'), array('in' => 'files/etown/Laboratory-Report.pdf', 'out' => 'output/etown-signed.pdf'), array('in' => 'files/camtown/Laboratory-Report.pdf', 'out' => 'output/camtown-signed.pdf'));
// create document instances by the filenames
$documents = array();
foreach ($files as $file) {
    $documents[] = SetaPDF_Core_Document::loadByFilename($file['in'], new SetaPDF_Core_Writer_File($file['out']));
}
// initiate a batch instance
$batch = new SetaPDF_Signer_SwisscomAIS_Batch($customerId, $clientOptions);
// let's add PADES revoke information to the resulting signatures
$batch->setAddRevokeInformation('PADES');
// the signatures should include a timestamp, too
$batch->setAddTimestamp(true);
try {
    // sign the documents and add the revoke information to the DSS of the documents
    $batch->sign($documents, true, array(SetaPDF_Signer::PROP_LOCATION => $_SERVER['SERVER_NAME'], SetaPDF_Signer::PROP_REASON => 'Testing'));
} 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>";
    die;
}
// get access to the last result object
$result = $batch->getLastResult();
echo count($result->SignResponse->SignatureObject->Other->SignatureObjects->ExtendedSignatureObject);
?>
 Signatures created.<br />
    $documents[] = SetaPDF_Core_Document::loadByFilename($file['in'], new SetaPDF_Core_Writer_File($file['out']));
}
// initiate a batch instance
$batch = new SetaPDF_Signer_SwisscomAIS_Batch($customerId, $clientOptions);
// let's add PADES revoke information to the resulting signatures
$batch->setAddRevokeInformation('PADES');
// the signatures should include a timestamp, too
$batch->setAddTimestamp(true);
// set on-demand options
$batch->setOnDemandOptions($signerDn);
if ($approvalNo !== '') {
    $batch->setOnDemandOptions($signerDn, $approvalNo, $approvalMsg, $approvalLang, $approvalSn);
}
try {
    // sign the documents and add the revoke information to the DSS of the documents
    $batch->sign($documents, true);
} 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>";
    die;
}
// get access to the last result object
$result = $batch->getLastResult();
echo count($result->SignResponse->SignatureObject->Other->SignatureObjects->ExtendedSignatureObject);
?>
 Signatures created.<br />