How could I display Reporting Services report in the opened window ?
This is my code in the Page_Load()
Dim RptParameters(0)As Microsoft.Reporting.WebForms.ReportParameter RptParameters(0) =New Microsoft.Reporting.WebForms.ReportParameter("ProjectId",CStr(Session("CurrentProject"))) ReportViewer1.ServerReport.SetParameters(RptParameters)Dim warningsAs Microsoft.Reporting.WebForms.Warning() =Nothing Dim streamidsAs String() =Nothing Dim mimeTypeAs String =Nothing Dim encodingAs String =Nothing Dim extensionAs String =Nothing Dim DeviceInfoAs String ="<DeviceInfo>" &" <OutputFormat>PDF</OutputFormat>" &" <PageWidth>29.7cm</PageWidth>" &" <PageHeight>21cm</PageHeight>" &" <MarginTop>0.5cm</MarginTop>" &" <MarginLeft>0.5cm</MarginLeft>" &" <MarginRight>0.5cm</MarginRight>" &" <MarginBottom>0.5cm</MarginBottom>" &"</DeviceInfo>"Dim bytesAs Byte() bytes = ReportViewer1.ServerReport.Render("PDF", DeviceInfo, mimeType, encoding, extension, streamids, warnings) Response.Clear() Response.ContentType = mimeType Response.AddHeader("content-disposition","attachment; filename=Project." & extension) Response.BinaryWrite(bytes) Response.End()
With this code I am able to get the report as PDF. However I have 2 issues:
First if I try to open directly the PDF (I press the Open button when prompted) Acrobat Reader opens but complains he cannot find the file. Where is the file coming from and why it cannot be found ?
In order to open the PDF I have to save it first on the local client. Then I am prompted again and I can open the PDF file in Acrobat.
Secondly, I would like to open the PDF directly in the current window and not in he Acrobat window. How to achieve it ?
hi,
i had similar problems with Acrobat Reader. The new version of it (7.0) cannot handle opening pdfs from the web.
So i think the problem is not in the code but in the reader itself.
You could try with another pdf reader like Foxit - http://www.foxitsoftware.com/pdf/rd_intro.php
I have a similar report exporting it my self, and works for me to open it without downloading (however not using Acrobat Reader).
Unfortunately, I don't know either how to display the pdf report directly into the browser. Tried playing a lot with the content-type, but didn't help.
In case you find it feel free to share :)
Cheers,
Yani
No comments:
Post a Comment