Finally, PDF Header for PDF stuffs that work....

From: Date: Tue, 14 Oct 2003 19:02:24 +0000
Subject: Finally, PDF Header for PDF stuffs that work....
Groups: php.general 
Request: Send a blank email to php-general+get-166102@lists.php.net to get a copy of this message
Finally got some PHP header to force IE to display the PDF document right from the file from the server. Due to most of IE bugs, this script will help. It can be either getting a file from the webserver as this script is or you can change the PHP header to use the attachment instead. --snip-- <? $filename=$_REQUEST['PDF_FileName']; $filepath=$_REQUEST['PDF_FilePath']; $filesize=filesize($filepath); header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/pdf"); header("Content-Length: ".$filesize); header("Content-Disposition: inline; filename=$filename"); header("Content-Transfer-Encoding: binary"); //Can't use readfile() due to poor controlling of the file download. //(IE have this problems)... //readfile($filepath); //use fopen() instead of readfile... $fp = fopen($filepath, 'rb'); $pdf_buffer = fread($fp, $filesize); fclose ($fp); print $pdf_buffer; //Required, to keep IE from running into problems //when opening the file while downloading or downloading... //(IE been acting strange...) exit(); ?> --snip--

« previous php.general (#166102) next »