Comment inline below.

On Tue, Jun 29, 2010 at 3:23 PM, Zachary Valentiner
<zvalenti...@gmail.com>wrote:

> Hi Dola,
>
> Setting the content type to "application/octet-stream" will force a
> download. If I recall my headers correclty, setting "application/pdf" is as
> close as you can get to telling it to open in the browser without embedding
> it in an HTML file directly and thereby forcing the browser to use a plugin
> to render the PDF.
>

 "application/octet-stream" is one way, but it's by no means bullet-proof.
If the file name has an extension, some version of IE will blow off the MIME
type and do what they damn well please based on the extension.


> Someone might have some other tip, but this is also somewhat browser/plugin
> dependent, e.g., I notice different behavior between Firefox and Chrome,
> even when opening the same links to the same PDFs.
>
> Good luck,
>
> Zach
>

A while back I did some digging around and found that for all browsers I
should call response.addHeader("Content-Disposition", "attachment;
filename="myfile.pdf").  Then for IE I call
response.setContentType("application/force-download; name="myfile.pdf")
while for Firefox and Safari I use
response.setContentType("application/octet-stream; name="myfile.pdf") works
best.

-- 
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, 'Doctor Faustus' (v, 121-24)

Reply via email to