beckybear3
Programmer
I am a new programmer to .NET and I inherited an application that contains an aspx page that retrieves a Word document and streams it to the browser using the Response object (BinaryWrite). In the header, content-disposition is specified as inline and it opens the Word document in the browser with no problems.
I tried to extend this to also do PDF documents. The problem is, when the PDF document is streamed, it opens in a new Acrobat window (not inline, as specified in the content-disposition). Then I am left with a blank browser window that does nothing.
So I'd like to know either how to get the PDF document to display in the current browser window, or how to close the referring browser window once Acrobat is opened. I know that javascript can be used to close the window when attached to something in the user interface (button, link, etc), but I'm not sure how to do it without user intervention.
The aspx page just consists of Page_Load that does the following:
Thanks in advance for your help.
I tried to extend this to also do PDF documents. The problem is, when the PDF document is streamed, it opens in a new Acrobat window (not inline, as specified in the content-disposition). Then I am left with a blank browser window that does nothing.
So I'd like to know either how to get the PDF document to display in the current browser window, or how to close the referring browser window once Acrobat is opened. I know that javascript can be used to close the window when attached to something in the user interface (button, link, etc), but I'm not sure how to do it without user intervention.
The aspx page just consists of Page_Load that does the following:
Code:
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "Application/pdf"
Response.AddHeader("content-disposition", "inline; filename=comments.pdf")
Dim sr As System.IO.StreamReader
Try
<code to get PDF path>
sr = New System.IO.StreamReader(path)
Dim ll As Long = sr.BaseStream.Length
Dim re(ll) As Byte ''
For i As Long = 0 To ll - 1
re(i) = CType(sr.BaseStream.ReadByte(), Byte)
Next
Response.BinaryWrite(re)
Response.End()
Catch ex As Exception
Me.Response.Write(ex.ToString)
Finally
sr.Close()
End Try
Thanks in advance for your help.