• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

Opening pdf in browser

Hi,

How can I open pdf files in browser?

pls. give me vb code?

ayha
0
ayha1999
Asked:
ayha1999
  • 6
  • 5
  • 2
  • +1
1 Solution
 
razoCommented:
can u please provide more details on how u want to open a pdf? is it a link?
0
 
ayha1999Author Commented:
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
 
razoCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Bob LearnedCommented:
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
 
Bob LearnedCommented:
0
 
ayha1999Author Commented:
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
 
Bob LearnedCommented:
That method is available in 1.1, so are you using 2.0?

Bob
0
 
ayha1999Author Commented:
No. I am using ver. 1.1.

ayha
0
 
ayha1999Author Commented:
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
 
Bob LearnedCommented:
If you have 1.1, then you should have Response.TransmitFile.  'documentPath' is the local file name for the .PDF file.

Bob
0
 
ayha1999Author Commented:
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
 
Bob LearnedCommented:
Where are you calling that from?  A web page?  A class?

Bob
0
 
ayha1999Author Commented:
in a page.  some other solution worked with 'Response.WriteFile method.

ayha
0
 
Tom KnowltonWeb developerCommented:
Bob:

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now