php - TCPDF adding digital signature to the created pdf -


i have kind of weird problem.
i'm struggling pdf digital signature problem since while , did't working expect. doesn't work @ all.

i used exacly same code posted in examples 52 page:

// set certificate file $certificate = 'file://var/www/app/tcpdf/config/cert/tcpdf.crt';  // set additional information $info = array(     'name' => 'tcpdf',     'location' => 'office',     'reason' => 'testing tcpdf',     'contactinfo' => 'http://www.tcpdf.org',     );  // set document signature $pdf->setsignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info); 

first problem

warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting private key in /var/www/app/tcpdf/tcpdf.php on line 7566 

it caused because did not set privileges execute cert directory. after set 777 magic happen.
on not see error, , not see error track but:

http error 324 (net::err_empty_response) 

anyone can suggest me something?

from see, error recieving not caused code have posted in question code straignforward , found in tcpdf documentation. can find example of sending signed pdf @ tcpdf documentation

the code there follows:

require_once('../config/lang/eng.php'); require_once('../tcpdf.php');  // create new pdf document $pdf = new tcpdf(pdf_page_orientation, pdf_unit, pdf_page_format, true, 'utf-8', false);  // set document information $pdf->setcreator(pdf_creator); $pdf->setauthor('nicola asuni'); $pdf->settitle('tcpdf example 052'); $pdf->setsubject('tcpdf tutorial'); $pdf->setkeywords('tcpdf, pdf, example, test, guide');  // set default header data $pdf->setheaderdata(pdf_header_logo, pdf_header_logo_width, pdf_header_title.' 052', pdf_header_string);  // set header , footer fonts $pdf->setheaderfont(array(pdf_font_name_main, '', pdf_font_size_main)); $pdf->setfooterfont(array(pdf_font_name_data, '', pdf_font_size_data));  // set default monospaced font $pdf->setdefaultmonospacedfont(pdf_font_monospaced);  //set margins $pdf->setmargins(pdf_margin_left, pdf_margin_top, pdf_margin_right); $pdf->setheadermargin(pdf_margin_header); $pdf->setfootermargin(pdf_margin_footer);  //set auto page breaks $pdf->setautopagebreak(true, pdf_margin_bottom);  //set image scale factor $pdf->setimagescale(pdf_image_scale_ratio);  //set language-dependent strings $pdf->setlanguagearray($l);  // ---------------------------------------------------------  /* notes:  - create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt  - export crt p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12  - convert pfx certificate pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes */  // set certificate file $certificate = 'file://../config/cert/tcpdf.crt';  // set additional information $info = array(     'name' => 'tcpdf',     'location' => 'office',     'reason' => 'testing tcpdf',     'contactinfo' => 'http://www.tcpdf.org',     );  // set document signature $pdf->setsignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info);  // set font $pdf->setfont('helvetica', '', 12);  // add page $pdf->addpage();  // print line of text $text = 'this <b color="#ff0000">digitally signed document</b> using default (example) <b>tcpdf.crt</b> certificate.<br />to validate signature have load <b color="#006600">tcpdf.fdf</b> on arobat reader add certificate <i>list of trusted identities</i>.<br /><br />for more information check source code of example , source code documentation <i>setsignature()</i> method.<br /><br /><a href="http://www.tcpdf.org">www.tcpdf.org</a>'; $pdf->writehtml($text, true, 0, true, 0);  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // *** set signature appearance ***  // create content signature (image and/or text) $pdf->image('../images/tcpdf_signature.png', 180, 60, 15, 15, 'png');  // define active area signature appearance $pdf->setsignatureappearance(180, 60, 15, 15);  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  // *** set empty signature appearance *** $pdf->addemptysignatureappearance(180, 80, 15, 15);  // ---------------------------------------------------------  //close , output pdf document $pdf->output('example_052.pdf', 'i'); 

note that, need add pages document , call output() function in order output sent browser. otherwise, server not have data send , give empty response causing error.

this error can cause if creating file on server , saving in folder script doesn't have permissions access , output browser.

if using google chrome view pdf, might want check out information here on error chrome empty response errors group

also, there reports error has been caused incorrectly configured zend optimizer/zend guardian setups. if neither of above case, make sure these deactivated continue troubleshooting.

as can see, error bit non-specific , can difficult troubleshoot.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -