function print_pdf_controller in Printer, email and PDF versions 5.3
Same name and namespace in other branches
- 5.4 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 6 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 7.2 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 7 print_pdf/print_pdf.pages.inc \print_pdf_controller()
- 5.x print_pdf/print_pdf.pages.inc \print_pdf_controller()
Generate a PDF version of the printer-friendly page
See also
1 string reference to 'print_pdf_controller'
- print_pdf_menu in print_pdf/
print_pdf.module - Implementation of hook_menu().
File
- print_pdf/
print_pdf.pages.inc, line 21
Code
function print_pdf_controller() {
global $base_url;
$args = func_get_args();
// Remove the printpdf/ prefix
$path = implode('/', $args);
$cid = isset($_GET['comment']) ? (int) $_GET['comment'] : NULL;
$print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
$print = print_controller($path, $cid);
if ($print === FALSE) {
return;
}
// Img elements must be set to absolute
$pattern = '!<(img\\s[^>]*?)>!is';
$print['content'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['content']);
$print['logo'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['logo']);
$print['footer_message'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['footer_message']);
// And converted from private to public paths
$file_downloads = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC);
if ($file_downloads == FILE_DOWNLOADS_PRIVATE) {
$pattern = "!(<img\\s[^>]*?src\\s*?=\\s*?['\"]?{$base_url}/)system/files(/[^>]*?>)!is";
$replacement = '$1' . file_directory_path() . '$2';
$print['content'] = preg_replace($pattern, $replacement, $print['content']);
$print['logo'] = preg_replace($pattern, $replacement, $print['logo']);
$print['footer_message'] = preg_replace($pattern, $replacement, $print['footer_message']);
}
$node = $print['node'];
ob_start();
include_once _print_get_template('pdf', $print['type']);
$html = ob_get_contents();
ob_end_clean();
if (basename($print_pdf_pdf_tool) == 'dompdf_config.inc.php') {
_print_pdf_dompdf($print, $html, $path . '.pdf');
}
elseif (basename($print_pdf_pdf_tool) == 'tcpdf.php') {
_print_pdf_tcpdf($print, $html, $path . '.pdf');
}
else {
return drupal_not_found();
}
}