Hi everyone,
I just encountered an error using the tcpdf librairies and modifying the template.
When you withdraw the div "print-site_name" from the template, an error is generated in printp_pdf.pages.inc on line 514 (because $tpl_site_name is empty) :
$pdf->setHeaderData($logo, 10 * $ratio, html_entity_decode($tpl_title[1], ENT_QUOTES, 'UTF-8'), html_entity_decode($site_name, ENT_QUOTES, 'UTF-8'));
I corrected it adding this code before:
$site_name = '';
if(isset($tpl_site_name[1])){
$site_name = strip_tags($tpl_site_name[1]);
}And replacing the line in error by:
$pdf->setHeaderData($logo, 10 * $ratio, html_entity_decode($tpl_title[1], ENT_QUOTES, 'UTF-8'), html_entity_decode($site_name, ENT_QUOTES, 'UTF-8'));
Same thing happens on line 591 if you withdraw "print-footer" from your template (try accessing $tpl_footer[1] without checking if it's empty).
So you can replace :
function theme_print_pdf_tcpdf_footer($vars) {
$pdf = $vars['pdf'];
preg_match('!<div class="print-footer">(.*?)</div>!si', $vars['html'], $tpl_footer);
$footer = trim(preg_replace('!</?div[^>]*?>!i', '', $tpl_footer[1]));
// set footer font
$vars['font'][2] *= 0.8;
$pdf->setFooterFont($vars['font']);
// set footer margin
$pdf->SetFooterMargin(10);
// set footer data
$pdf->SetFooterData($footer);
return $pdf;
}By
function theme_print_pdf_tcpdf_footer($vars) {
$pdf = $vars['pdf'];
preg_match('!<div class="print-footer">(.*?)</div>!si', $vars['html'], $tpl_footer);
if(isset($tpl_footer[1])) {
$footer = trim(preg_replace('!</?div[^>]*?>!i', '', $tpl_footer[1]));
// set footer font
$vars['font'][2] *= 0.8;
$pdf->setFooterFont($vars['font']);
// set footer margin
$pdf->SetFooterMargin(10);
// set footer data
$pdf->SetFooterData($footer);
}
return $pdf;
}I'll try to make a patch when I've time.
Hope this helps.
Mat
Comments
Comment #1
simon georges commentedSetting to active since the patch isn't there.
Comment #2
jcnventuraIt's OK.. The code changes are here, so I can work with that.
Comment #3
jcnventuraThanks for the code suggestion. I've fixed it in git.
http://drupalcode.org/project/print.git/commit/6abb057
Comment #4.0
(not verified) commentedUpdating display