Skip to content

Instantly share code, notes, and snippets.

@gjerokrsteski
Created December 8, 2010 16:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjerokrsteski/733490 to your computer and use it in GitHub Desktop.
Save gjerokrsteski/733490 to your computer and use it in GitHub Desktop.
sends pdf-file as header through any firewall and browser
/**
* Prints out the new generated pdf-file as an raw HTTP-header.
* @link http://reeg.junetz.de/DSP/node16.html
* @link http://www.php.net/manual/de/function.header.php#88038
* @return void
*/
function sendPdfFileAsHeader($pdfFile, $fileName)
{
$disposition = (false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5'))
? ''
: 'attachment; ';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: application/pdf");
header("Content-Disposition: ".$disposition."filename=".$fileName.";");
header("Content-Transfer-Encoding: binary");
readfile($pdfFile);
echo $pdf;exit;
} // function
@gjerokrsteski
Copy link
Author

sends pdf-file as header through any firewall and browser - IE6, IE7, IE8, IE9, FF3.6, FF11, Safari, Chrome, Opera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment