Commit b658d760 authored by jcnventura's avatar jcnventura

Add some help text to content-type settings to explain that the module-wide...

Add some help text to content-type settings to explain that the module-wide settings must be enabled.
Add option to auto-configure the TCPDF library (on by default)
Only remove queries from img URLs which TCPDF will try to access locally
parent bfb5cb0d
......@@ -375,6 +375,7 @@ function print_form_alter(&$form, $form_state, $form_id) {
$form['print']['print_display']['#default_value'] = variable_get('print_display_' . $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$form['print']['print_display_comment']['#default_value'] = variable_get('print_display_comment_' . $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$form['print']['print_display_urllist']['#default_value'] = variable_get('print_display_urllist_' . $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
$form['print']['label']['#markup'] = '<p><em>' . t('The settings below only apply when some of the corresponding module-wide link settings are enabled.') . '</em></p>' . $form['print']['label']['#markup'];
}
else {
$node = $form['#node'];
......
......@@ -164,6 +164,12 @@ function print_pdf_settings() {
'#default_value' => variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT),
'#description' => t('Choose the page orientation of the generated PDF.'),
);
$form['settings']['print_pdf_autoconfig'] = array(
'#type' => 'checkbox',
'#title' => t('Auto-configure the TCPDF settings'),
'#default_value' => variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT),
'#description' => t('(TCPDF only) If you disable this option, the TCDPF settings in tcpdf/config/tcpdf_config.php file must be configured manually.'),
);
$form['settings']['print_pdf_font_family'] = array(
'#type' => 'textfield',
'#title' => t('Font Family'),
......
......@@ -23,6 +23,7 @@ define('PRINT_PDF_PDF_TOOL_DEFAULT', 0);
define('PRINT_PDF_CONTENT_DISPOSITION_DEFAULT', 2);
define('PRINT_PDF_PAPER_SIZE_DEFAULT', 'A4');
define('PRINT_PDF_PAGE_ORIENTATION_DEFAULT', 'portrait');
define('PRINT_PDF_AUTOCONFIG_DEFAULT', 1);
define('PRINT_PDF_FONT_FAMILY_DEFAULT', 'dejavusans');
define('PRINT_PDF_FONT_SIZE_DEFAULT', 10);
define('PRINT_PDF_FILENAME_DEFAULT', '[site-name] - [title] - [mod-yyyy]-[mod-mm]-[mod-dd]');
......
......@@ -183,21 +183,23 @@ function _print_pdf_tcpdf($print, $html, $filename) {
$pdf_tool_path = realpath(dirname($print_pdf_pdf_tool));
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
define('K_PATH_URL', $base_url);
define('K_PATH_FONTS', $pdf_tool_path . '/fonts/');
define('K_PATH_CACHE', $pdf_tool_path . '/cache/');
define('K_PATH_IMAGES', '');
define('K_BLANK_IMAGE', $pdf_tool_path . '/images/_blank.png');
define('K_CELL_HEIGHT_RATIO', 1.25);
define('K_SMALL_RATIO', 2/3);
if (variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT)) {
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
define('K_PATH_URL', $base_url);
define('K_PATH_FONTS', $pdf_tool_path . '/fonts/');
define('K_PATH_CACHE', $pdf_tool_path . '/cache/');
define('K_PATH_IMAGES', '');
define('K_BLANK_IMAGE', $pdf_tool_path . '/images/_blank.png');
define('K_CELL_HEIGHT_RATIO', 1.25);
define('K_SMALL_RATIO', 2/3);
}
// Decode HTML entities in image filenames
$pattern = "!<img[^>]*?>!is";
$pattern = "!<img\s[^>]*?src\s*?=\s*?['\"]?${base_url}[^>]*?>!is";
$html = preg_replace_callback($pattern, create_function('$matches', 'return html_entity_decode($matches[0], ENT_QUOTES);'), $html);
// Remove queries from the image URL
$pattern = "!(<img\s[^>]*?src\s*?=.*?)(?:%3F|\?)[\w=&]+([^>]*?>)!is";
$pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?${base_url}.*?)(?:%3F|\?)[\w=&]+([^>]*?>)!is";
$html = preg_replace($pattern, '$1$2', $html);
require_once(DRUPAL_ROOT . '/' . $print_pdf_pdf_tool);
......
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