Forum


Replies: 4   Views: 2433
Docx sign not work
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 edol.fuchs  · 17-08-2017 - 17:34

I am using the following code:

require_once 'classes/SignDocx.inc';

$sign = new SignDocx();

$sign->setDocx('Test.docx');
$sign->setPrivateKey('Test.pem', 'mypass');
$sign->setX509Certificate('Test.pem');

$sign->setSignatureComments('This document has been signed by me');

$sign->sign();

I can not sign the docx document. The following message appears:

sort() expects parameter 1 to be array, null given in [.../vendor/phpdocx/phpdocx/Classes/Phpdocx/Sign/SignDocx.inc 462]

Does anyone know what this error can be?

Posted by admin  · 17-08-2017 - 18:57

Hello,

It seems the DOCX doesn't contain a valid .rels file, or PHP is unable of read it.

Please run the included sample DigitalSignature\signDocx\sample_1.php using PHP CLI mode and reply the topic if it works or not (note that signdocx overwrites the DOCX to be signed to add the signature).

If the included sample works, please send to contact[at]phpdocx.com the DOCX you are trying to sign and the dev team we'll check it.

Which version of PHP are you using? The digital signature module is fully tested with PHP 5.2 to PHP 7.

Regards.

Posted by edol.fuchs  · 17-08-2017 - 19:30

I run the file Digital Signature\signDocx\sample1.php and it worked. Php is version 7.

Does not work when I generate the docx file ($phpWord->createDocx ($ path)). Any idea?

Posted by admin  · 17-08-2017 - 19:41

Hello,

Please do these tests:

· Generate the most simple DOCX, a single text, and then sign it (all in the same script).

· Use a standalone script to sign your DOCX (just to test it standalone). Maybe the DOCX file is not correctly closed by PHP when createDocx is called and then sign docx try to open it in the same script?

If the second test doesn't work, please send to contact[at]phpdocx.com the DOCX you are trying to sign and the dev team we'll check it.

Regards.

Posted by edol.fuchs  · 18-08-2017 - 11:37

Now it's working.

I change code block below:

new \Phpdocx\Create\CreateDocx();

to:

new \Phpdocx\Create\CreateDocxFromTemplate($blank_template_path);

 

Thank you for your help