function theme_print_pdf_tcpdf_content in Printer, email and PDF versions 7
Same name and namespace in other branches
- 5.4 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_content()
- 5.3 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()
- 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 561
Code
function theme_print_pdf_tcpdf_content($vars) {
$pdf = $vars['pdf'];
// set content font
$pdf
->setFont($vars['font'][0], $vars['font'][1], $vars['font'][2]);
preg_match('!<body.*?>(.*)</body>!sim', $vars['html'], $matches);
$pattern = '!(?:<div class="print-(?:logo|site_name|breadcrumb|footer)">.*?</div>|<hr class="print-hr" />)!si';
$matches[1] = preg_replace($pattern, '', $matches[1]);
// Make CCK fields look better
$matches[1] = preg_replace('!(<div class="field.*?>)\\s*!sm', '$1', $matches[1]);
$matches[1] = preg_replace('!(<div class="field.*?>.*?</div>)\\s*!sm', '$1', $matches[1]);
$matches[1] = preg_replace('!<div( class="field-label.*?>.*?)</div>!sm', '<strong$1</strong>', $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$1 />', $matches[1]);
$matches[1] = str_replace(array(
'<div',
'div>',
), array(
'<span',
'span><br />',
), $matches[1]);
do {
$prev = $matches[1];
$matches[1] = preg_replace('!(</span>)<br />(\\s*?</span><br />)!s', '$1$2', $matches[1]);
} while ($prev != $matches[1]);
@$pdf
->writeHTML($matches[1]);
return $pdf;
}