English 中文(简体)
Adobe Reader unable to open downloaded file in IE6
原标题:

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

最佳回答

Have you tried Response.ClearHeaders();?

问题回答

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)

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";

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)

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...





相关问题
Image rendered with wrong colors in IE8

I have a gradient image as a PNG (no transparency) in a web-page. By taking a screenshot of Chrome showing the page and cropping the image from the page, I see the exact same colors are drawn as the ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

Internet Explorer only part loading JavaScript/CSS

I m having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签