You are here

function print_pdf_tcpdf_pdf_tool_version in Printer, email and PDF versions 7.2

Implements hook_pdf_tool_version().

File

print_pdf/lib_handlers/print_pdf_tcpdf/print_pdf_tcpdf.module, line 82
Generate a PDF for the print_pdf module using the TCPDF library.

Code

function print_pdf_tcpdf_pdf_tool_version($pdf_tool) {
  if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {

    // Prevent TCPDF default configs.
    define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
  }
  if (file_exists(DRUPAL_ROOT . '/' . $pdf_tool)) {
    include_once DRUPAL_ROOT . '/' . $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';
}