pdf signer in php using SetaPDF-Signer



我的问题是我无法移动到最后一个语句,即 echo 语句。 PDF 签名者给出正确的输出,但执行停止在"$signer->sign($module);"行。

如何移动到下一个语句,即 echo 语句

我的代码如下...

require_once('SetaPDF-Signer/library/SetaPDF/Autoload.php');
// configure the temporary writer
SetaPDF_Core_Writer_TempFile::setTempDir('SetaPDF-Signer/demos');
// create a writer
$writer = new SetaPDF_Core_Writer_Http('235.pdf', true);
// create a new document instance
$document = SetaPDF_Core_Document::loadByFilename(
    'SetaPDF-Signer/235.pdf', $writer
);
// create a signer instance
$signer = new SetaPDF_Signer($document);
// set some signature properties  
$signer->setReason('needs to provide this ');
$signer->setLocation('needs to provide this');
// create a signature module
$module = new SetaPDF_Signer_Signature_Module_OpenSsl();
// load the certificate
$certificate = file_get_contents('xxxxxxxxx.pem');
$module->setCertificate($certificate);
$module->setPrivateKey(array($certificate, 'xxxxxxxxxx' /* no password */));
// sign the document and send the final document to the initial writer
$signer->sign($module);

echo "welcome";

您必须选择另一个编写器实例,该实例不会自动将生成的文档发送到客户端浏览器。 例如:

$writer = new SetaPDF_Core_Writer_File('path/to/235.pdf');

而不是

$writer = new SetaPDF_Core_Writer_Http('235.pdf', true);

SetaPDF 中所有可用编写器类的概述可在此处获得。

最新更新