function theme_print_pdf_tcpdf_header in Printer, email and PDF versions 6
Same name and namespace in other branches
- 5.4 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_header()
- 5.3 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_header()
- 7.2 print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc \theme_print_pdf_tcpdf_header()
- 7 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_header()
- 5.x print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_header()
Format the TCPDF header
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_header()
1 theme call to theme_print_pdf_tcpdf_header()
- _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 519
Code
function theme_print_pdf_tcpdf_header($pdf, $html, $font) {
preg_match('!<div class="print-logo">(.*?)</div>!si', $html, $tpl_logo);
preg_match('!<h1 class="print-title">(.*?)</h1>!si', $html, $tpl_title);
preg_match('!<div class="print-site_name">(.*?)</div>!si', $html, $tpl_site_name);
$ratio = 0;
$logo = '';
if (isset($tpl_logo[1]) && preg_match('!src\\s*=\\s*(?:"(.*?)"|\'(.*?)\'|([^\\s]*))!i', $tpl_logo[1], $logo_url)) {
$logo = $logo_url[1];
if (!empty($logo)) {
$size = getimagesize($logo);
$ratio = $size ? $size[0] / $size[1] : 0;
}
}
// set header font
$pdf
->setHeaderFont($font);
// set header margin
$pdf
->setHeaderMargin(5);
// set header data
$pdf
->setHeaderData($logo, 10 * $ratio, html_entity_decode($tpl_title[1], ENT_QUOTES, 'UTF-8'), html_entity_decode(strip_tags($tpl_site_name[1]), ENT_QUOTES, 'UTF-8'));
return $pdf;
}