How to open PDF in Reader rather than download file
I've inherited a VB.net application that uses a button click to open PDF files stored on a server. I want the PDF to open in Adobe Reader, but the following code downloads the file instead. How can I open it in Reader?
Code:
...
Response.Buffer = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-disposition", "attachment; filename=" & name)
Response.TransmitFile("c:\12345.pdf")
Response.End()
Re: How to open PDF in Reader rather than download file
You could continue with that code, then immediately after that…
Code:
Process.Start(“c:/12345.pdf”)
Re: How to open PDF in Reader rather than download file
The op's code is on the server tho... so using Process.Start isn't going to work... They're transmitting a PDF file from the server to the client... and the client is downloading the file rather than opening it in Reader. As far as I know there isn't anything on the server side you can do to change that. It's a client issue.
I'm truying to remember if a plugin in is needed or not... I work on an app that does PDFs and they just open in the browser, but it's been so long since I set it up, I don't remember exactly how I did it.
-tg
Re: How to open PDF in Reader rather than download file
Thanks for your help! I found I can prevent download with the following code change. This opens PDF in same tab of browser. If no convenient way to open in Adobe Reader, is there a way to open in new tab?
Code:
Response.AddHeader("Content-disposition", "inline; filename=" & name)
Re: How to open PDF in Reader rather than download file
Re: How to open PDF in Reader rather than download file
This method worked. Thanks jdc2000!