Solved

Opening pdf in browser

Posted on 2006-10-31
14
407 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

22 Experts available now in Live!

Get 1:1 Help Now