function theme_print_pdf_tcpdf_content in Printer, email and PDF versions 5.3
Same name and namespace in other branches
- 5.4 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_content()
- 6 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_content()
- 7.2 print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc \theme_print_pdf_tcpdf_content()
- 7 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_content()
- 5.x print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_content()
Format the TCPDF page content
Parameters
$pdf: current TCPDF object
$html: contents of the body of the HTML from the original node
$font: array with the font definition (font name, styles and size)
See also
theme_print_pdf_tcpdf_content()
1 theme call to theme_print_pdf_tcpdf_content()
- _print_pdf_tcpdf in print_pdf/
print_pdf.pages.inc - Generate the PDF file using the TCPDF library
File
- print_pdf/
print_pdf.pages.inc, line 294
Code
function theme_print_pdf_tcpdf_content(&$pdf, &$html, $font) {
// set content font
$pdf
->setFont($font[0], $font[1], $font[2]);
preg_match('!<body.*?>(.*)</body>!sim', $html, $matches);
$pattern = '!(?:<div class="print-(?:logo|site_name|breadcrumb|footer)">.*?</div>|<hr class="print-hr" />)!si';
$matches[1] = preg_replace($pattern, '', $matches[1]);
// Since TCPDF's writeHTML is so bad with <p>, do everything possible to make it look nice
$matches[1] = preg_replace('!(<p\\s*/>|</p>)!i', '<br />', $matches[1]);
$matches[1] = str_replace(array(
'<div',
'div>',
), array(
'<span',
'span><br />',
), $matches[1]);
$pdf
->writeHTML($matches[1]);
return $pdf;
}