You are here

function theme_print_pdf_dompdf_footer in Printer, email and PDF versions 5.4

Same name and namespace in other branches
  1. 5.3 print_pdf/print_pdf.pages.inc \theme_print_pdf_dompdf_footer()
  2. 6 print_pdf/print_pdf.pages.inc \theme_print_pdf_dompdf_footer()
  3. 7.2 print_pdf/lib_handlers/print_pdf_dompdf/print_pdf_dompdf.pages.inc \theme_print_pdf_dompdf_footer()
  4. 7 print_pdf/print_pdf.pages.inc \theme_print_pdf_dompdf_footer()
  5. 5.x print_pdf/print_pdf.pages.inc \theme_print_pdf_dompdf_footer()

Format the dompdf footer contents

Parameters

$html: contents of the body of the HTML from the original node

See also

theme_print_pdf_tcpdf_footer()

File

print_pdf/print_pdf.pages.inc, line 384

Code

function theme_print_pdf_dompdf_footer($html) {
  preg_match('!<div class="print-footer">(.*?)</div>!si', $html, $tpl_footer);
  $html = str_replace($tpl_footer[0], '', $html);
  $text = '<script type="text/php">
    if (isset($pdf)) {
      $font = Font_Metrics::get_font("verdana");;
      $size = 10;
      $color = array(0,0,0);
      $text_height = Font_Metrics::get_font_height($font, $size);

      $w = $pdf->get_width();
      $h = $pdf->get_height();

      $footer = $pdf->open_object();

      // Draw a line along the bottom
      $y = $h - 25;
      $pdf->line(15, $y, $w - 15, $y, $color, 1);

      $y += $text_height / 2;
      $pdf->page_text(15, $y, \'' . addslashes(strip_tags($tpl_footer[1])) . '\', $font, $size, $color);

      $pdf->close_object();
      $pdf->add_object($footer, "all");

      // Center the text
      $width = Font_Metrics::get_text_width("Page 1 of 2", $font, $size);
      $pagenumtxt = t("Page !n of !total", array("!n" => "{PAGE_NUM}", "!total" => "{PAGE_COUNT}"));
      $pdf->page_text($w - 15 - $width, $y, $pagenumtxt, $font, $size, $color);
    }
  </script>';
  return str_replace("<body>", "<body>" . $text, $html);
}