You are here

function _print_pdf_tcpdf_version in Printer, email and PDF versions 6

Same name and namespace in other branches
  1. 7 print_pdf/print_pdf.module \_print_pdf_tcpdf_version()

Find out the version of the TCPDF library

1 call to _print_pdf_tcpdf_version()
print_pdf_requirements in print_pdf/print_pdf.module
Implementation of hook_requirements().

File

print_pdf/print_pdf.module, line 643
Displays Printer-friendly versions of Drupal pages.

Code

function _print_pdf_tcpdf_version() {
  $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
  if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {

    // prevent TCPDF default configs
    define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
  }
  require_once $print_pdf_pdf_tool;

  // Hide warnings, as some TCPDF constants may still be undefined
  if (class_exists('TCPDF')) {
    @($pdf = new TCPDF());
    if (class_exists('TCPDF_STATIC')) {
      return TCPDF_STATIC::getTCPDFVersion();
    }
    elseif (method_exists($pdf, 'getTCPDFVersion')) {
      return $pdf
        ->getTCPDFVersion();
    }
    elseif (defined('PDF_PRODUCER')) {
      sscanf(PDF_PRODUCER, "TCPDF %s", $version);
      return $version;
    }
  }
  return 'unknown';
}