You are here

function theme_print_pdf_tcpdf_header in Printer, email and PDF versions 5.3

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

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 = '';
  $logo_ret = preg_match('!src\\s*=\\s*(\'.*?\'|".*?"|[^\\s]*)!i', $tpl_logo[1], $matches);
  if ($logo_ret) {
    $logo = trim($matches[1], '\'"');
    $size = getimagesize($logo);
    $ratio = $size[0] / $size[1];
  }

  // set header font
  $pdf
    ->setHeaderFont($font);

  // set header margin
  $pdf
    ->SetHeaderMargin(5);

  // set header data
  $pdf
    ->SetHeaderData($logo, 10 * $ratio, $tpl_title[1], strip_tags($tpl_site_name[1]));
  return $pdf;
}