Hello! I'm attempting to build a simple set of reports against a development project that is currently using SQL Reporting 2005, which has some shortcomings I think your product may handily overcome.... if I can only figure out what I'm doing wrong here.
My web app needs to generate PDF reports and display them to the user. Here's the code I'm trying to use against the telerik Reporting. Note that I'm trying to pull the rendered PDF into a byte array and pass that array directly to the context.Response object. (This is very similar to what I do with SSRS, which is working.) Unfortunately, with the telerik report in the code below, when the Adobe Reader opens on the client's system, an error message pops up that reads "there was an error opening this document. The file is damaged and could not be repaired." (This was with Adobe Reader 7.0.8 by the way.)
Note that there's some lines in the code below that are commented out - these are pulling the PDF into a FileStream and writing it to a file - if I try to open the file thus created, it works like a charm!! (same version of the reader.)
I'd like to avoid all that sloppy file writing... any ideas what in the world I'm doing wrong here????
Oh, and thanks for letting us use the beta of what looks to be a fabulous product... I was sold as soon as I realized the codebehind was C# and not some horrible VBA like what SSRS uses!
|JobList report = new JobList();|
|string mimeType = string.Empty;|
|string extension = string.Empty;|
|Encoding encoding = null;|
|byte RenderedRptArr = Telerik.Reporting.Processing.ReportProcessor.Render("PDF", report, null, out mimeType, out extension, out encoding);|
|//FileStream sOut = new FileStream("c:\\dev\\joblist.pdf", FileMode.CreateNew, FileAccess.Write);|
|//sOut.Write(RenderedRptArr, 0, RenderedRptArr.Length);|
|System.Web.HttpContext context = System.Web.HttpContext.Current;|
|string strPath = context.Request.ApplicationPath;|
|Response.AppendHeader("content-disposition", "attachment; filename=JobList.pdf");|
|Response.ContentType = "application/pdf";|