You are here

function certificate_print_pdf_wrapper in Certificate 3.x

Same name and namespace in other branches
  1. 8.3 certificate.pages.inc \certificate_print_pdf_wrapper()
  2. 7.3 certificate.pages.inc \certificate_print_pdf_wrapper()
  3. 7.2 certificate.pages.inc \certificate_print_pdf_wrapper()

Wrapper to use correct Print API functions across versions.

2 calls to certificate_print_pdf_wrapper()
certificate_preview in ./certificate.pages.inc
Preview certificate template as PDF.
certificate_single in ./certificate.pages.inc
Generate a single certificate.

File

./certificate.pages.inc, line 238
certificate.pages.inc Functions for generating certificates.

Code

function certificate_print_pdf_wrapper($filename, $html, $orientation) {
  module_load_include('pages.inc', 'print_pdf', 'print_pdf');
  module_load_include('inc', 'print', 'includes/print');

  // Rewrite image URLs using Print.
  $pattern = '!<(img\\s[^>]*?)>!is';
  $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html);
  if (function_exists('_print_scan_libs')) {

    // Print 2.x
    $meta = array(
      'url' => url(current_path(), array(
        'absolute' => TRUE,
      )),
      'name' => '',
      'title' => '',
      'node' => NULL,
    );
    print_pdf_generate_html($html, $meta, $filename, NULL, $orientation);
  }
  else {

    // Print 1.x
    global $conf;
    $conf['print_pdf_page_orientation'] = $orientation;
    $print = array(
      'url' => url(current_path(), array(
        'absolute' => TRUE,
      )),
      'node' => NULL,
    );
    print_pdf_generate_html($print, $html, $filename);
  }
  exit;
}