views:

180

answers:

5

I'm working on a web app that allows users to downloaded dynamically generated PDF files.

This works fine in IE8 and Firefox but fails in IE6 with Adobe Reader giving the message "there was an error opening this document. this file cannot be found"

If I save the file to disk first then it opens fine in Reader.

I've given the file a simple short filename, without spaces so not sure what else to try. Any suggestions are very welcome.

Further info: PDF is generated in asp.net code using the abcpdf plugin

A: 

Maybe because of timeout setting in Adobe Reader Activex for IE. You respond the browser with a partially finished document then your program took some time to continue responding for the rest of document and Adobe Reader timeoutted. Try to generating entire PDF document and then respond to http request. for example in php.

$s = "";
for(int i=0;i<10;i++)
    $s .= "1";
echo #s;

instead of

for(int i=0;i<10;i++)
    echo "1";
VOX
PDF document is fully generated before response is sent I beleive
chillysapien
check for MIME type to see if you responded proper MIME type as PDF to browser?
VOX
MIME type is set to application/pdf.
chillysapien
+2  A: 

Is there really a need for IE6 support on your webpage? Would a valid solution be to simply require users to upgrade to a later version of IE?

IE6 died two and a half months ago. (IE6 Funeral)

Steven
Or, if you really want to continue to support IE6 just give IE6 users instructions on how to right click on the link to save the file on their HD.
nico
Unfortunately there is a business requirement to support IE6 much to the chagrin of all developers here. Just providing an explanation of a workaround is my fallback solution but would like to know why this problem is occuring in the first place
chillysapien
+1  A: 

Have you tried Response.ClearHeaders();?

Gert G
A: 

IMHO that's a header interpretation problem. I'm not very familiar or fond of ASP.NET but at least in PHP you need to have these:

ob_start(); (* should be equivalent to HttpContext.Current.Response.Buffer = true *)

header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=somefile.pdf'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); //header('Content-Length: ' . filesize($file));

ob_flush(); (* should be equivalent to HttpContext.Current.Response.Flush() ) * output the pdf contents here

(* header() should be similar to HttpContext.Current.Response.AddHeader() function *)

NOTE that setting Content-Length: together with content-disposition: attachment might fail to work in safari and ie.

hope it helps...

sonicempire
A: 

i think i have observed such most annoying behavior (bug) in IE6 and if i recollect, the reason for the error was that the file was not stored in the cache but expired/deleted right away. Check the following:

  1. are you returning the file over HTTPS?
  2. check the headers of the response, anything about expiration?
  3. are you having the same issues with the file served statically (but in almost the same URL, try '.../file.pdf' and '.../file.asp' with browser-redirect to /file.pdf)
Nas Banov