Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I improve the performance of the LocalReport.Render method when exporting PDF from .rdlc in code?

I want to render big non-graphical reports (thousands of pages) in the code level, omitting the ReportViewer control that just jams the browser, from the .rdlc files. When I test to render a report that is somewhat 2000 pages, the Microsoft.Reporting.WebForms.LocalReport.Render method takes approximately half an hour to finish, that is considered as bad user experience.

Are there any tricks or alternative solutions to improve the performance of the rendering: in code, re-designing the .rdlc file, or somewhere else, e.g, just increasing hardware?

Example code:

LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/report.rdlc");

SetDataSources(ref localReport);

string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;

string deviceInfo =
"<DeviceInfo>" +
"  <OutputFormat>PDF</OutputFormat>" +
"  <PageWidth>8.5in</PageWidth>" +
"  <PageHeight>11in</PageHeight>" +
"  <MarginTop>0in</MarginTop>" +
"  <MarginLeft>0in</MarginLeft>" +
"  <MarginRight>0in</MarginRight>" +
"  <MarginBottom>0in</MarginBottom>" +
"</DeviceInfo>";
}

Warning[] warnings;
string[] streams;
byte[] renderedBytes;

//Render the report
renderedBytes = localReport.Render(
            reportType,
            deviceInfo,
            out mimeType,
            out encoding,
            out fileNameExtension,
            out streams,
            out warnings);

Any help is much appreciated, thanks in advance!

like image 576
anssi Avatar asked Oct 24 '11 08:10

anssi


1 Answers

Placing <trust legacyCasModel="true" level="Full"/> inside <system.web> tag in web.config did it for me. More details here

like image 119
Máster Avatar answered Sep 20 '22 05:09

Máster