Commit 3183f351 authored by jcnventura's avatar jcnventura

Issue #1183460: PDF_PRODUCER no longer available in new versions of TCPDF.

parent 424f83e0
......@@ -194,6 +194,18 @@ function print_pdf_requirements($phase) {
);
}
}
elseif (basename($print_pdf_pdf_tool) == 'tcpdf.php') {
$version = _print_pdf_tcpdf_version();
if (version_compare($version, '5.9.012', '<')) {
$requirements['print_pdf_tool'] = array(
'title' => $t('TCPDF library'),
'value' => $t('Unsupported version'),
'description' => $t('The currently selected version of TCPDF (@version) is not supported. Please update to a <a href="@url">newer version</a>.', array('@version' => $version, '@url' => url('http://www.tcpdf.org'))),
'severity' => REQUIREMENT_ERROR,
);
}
}
elseif (substr(basename($print_pdf_pdf_tool, '.exe'), 0, 11) == 'wkhtmltopdf') {
if (function_exists('is_executable') && !is_executable($print_pdf_pdf_tool)) {
$requirements['print_pdf_tool'] = array(
......@@ -594,6 +606,21 @@ function print_pdf_link_allowed($args) {
return FALSE;
}
/**
* Find out the version of the TCPDF library
*/
function _print_pdf_tcpdf_version() {
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
require_once(DRUPAL_ROOT . '/' . $print_pdf_pdf_tool);
$pdf = new TCPDF();
return $pdf->getTCPDFVersion();
}
/**
* Find out the version of the wkhtmltopdf library
*/
function _print_pdf_wkhtmltopdf_version() {
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
$descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
......
......@@ -10,7 +10,7 @@
* @ingroup print
*/
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'print') . '/print.pages.inc');
module_load_include('inc', 'print', 'print.pages');
/**
* Generate a PDF version of the printer-friendly page
......@@ -251,13 +251,7 @@ function _print_pdf_tcpdf($print, $html, $filename) {
$html = preg_replace($pattern, '$1$2', $html);
require_once(DRUPAL_ROOT . '/' . $print_pdf_pdf_tool);
if (strpos(PDF_PRODUCER, 'PHP4') === FALSE) {
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'print_pdf') . '/print_pdf.class.inc');
}
else {
drupal_set_message(t("The PHP4 version of TCPDF is not supported. Please upgrade it."), 'error', FALSE);
drupal_goto($_GET['q']);
}
module_load_include('inc', 'print_pdf', 'print_pdf.class');
$font = Array(
check_plain(variable_get('print_pdf_font_family', PRINT_PDF_FONT_FAMILY_DEFAULT)),
......@@ -478,9 +472,7 @@ function theme_print_pdf_tcpdf_page($vars) {
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 15);
// set image scale factor
sscanf(PDF_PRODUCER, "TCPDF %d.%d.%d", $major, $minor, $build);
$imagescale = (($major >= 4) && ($minor >= 6) && ($build >= 2)) ? 1 : 4;
$pdf->setImageScale($imagescale);
$pdf->setImageScale(1);
// set image compression quality
$pdf->setJPEGQuality(100);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment