function print_pdf_generate_path in Printer, email and PDF versions 7
Same name and namespace in other branches
- 6 print_pdf/print_pdf.pages.inc \print_pdf_generate_path()
- 7.2 print_pdf/print_pdf.pages.inc \print_pdf_generate_path()
- 5.x print_pdf/print_pdf.pages.inc \print_pdf_generate_path()
1 call to print_pdf_generate_path()
- print_pdf_controller in print_pdf/
print_pdf.pages.inc - Generate a PDF version of the printer-friendly page
File
- print_pdf/
print_pdf.pages.inc, line 86
Code
function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filename = NULL) {
global $base_url;
$print = print_controller($path, $query, $cid, PRINT_PDF_FORMAT);
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']);
// Send to printer option causes problems with PDF
$print['sendtoprinter'] = '';
$node = $print['node'];
$html = theme('print', array(
'print' => $print,
'type' => PRINT_PDF_FORMAT,
'node' => $node,
));
// Convert the a href elements, to make sure no relative links remain
$pattern = '!<(a\\s[^>]*?)>!is';
$html = preg_replace_callback($pattern, '_print_rewrite_urls', $html);
// And make anchor links relative again, to permit in-PDF navigation
$html = preg_replace("!{$base_url}/" . PRINTPDF_PATH . '/.*?#!', '#', $html);
return print_pdf_generate_html($print, $html, $pdf_filename);
}