Commit cc493b52 authored by Devin Zuczek's avatar Devin Zuczek Committed by Devin Zuczek
Browse files

Issue #3283422 by djdevin, jcnventura: Remove dead code in theme_print_pdf_dompdf_footer

parent 2ab882a5
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -25,18 +25,6 @@ function print_pdf_dompdf_pdf_tool_info() {
  );
}

/**
 * Implements hook_theme().
 */
function print_pdf_dompdf_theme() {
  return array(
    'print_pdf_dompdf_footer' => array(
      'variables' => array('html' => ''),
      'file' => 'print_pdf_dompdf.pages.inc',
    ),
  );
}

/**
 * Implements hook_menu().
 */
+0 −57
Original line number Diff line number Diff line
@@ -113,9 +113,6 @@ function print_pdf_dompdf_print_pdf_generate($html, $meta, $paper_size = NULL, $
  $dompdf->set_paper(drupal_strtolower($paper_size), $page_orientation);
  $dompdf->set_protocol($protocol);

  // It seems dompdf can't handle footers cleanly, so disable the following.
  /*  $html = theme('print_pdf_dompdf_footer', array('html' => $html)); */

  // If dompdf Unicode support is disabled, try to convert to ISO-8859-1 and
  // then to HTML entities.
  if (!$unicode) {
@@ -144,57 +141,3 @@ function print_pdf_dompdf_print_pdf_generate($html, $meta, $paper_size = NULL, $
  $dompdf->render();
  return $dompdf->output();
}

/**
 * Format the dompdf footer contents.
 *
 * @param array $vars
 *   An associative array containing:
 *    - $html: contents of the body of the HTML from the original node.
 *
 * @return string
 *   customized HTML text
 *
 * @ingroup themeable
 * @ingroup print_themeable
 */
function theme_print_pdf_dompdf_footer($vars) {
  preg_match('!<div class="print-footer">(.*?)</div>!si', $vars['html'], $tpl_footer);
  if (isset($tpl_footer[1])) {
    $html = str_replace($tpl_footer[0], '', $vars['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);
  }
  else {
    return $vars['html'];
  }
}