Solved

Opening pdf in browser

Posted on 2006-10-31
14
408 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
ID: 17840964
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
ID: 17840969
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
ID: 17840993
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
ID: 17841232
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
ID: 17841235
0
 
LVL 7

Author Comment

by:ayha1999
ID: 17849927
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
ID: 17851049
That method is available in 1.1, so are you using 2.0?

Bob
0
 
LVL 7

Author Comment

by:ayha1999
ID: 17851735
No. I am using ver. 1.1.

ayha
0
 
LVL 7

Author Comment

by:ayha1999
ID: 17851807
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
ID: 17851963
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
ID: 17890315
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
ID: 17897436
Where are you calling that from?  A web page?  A class?

Bob
0
 
LVL 7

Author Comment

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

ayha
0
 
LVL 5

Expert Comment

by:knowlton
ID: 20880336
Bob:

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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