You are here

function print_pdf_dispose_content in Printer, email and PDF versions 7.2

Displays the PDF as inline or a downloadable file.

Parameters

string $pdf: PDF content string.

string $filename: Filename of the generated PDF.

Return value

string The disposed PDF file

2 calls to print_pdf_dispose_content()
print_pdf_generate_html in print_pdf/print_pdf.module
Generate a PDF version of the provided HTML.
print_pdf_generate_path in print_pdf/print_pdf.pages.inc
Gennerate a PDF for a given Drupal path.

File

print_pdf/print_pdf.module, line 435
Displays Printer-friendly versions of Drupal pages.

Code

function print_pdf_dispose_content($pdf, $filename) {
  if (headers_sent()) {
    exit('Unable to stream pdf: headers already sent');
  }
  header('Cache-Control: private');
  header('Content-Type: application/pdf');
  $content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
  $attachment = $content_disposition == 2 ? 'attachment' : 'inline';
  header("Content-Disposition: {$attachment}; filename=\"{$filename}\"");
  echo $pdf;
  flush();
  return TRUE;
}