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

5

10

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!

Oversight answered 24/10, 2011 at 8:32 Comment(0)
K
1

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

Keratoplasty answered 4/5, 2018 at 16:35 Comment(0)
D
0

returning datatable as datasource runs much faster than a list of objects

Diatomic answered 12/4, 2013 at 20:3 Comment(0)
S
0

Generating large PDF files requires memory but there is a trick to optimize the memory usage if you need to:

  1. generate the report as separate PDF documents with up to 5-10 pages (using specific PDF libraries like free iTextSharp or PDF File Writer
  2. then merge all these PDF files into one single large PDF document.

This technique is also useful as you control the progress of report generation.

Soteriology answered 10/2, 2015 at 15:2 Comment(0)
L
0

Remove all the expressions in SSRS report. Any conditional formatting , coloring and alternating rows , this should reduce your download time drastically.

Longoria answered 20/4, 2018 at 17:32 Comment(0)
F
0

There is no way to improve the RDLC performance at acceptable speed level after my 5 months investigation. RDLC is created for SIMPLE report such as receipt and invoice. Using html is the best option for acceptable loading and rendering speed if the number of report pages is greater than 100 with no any internal expressions, or greater than 50 pages with dynamic internal expressions.

Fondly answered 15/1, 2021 at 22:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.