Created
December 8, 2010 16:18
-
-
Save gjerokrsteski/733490 to your computer and use it in GitHub Desktop.
sends pdf-file as header through any firewall and browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sends pdf-file as header through any firewall and browser - IE6, IE7, IE8, IE9, FF3.6, FF11, Safari, Chrome, Opera