-
Dec 2nd, 2021, 09:38 AM
#1
Thread Starter
Junior Member
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()
Last edited by Rhodo; Dec 2nd, 2021 at 02:27 PM.
-
Dec 2nd, 2021, 04:50 PM
#2
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”)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 2nd, 2021, 07:23 PM
#3
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
-
Dec 3rd, 2021, 02:02 PM
#4
Thread Starter
Junior Member
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)
-
Dec 3rd, 2021, 06:43 PM
#5
Re: How to open PDF in Reader rather than download file
-
Dec 6th, 2021, 09:16 AM
#6
Thread Starter
Junior Member
Re: How to open PDF in Reader rather than download file
This method worked. Thanks jdc2000!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|