944,181 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 30460
  • ASP.NET RSS
Dec 10th, 2006
0

Opening a .pdf file at the clientside without the open/save dialog box

Expand Post »
Hi guys

Need some help with an problem thats bugging me..
I have to open a .pdf file at the client side when the user clicks a button..

Opening is not a problem.. I am able to do it using the following code
which is executed when the user clicks on the button

MyFileStream = New FileStream("E:\MyWork\Test\DownloadFiles\Reports\Rpt.pdf", FileMode.Open)
FileSize = MyFileStream.Length
Dim Buffer(CType(FileSize, Integer)) As Byte
MyFileStream.Read(Buffer, 0, CType(MyFileStream.Length, Integer))
MyFileStream.Close()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename=MyReport.PDF")
Response.BinaryWrite(Buffer)


The problem is that the user first sees a 'Open/ Save / Cancel' dialog box. Only when the user clicks on 'Open' does the .pdf file get opened.
My client wants it to be opened directly when the button is clicked.
Am at a loss and any help will be appreciated...

Thanks in advance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Phoenix777 is offline Offline
10 posts
since Jul 2006
Dec 12th, 2006
0

Re: Opening a .pdf file at the clientside without the open/save dialog box

Also is there any other way to open the file at the client side?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Phoenix777 is offline Offline
10 posts
since Jul 2006
Dec 13th, 2006
0

Re: Opening a .pdf file at the clientside without the open/save dialog box

Hi ,
R u seaching for something like this.....

String strPop = "<script language='javascript'>" + Environment.NewLine +
"window.open('E:\MyWork\Test\DownloadFiles\Reports\Rpt.pdf"','Report','height=520,width=730,toolbars=no,scrollbars=yes,resizable=yes');" + Environment.NewLine +
"</script>" + Environment.NewLine;
Page.RegisterStartupScript("Pop", strPop);
Hope this will help u

Reputation Points: 10
Solved Threads: 1
Newbie Poster
sushanth is offline Offline
6 posts
since Dec 2006
Dec 14th, 2006
0

Re: Opening a .pdf file at the clientside without the open/save dialog box

I think that all depends on the client's browser.
Reputation Points: 45
Solved Threads: 28
Posting Whiz in Training
Dukane is offline Offline
282 posts
since Oct 2006
Dec 16th, 2006
0

Re: Opening a .pdf file at the clientside without the open/save dialog box

dude

i think the best thing is using javascript to open the pdf

try this:

<INPUT id="btnopen" type="button" value="open report" name="Button1" onclick="location.href='linux1-sample.pdf'">

sam
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
web_developer is offline Offline
84 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Returning Empty Datatable
Next Thread in ASP.NET Forum Timeline: Asp.net+xml+ms Sql





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC