views:

263

answers:

3

Hi all,

I have got a PDF fle which i would like my users to download when they click on a button/link/image.Is this possible?

Thank You

+1  A: 

What's wrong with...

<a href="file.pdf">pdf</a>
meder
it opens the pdf documnet in the pdf reader,i want the users to download the document. It should invoke the small "File Download" window, where it asks you to open or save the file.
manraj82
i hope u know wat im talking about,this window has got three buttons Open , Save and Cancel
manraj82
+4  A: 

If you want to override any plugins for viewing a PDF in browser, then you need to send an HTTP Content-Disposition header to state that it should be treated as an attachment.

The specifics of how you achieve this depend on the server side environment you are using. JavaScript can't help you (unless you are using a server side JavaScript implemention, which is unlikely).

David Dorward
its an ASP IIS environmnet,like you said I just tried the HTTP Content-Disposition header.this is the code i used on the ASP pageResponse.AddHeader "content-disposition","attachment; filename=test.pdf"It did invoke the file download window,but in the Save As window it didnt have the "Adobe Acrobat Document" item in the Save As Type list.It only had 'HTML Document' and 'All files'
manraj82
Am i doing sumthin wrong? please advise...
manraj82
Sounds like you are letting ASP continue to use its default content-type output of text/html instead of setting it to application/pdf (how you do that in ASP I have no idea, I'm happy to avoid that framework).
David Dorward
Agreed. In more simple terms he needs to change the mime-type from application/pdf to something else that is not recognized, such as application/zzzzzzzzzz
No. He does not need to lie about the content type. He needs to specify that the PDF is PDF (and not HTML) and use Content-Disposition to trigger a download instead of the default handler.
David Dorward
guys i really apprecaite your comments, i tried the following code but stiil no joy.<%Response.AddHeader "content-disposition","attachment; filename=test.pdf"%>i even referred this link http://support.microsoft.com/kb/260519 but no luck.
manraj82
its not allowing me to save it as a Adobe Acrobat Document
manraj82
As mentioned twice already — you need to specify the content-type as application/pdf too.
David Dorward
A: 

I would simply configure IIS to server .pdf files as the MIME type application/octet-stream

Ian Oxley