Solved

Opening pdf in browser

Posted on 2006-10-31
14
406 Views
Last Modified: 2008-02-01
Hi,

How can I open pdf files in browser?

pls. give me vb code?

ayha
0
Comment
Question by:ayha1999
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 8

Expert Comment

by:razo
Comment Utility
can u please provide more details on how u want to open a pdf? is it a link?
0
 
LVL 7

Author Comment

by:ayha1999
Comment Utility
Hi,

I am storing pdf file names in the table dispaly in the page as links. when user click on the link I want to open in a new browser window?

ayha
0
 
LVL 8

Expert Comment

by:razo
Comment Utility
just create a regular link for the pdf like u would for any other html page and have the target as _blank and ur pdf will open in a new browser
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
Comment Utility
Response.Buffer = false; //transmitfile self buffers
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", "attachment; filename=myfile.pdf")
Response.TransmitFile(documentPath) //transmitfile keeps entire file from loading into memory
Response.End

Bob


0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
0
 
LVL 7

Author Comment

by:ayha1999
Comment Utility
Hi bob,

I get an error at the following line

Response.TransmitFile <---- TransmitFile is not a member of HttpResponse

and what is documentPath?

ayha
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
That method is available in 1.1, so are you using 2.0?

Bob
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Author Comment

by:ayha1999
Comment Utility
No. I am using ver. 1.1.

ayha
0
 
LVL 7

Author Comment

by:ayha1999
Comment Utility
Here I am just storing pdf filename in the table and original file in a folder. then display the filename as a link.when user clickon the linkIwant to openthe file in a new browser.

ayha
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
If you have 1.1, then you should have Response.TransmitFile.  'documentPath' is the local file name for the .PDF file.

Bob
0
 
LVL 7

Author Comment

by:ayha1999
Comment Utility
Hi Bob,

My asp.net version is 1.1 but still I get compilation error

Response.TransmitFile <---- TransmitFile is not a member of HttpResponse

what's wrong?

ayha
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Where are you calling that from?  A web page?  A class?

Bob
0
 
LVL 7

Author Comment

by:ayha1999
Comment Utility
in a page.  some other solution worked with 'Response.WriteFile method.

ayha
0
 
LVL 5

Expert Comment

by:knowlton
Comment Utility
Bob:

Thank you -- your accepted solution above helped me out today.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now