Forum


Replies: 1   Views: 1213
Multiple signatures for a document
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 22-10-2021 - 11:39

Hello,

All documents (DOCX, PDF, XLSX, PPTX) can be signed using more than one signature using signature methods included in Premium licenses (https://www.phpdocx.com/documentation/introduction/digital-signature-docx-pdf-PHP).

For example, you can sign a DOCX:

$sign = new SignDOCX();
$sign->setDocx('Text.docx');
$sign->setPrivateKey('key_1.pem', 'phpdocx');
$sign->setX509Certificate('cert_1.pem');
$sign->setSignatureComments('This document has been signed.');
$sign->sign();

If you change the signed DOCX using phpdocx or any other tool, MS Word and other DOCX readers will display a message that the document has changed and the signature is not valid.

The same DOCX can be signed again adding a new signature (the same or other signature):

$sign = new SignDOCX();
$sign->setDocx('Text.docx');
$sign->setPrivateKey('key_2.pem', 'otherpassword');
$sign->setX509Certificate('cert_2.pem');
$sign->setSignatureComments('This document has been signed.');
$sign->sign();

and you'll get a DOCX with two signatures (or more if needed).

Since phpdocx 12, the Indexer class (https://www.phpdocx.com/api-documentation/docxutilities/indexer-parse-word-documents-with-PHP) allows extracing signatures information from a DOCX.

Regards.