使用SetaPDF-Signer在php中的pdf签名者

时间:2014-02-14 14:21:14

标签: php pdf

我的问题是我无法移动到最后一个声明,即echo语句。 pdf签名者提供正确的输出,但执行在'$ signer->符号($ 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";

1 个答案:

答案 0 :(得分:1)

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

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

而不是

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

可以使用SetaPDF中所有可用编写器类的概述here