PAdES Module (PHP)

Table of Contents

  1. Description
    1. Public Methods
      1. Demo


        The SetaPDF_Signer_Signature_Module_Pades module allows you to create PAdES-BES/B-B conform signatures.

        PAdES (PDF Advanced Electronic Signatures) is a set of restrictions and extensions to PDF and ISO 32000-1 making it suitable for advanced electronic signature. This is published by ETSI as TS 102 778.

        The PAdES-BES/B-B profile defines an optional signature-timestamp-stamp attribute. This can be used by simply combining this signature module with an additional timestamp module.  

        This module extends the CMS module to add additional required singed attributes to the CMS structure. Additionally it also have restrictions on the used digest algorithm: It explicitly prohibits the usage of MD5, SHA-1 or RIPEMD-160.

        Public Methods


        Adds Signing Certificate Reference Attribute.


        Get the certificate value.


        Get the complete Cryptographic Message Syntax structure.


        Get the digest algorithm.


        Ensures a certificate parameter and parses it into an ASN.1 element object structure.


        Set the signing certificate (PEM).


        Set the digest algorithm to use when signing.


        Add additional certificates which are placed into the CMS structure.


        Set the the private key or a path to the private key file and password argument.


        // create a writer
        $writer = new SetaPDF_Core_Writer_Http('simple.pdf', true);
        // create a new document instance
        $document = SetaPDF_Core_Document::loadByFilename(
            'files/pdfs/etown/Laboratory-Report.pdf', $writer
        // create a signer instance
        $signer = new SetaPDF_Signer($document);
        // set some signature properties
        $signer->setReason('Testing PAdES module');
        $signer->setLocation('SetaPDF-Signer Manual');
        // We need more space, if the signature will include a timestamp signature
        // create a signature module
        $module = new SetaPDF_Signer_Signature_Module_Pades();
        // load the certificate
        $certificate = 'file://files/certificates/setapdf-no-pw.pem';
        $module->setPrivateKey(array($certificate, '' /* no password */));
        // create a timestamp module
        $tsModule = new SetaPDF_Signer_Timestamp_Module_Rfc3161_Curl();
        // sign the document and send the final document to the initial writer