theme_print_pdf_tcpdf_header

  1. drupal
    1. 6 print_pdf.pages.inc function
    2. 7 print_pdf.pages.inc function
Drupal 7 theme_print_pdf_tcpdf_header($vars)

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()

File

sites/all/modules/print/print_pdf/print_pdf.pages.inc, line 483
Generates the PDF versions of the pages

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;
}