Reputation: 3
I am sending a PDF file which has been created in a MemoryStream
back to the browser using Response.BinaryWrite(pdfResponse)
. This works fine. Except for one small nuance I have noticed. If I run my application in 32bit IE9, the PDF opens in a browser window. However, if I am using IE9 64bit to view the app, it loads (like I desire) in Adobe Reader. The full response is below:
byte[] pdfResponse = pdfStream.ToArray();
Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Content-Type", "application/pdf");
Response.BinaryWrite(pdfResponse);
Response.Flush();
Response.End();
Two questions:
Upvotes: 0
Views: 342
Reputation: 120450
This has nothing to do with the server side code and everything to do with the configuration of the browser (effectively it's a user preference).
There is no x64 Acrobat AX control.
Your best bet is to supply a Content-Disposition header
to force download. User then can decide to open or save the download (which will open in the registered app for PDF).
Response.AddHeader("Content-Disposition", "attachment; filename=mypdf.pdf");
(as an aside, allowing websites to arbitrarily open the Acrobat plugin in my browser is a behaviour I turned off a long time ago... Two words: attack vector)
Upvotes: 2
Reputation: 1826
What I just found:
> Reset the Display PDF In Browser preference
In Reader or Acrobat, right-click the document window, and select Page Display Preferences. From the list at left, select Internet. Deselect Display PDF In Browser, and then click OK. Choose Edit > Preferences > Internet, select Display PDF In Browser, and then click OK.
> Try to open the PDF again from the website.
> View PDF in 32-bit version of Internet Explorer or Safari
Acrobat and Reader are 32-bit applications on Windows. If you try to open a PDF in a 64-bit version of Internet Explorer, the PDF opens in stand-alone Acrobat or Reader, not in Internet Explorer.
Note: Only Reader 10.1 or Acrobat 10.1 and later support Internet Explorer 9.
To make sure that you are using a 32-bit version of Internet Explorer, follow these steps:
In Internet Explorer, choose Help > About Internet Explorer. (In some versions of Internet Explorer, select the Question mark in the upper-right corner to select About Internet Explorer).
If you see "64-bit Edition" next to the version, then switch to the 32-bit version of Internet Explorer.
To switch to the 32-bit Internet Explorer, first exit 64-bit Internet Explorer. Then double-click the program icon for the 32-bit version:
C:\Program Files (x86)\Internet Explorer\iexplore.exe
Maybe that helps
Upvotes: 0