You are here

function certificate_preview in Certificate 6.2

Same name and namespace in other branches
  1. 8.3 certificate.pages.inc \certificate_preview()
  2. 6 certificate.pages.inc \certificate_preview()
  3. 7.3 certificate.pages.inc \certificate_preview()
  4. 7.2 certificate.pages.inc \certificate_preview()
  5. 3.x certificate.pages.inc \certificate_preview()

Preview certificate template as PDF.

1 string reference to 'certificate_preview'
certificate_menu in ./certificate.module
Implementation of hook_menu().

File

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

Code

function certificate_preview($template_id) {
  $template = node_load($template_id);
  if ($template) {
    $output = '<html><head><meta charset="utf-8"/></head><body>' . theme('certificate_certificate', $node, $account, $template) . '</body></html>';
  }
  $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', '');
  if ($print_pdf_pdf_tool == '') {
    drupal_set_message('Certificate cannot be displayed because you have not selected a PDF generation tool in !link.', array(
      '!link' => l('Printer, e-mail and PDF versions', 'admin/settings/print/pdf') . '.',
      'error',
    ));
    return '';
  }
  module_load_include('pages.inc', 'print_pdf', 'print_pdf');

  // Rewrite image URLs using Print.
  $pattern = '!<(img\\s[^>]*?)>!is';
  $output = preg_replace_callback($pattern, '_print_rewrite_urls', $output);
  global $conf;
  $conf['print_pdf_page_orientation'] = $template->certificate['orientation'];
  print_pdf_generate_html(array(
    'node' => $node,
  ), $output, $template->title . '.pdf');
}