12-17-2009, 10:55 AM
|
Slachkey
Joined on 04-24-2008
Posts 2
|
(Solved) PDF Export not working in new window; works fine in existing window
|
|
|
|
|
Found Solution:
Solution: Comment out this line or
set line = Response.Cache.SetCacheability(HttpCacheability.Public);
(I commented out the line)
I found the solution by digging through a bunch of old threads. I'll leave this up in case anyone else runs into the same problem.
Hi all,
We're using the PDF export to display reports in a web browser. It works fine if we use response.redirect and show the report in the existing window, however we really need it to pop open in a new window. When we switch out the response.redirect for window.open we aren't seeing ANYTHING in the popup window. I can step through the code and see that everything is working as intended we are just not getting the report to show.
Here is the calling code:
*****************************
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Print Agreement", "window.open('../Reports/ReportViewer.aspx?p1=" & _
Me.Encrypt(agreeRec.AgreementNbr) & "&p2=" & Me.Encrypt(agreeRec.ReportFilename) & "');", True)
*****************************
Here is the report code we are using:
*****************************
crptAgrmt.DataSource = tblReportData
crptAgrmt.Run()
' Buffer this pages output until the PDF is complete.
Response.Buffer = True
'I think that this is already set by default.
' Clear any part of this page that might have already been buffered for output.
Response.ClearContent()
' Clear any headers that might have already been buffered (such as the content type for an HTML page)
Response.ClearHeaders()
Response.Cache.SetCacheability(HttpCacheability.NoCache)
' Tell the browser this is a PDF document so it will use an appropriate viewer.
Response.ContentType = "application/pdf"
' Create the PDF export object
Dim pdfAgreement As New DataDynamics.ActiveReports.Export.Pdf.PdfExport
' Create a new memory stream that will hold the pdf output
Dim memStream As New System.IO.MemoryStream()
' Export the report to PDF:
pdfAgreement.Export(crptAgrmt.Document, memStream)
' Write the PDF stream out
Response.BinaryWrite(memStream.ToArray())
' Send all buffered content to the client
Response.[End]()
Server.ScriptTimeout = 30
*****************************
Again this works fine if we call this with response.redirect and let the report open in the same page, but calling window.open doesn't display anything.
Any help is greatly appreciated!
|
|
|
|
|
Report
|
|
|
|