2
votes

I upload & save PDF in SQL. Then people can open that PDF in web browser (IE). Today I've updated Acrobat Reader and I cannot open same PDF in web browser. I can save it to desktop then open it. There is no [Open] button in dialog box and it says file might be corrupted

Name: admin.pdf

Type: Adobe Acrobat Document, 37,8 KB

From: domain.com

*

Dynamically generated PDF' link is like below: http://domain.com/admin.asp?cmd=Download_PDF&id=20112

I did every solutions on both Adobe & Microsoft websites. I cannot open PDF files directly in IE8.

My ex-ASP code was:

    Response.ContentType = rsFile("filetype")
    Response.BinaryWrite rsFile("filedata")

Then I just changed it to make PDF as downloadable file, now I can -at least- download & open it in external Acrobat Reader (dialog box shows [Open] [Download] [Cancel] buttons):

 Response.Buffer = TRUE
    'Response.ContentType = "application/pdf"
    Response.ContentType = rsFile("filetype")
    Response.AddHeader "Content-Disposition", "attachment; filename=" & filename & ".pdf"       
    Response.BinaryWrite rsFile("filedata")
2
The solution on the duplicate issue managed above actually resolved the issue for me by setting the Cache-control to max-age=1 rather than no-cacheDijkgraaf

2 Answers

4
votes

I just stumbled upon this exact same problem today, and dug up a solution.

We also have a site that's serving up pdfs stored in an SQL database. When the aspx page tries to serve up the pdf, it displays exactly the same dialog you're describing. It only affects IE8 (no one here has any other version of IE I could test); the most recent versions of Chrome, Firefox, and Safari, all loaded the pdfs in the browser without incident.

So after I found your question, I dug around some more, and found the following:

http://forums.adobe.com/thread/792591

Starting with adobe reader 9.4.2, a bug was introduced relating to character sets, such that if the Content-Type has a charset value, adobe will end up looking for a registry key that doesn't exist.

I did what jspraul suggested in response 17, and added:

Response.Charset = null;

Like you, I had simply set my Content-Type to application/pdf, but because my Response.Charset had a value of UTF-8 by default, adobe was looking for a registry key related to UTF-8 and failing to find it. Hopefully adobe will patch this at some point, but that should fix your problem in the interim.

1
votes

The reason why you the PDF is not opening in the browser is because the new installation of Adobe Reader is not registered as an IE plugin. Maybe the old plugin needs needs to be removed first.

If a particular version of Adobe Reader does not open a PDF, then it is possible that the PDF is corrupted. Ensure that your ASP code is closely packed and you do not by mistake write a space or newline to the browser. Remember to call Response.Flush at the end.

If you add the attachment header then the File save dialog will be shown and the PDF plugin will not catch the PDF inside the browser.

Your browser may also be loading a older corrupt copy of the PDF from the cache. Empty your IE cache (temporary Internet files).