Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with header() when displaying a PDF file in IE8

Tags:

php

pdf

header

So, I have a file that sends the following:

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: private");
header("Content-type: application/pdf");
header("Content-disposition: inline; filename=file.pdf");
header("Content-length: 7735");

then I echo out the file - it is a PDF file.

Works fine in IE6 & 7 on XP (and FF for that matter) The very same code shows nothing when running on IE8 on either XP or Vista. There are no security warnings, etc so I don't think it has to do with that.

And, if my memory serves me correctly, this worked on IE8 a while ago.

What am I doing wrong here? Am I missing something out of the headers?

Is there a way for me to see what header information normal comes over when viewing a PDF in IE8 so I know what to emulate?

After looking at things it still works in IE8 EXCEPT when SSL is on

like image 993
Jason Avatar asked Aug 07 '09 04:08

Jason


3 Answers

Under HTTPS and IE8, those headers fix the download problem:

header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Pragma: public");

Other X-something headers did not make any difference.

like image 57
mikikg Avatar answered Oct 20 '22 14:10

mikikg


It has probably to do do with the SSL. I read this article (in German, with code examples) where the author set the following header:

header('Pragma: anytextexeptno-cache', true);
like image 2
chiborg Avatar answered Oct 20 '22 15:10

chiborg


I'm not sure what is needed, but here is what you could do. Put the file temporarily in a public place on your server, make syre you can download that with a direct link in IE8, Use firefox LiveHTTP headers or similar to grab all headers that the server sends. Spit them out in exactly the same way and order in your script. (And don't forget to delete the file).

like image 1
user152247 Avatar answered Oct 20 '22 14:10

user152247