You are here

private function PdfFormat::getHeaders in Printer and PDF versions for Drupal 8+ 2.x

Same name and namespace in other branches
  1. 8 modules/printable_pdf/src/Plugin/PrintableFormat/PdfFormat.php \Drupal\printable_pdf\Plugin\PrintableFormat\PdfFormat::getHeaders()

Return default headers (may be overridden by the generator).

Parameters

string $filename: The filename to suggest to the browser.

bool $download: Whether to download the PDF or display it in the browser.

Return value

array Default headers for the response object.

File

modules/printable_pdf/src/Plugin/PrintableFormat/PdfFormat.php, line 274

Class

PdfFormat
Provides a plugin to display a PDF version of a page.

Namespace

Drupal\printable_pdf\Plugin\PrintableFormat

Code

private function getHeaders($filename, $download) {
  $disposition = $download ? 'attachment' : 'inline';
  return [
    'Content-Type' => Unicode::mimeHeaderEncode('application/pdf'),
    'Content-Disposition' => $disposition . '; filename="' . $filename . '"',
    'Content-Length' => filesize($filename),
    'Content-Transfer-Encoding' => 'binary',
    'Pragma' => 'no-cache',
    'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
    'Expires' => '0',
    'Accept-Ranges' => 'bytes',
  ];
}