Re: Stream pdf to browser
- From: "Rick" <rfemmer@xxxxxxxxxxxxxxxxx>
- Date: Wed, 9 May 2007 08:12:06 -0500
That's what I did the page comes up with no problem the call to the
webservice works, but the file does not show in the browser, if I put a
button on the page that does the same exact call to the web service it works
fine.
Page 1 calls page dedicated to call to web service:
Button2.Attributes.Add("onclick", "window.open('webform2.aspx?f=" &
txtFile.Text & "','mywindow')")
Page2 calls web service and flush to browser:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
getfile()
End If
End Sub
Private Sub getfile()
Dim ffile As FileInfo
Dim ws As webservice
Dim sFile As String = Request.QueryString("f")
Try
ws = New webservice
ws.Credentials = getcredentials
Dim Buffer() As Byte = ws.GetFileBuffer(sFile)
Response.BufferOutput = True
Response.ClearContent()
Response.ClearHeaders()
Response.AddHeader("Content-Length", Buffer.Length.ToString)
Response.AddHeader("content-disposition", "inline;filename=YourReport.pdf")
Response.ContentType = "application/pdf"
Response.BinaryWrite(Buffer)
Response.Flush()
Response.Clear()
Catch ex As Exception
Finally
ffile = Nothing
nref = Nothing
End Try
End Sub
"Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:y1M4Q$ekHHA.1144@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Rick,
From your description, you're using webservice to expose some PDF stream
from backend file or database and stream them to web application(let web
application flush the pdf content to client). currently you're wondering
how to make the web application display the pdf stream download in a
separate browser window from the main window(which trigger the postback)
,correct?
Based on my experience, a typical approach to do this is a below:
1. You should create a separate page which dedicate to retrieving binary
content from the webservice(that return pdf buffer) and stream it out to
web page response). This page will use some url querystring as parameter
to
identify which pdf file to retrieve from webservice.
2. In your main web page, when you click a button and postback to retrieve
pdf stream, you just simply register some client-side script that will
open
a new browser window, the url is just the dedicated page created in #1 and
append some url querystring (indicate which pdf file to open).
How do you think?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
.
- Follow-Ups:
- Re: Stream pdf to browser
- From: Steven Cheng[MSFT]
- Re: Stream pdf to browser
- References:
- Stream pdf to browser
- From: Rick
- RE: Stream pdf to browser
- From: Steven Cheng[MSFT]
- Stream pdf to browser
- Prev by Date: Re: Authentication issue
- Next by Date: Re: Authentication issue
- Previous by thread: RE: Stream pdf to browser
- Next by thread: Re: Stream pdf to browser
- Index(es):