我正在使用mPDF创建一个PDF。我想以数字方式向PDF文档中添加签名。
我只能找到向tcPDF对象添加数字签名的在线示例,而不是mPDF。
有谁有关于这个问题的任何信息可以帮助我吗?
这是我的PHP代码:
$pdf=new mPDF('en','A4','','DejaVuSansCondensed',$template->margin_left,$template->margin_right,$template->margin_top,$template->margin_bottom,$template->margin_header,$template->margin_footer);
$pdf->setAutoFont();
$pdf->SetHTMLHeader($header);
$pdf->SetHTMLFooter($footer);
$pdf->writeHTML($printable);
$pdf->Output($file_name, "D");
非常感谢!
发布于 2015-05-17 05:11:01
编辑(17.05.14):
我找到了下一个图书馆 - 这里 (向下滚动),并利用它将其打包到正确的Zend库中,以使其在盒外工作。因此,如果要使用PHP对PDF进行数字签名,则可以使用下一个库。http://www.mediafire.com/download/181rgs86nvr4nd5/signPdf.zip
在为已经生成的PHP文件签名寻找PHP解决方案几个星期之后,这是我发现的唯一使用性能良好的解决方案,它可以与任何PDF库一起使用。
感谢Damir开发这个库。
老旧答案
我也在努力解决同样的问题。我目前找到的唯一解决方案是创建PDF,然后使用https://www.setasign.com/products/fpdi/about/#p-510将PDF导入TCPDF。
然后用TCPDF签字。
首先创建一个类,然后从fpdi和TCPDF继承
require_once('tcpdf.php');
require_once('fpdi.php');
class Signpdf_lib extends FPDI{}
然后进行实际的签名
$pdfSigner = new Signpdf_lib();
$pageCount = $pdfSigner->setSourceFile($this->pdfFilePath);
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdfSigner->importPage($pageNo);
// get the size of the imported page
$size = $pdfSigner->getTemplateSize($templateId);
// create a page
$pdfSigner->AddPage('P', array($size['w'], $size['h']));
// use the imported page
$pdfSigner->useTemplate($templateId);
}
$info = array(
'Name' => "$documentName - $documentNumber",
'Location' => 'IL',
'Reason' => 'DOC SIGN',
'ContactInfo' => 'user details',
);
//load the certificate
$certificateStr = Signatures_lib::loadSignature();
// set document signature
$pdfSigner->setSignature($certificateStr, null, null, null, 1, $info);
// define active area for signature appearance
$pdfSigner->setSignatureAppearance(0, 5, 30, 30);
$pdfSigner->Output($this->pdfFilePath, 'F');
我曾经尝试过使用TCPDF签名算法并在mPdf中使用它,但是失败了,所以如果有人成功了,我会很高兴知道!
https://stackoverflow.com/questions/28848211
复制相似问题