]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?>!is";
$html = preg_replace_callback($pattern, function ($matches) { return html_entity_decode($matches[0], ENT_QUOTES); }, $html);
// Remove queries from the image URL.
$pattern = "!(]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?)(?:%3F|\?)[^\s'\"]+([^>]*?>)!is";
$html = preg_replace($pattern, '$1$2', $html);
$tool_path = DRUPAL_ROOT . '/' . $pdf_tool[1];
if (file_exists($tool_path)) {
require_once $tool_path;
}
else {
watchdog('print_pdf', 'Configured PDF tool does not exist at path: %path', array('%path' => $tool_path), WATCHDOG_ERROR);
throw new Exception("Configured PDF tool does not exist, unable to generate PDF.");
}
module_load_include('inc', 'print_pdf_tcpdf', 'print_pdf_tcpdf.class');
$font = array(
check_plain(variable_get('print_pdf_font_family', PRINT_PDF_TCPDF_FONT_FAMILY_DEFAULT)),
'',
check_plain(variable_get('print_pdf_font_size', PRINT_PDF_TCPDF_FONT_SIZE_DEFAULT)),
);
$orientation = drupal_strtoupper($page_orientation[0]);
// Create new PDF document.
$pdf = new PrintTCPDF($orientation, 'mm', $paper_size, TRUE);
// Set document information.
if (isset($meta['name'])) {
$pdf->SetAuthor(strip_tags($meta['name']));
}
$pdf->SetCreator(variable_get('site_name', 'Drupal'));
$pdf->SetTitle(html_entity_decode($meta['title'], ENT_QUOTES, 'UTF-8'));
$pdf->setPDFVersion('1.6');
$pdf->setFontSubsetting(variable_get('print_pdf_font_subsetting', PRINT_PDF_TCPDF_FONT_SUBSETTING_DEFAULT));
$pdf->setTcpdfLink(FALSE);
if ($language->direction == LANGUAGE_RTL) {
$pdf->setRTL(TRUE);
}
$pdf = theme('print_pdf_tcpdf_header', array(
'pdf' => $pdf,
'html' => $html,
'font' => $font,
));
$pdf = theme('print_pdf_tcpdf_footer', array(
'pdf' => $pdf,
'html' => $html,
'font' => $font,
));
$pdf = theme('print_pdf_tcpdf_page', array('pdf' => $pdf));
// Enable third-party module to alter the pdf object, via
// hook_print_pdf_tcpdf_alter().
drupal_alter('print_pdf_tcpdf', $pdf, $html, $meta);
// Add a page.
$pdf->AddPage();
$pdf = theme('print_pdf_tcpdf_content', array(
'pdf' => $pdf,
'html' => $html,
'font' => $font,
));
// Reset pointer to the last page.
$pdf->lastPage();
// Try to recover from any warning/error.
ob_clean();
return $pdf = $pdf->Output('', 'S');
}
/**
* Format the TCPDF header.
*
* @param array $vars
* An associative array containing:
* - $pdf: current TCPDF object
* - $html: contents of the body of the HTML from the original node
* - $font: array with the font definition (font name, styles and size)
*
* @return object
* modified PDF object
*
* @ingroup themeable
* @ingroup print_themeable
*/
function theme_print_pdf_tcpdf_header($vars) {
global $base_url;
$pdf = $vars['pdf'];
preg_match('!