You are here

function theme_print_pdf_tcpdf_header in Printer, email and PDF versions 7

Same name and namespace in other branches
  1. 5.4 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_header()
  2. 5.3 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_header()
  3. 6 print_pdf/print_pdf.pages.inc \theme_print_pdf_tcpdf_header()
  4. 7.2 print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.pages.inc \theme_print_pdf_tcpdf_header()
  5. 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 503

Code

function theme_print_pdf_tcpdf_header($vars) {
  $pdf = $vars['pdf'];
  preg_match('!<div class="print-logo">(.*?)</div>!si', $vars['html'], $tpl_logo);
  preg_match('!<title>(.*?)</title>!si', $vars['html'], $tpl_title);
  preg_match('!<div class="print-site_name">(.*?)</div>!si', $vars['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($vars['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;
}