I have Telerik Report that have about 700 images on it. When I generate the pdf, I get the following error message:
Here is the code that I uses.
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", tk, null);
FileStream fs = new FileStream("d:\\report1.pdf", FileMode.Create);
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
fs.Flush();
fs.Close();
However, when I display that in the report viewer on the screen, there is no error. Any idea on how to fix this? I have plenty of diskspace in c:/d: drives.
Thanks.
System.OutOfMemoryException was unhandled by user code
Message=Exception of type 'System.OutOfMemoryException' was thrown.
Source=mscorlib
StackTrace:
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at Telerik.Reporting.Pdf.IO.PdfWriter.Write(Byte[] bytes)
at Telerik.Reporting.Pdf.IO.PdfWriter.WriteStream(PdfDictionary value)
at Telerik.Reporting.Pdf.PdfDictionary.WriteDictionaryStream(PdfWriter writer)
at Telerik.Reporting.Pdf.PdfDictionary.WriteObject(PdfWriter writer)
at Telerik.Reporting.Pdf.PdfDocument.Save(Stream stream)
at Telerik.Reporting.ImageRendering.DocumentPdf.EndDocument()
at Telerik.Reporting.Writing.DocumentWriter.Telerik.Reporting.Writing.IWriter.WriteEndDocument()
at Telerik.Reporting.BaseRendering.PageHandler.Telerik.Reporting.Paging.IPageHandler.EndDocument(Boolean output)
at Telerik.Reporting.Paging.PagerBase.AddEndDocument(Boolean output)
at Telerik.Reporting.Paging.PageComposition.PageOverride()
at Telerik.Reporting.Paging.PagerBase.Page(IPageHandler handler, Report report)
at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(Report report, Hashtable renderingInfo, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback)
at Telerik.Reporting.Processing.ReportProcessor.Render(IList`1 reports, ExtensionInfo extensionInfo, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.RenderReportStateless(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo)
at _ViewReport.rdbGo_Click(Object sender, EventArgs e) in d:\SVN\ROVCatalog\Web\ViewReport.aspx.cs:line 89
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
<iframe id="ifPDF" src='@Url.Action("GetHtmlReport", "StandardReports")' class="resultPDF">
public ActionResult GetHtmlReport()
{
byte[] result = null;
string mimeType = "application/pdf";
result = popstreatmernt;
return File(result, mimeType);
}
private void GetReportInfo(StandardReportsListViewModel stdReportsFilters)
{
try
{
RequistionParameters ReqParams = new RequistionParameters();
RequisitionCheckListbase ReqchkParams = new RequisitionCheckListbase();
RequistionChecklistReport reportRequistionChecklist = new RequistionChecklistReport();
reportRequistionChecklist.ReportInput = ReqchkParams;
byte[] pdfbytesReport = GetPdfBytes(reportRequistionChecklist);
popstreatmernt = pdfbytesReport;
}
catch { }
}
public byte[] GetPdfBytes(Report rpt)
{
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
//set any deviceInfo settings if necessary
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
Telerik.Reporting.Processing.RenderingResult result1 = reportProcessor.RenderReport("PDF", rpt, deviceInfo);
byte[] result = result1.DocumentBytes;
return result;
}
DECLARE @Empty TABLE(ROW_NUM INT);DECLARE @iCount INTSET @iCount = 1WHILE @iCount<=10 BEGIN INSERT INTO @Empty VALUES(@iCount) SET @iCount = @iCount + 1 ENDSELECT DETTAGLI.* FROM @Empty RF LEFT OUTER JOIN ( SELECT ROW_NUMBER() OVER (ORDER BY SEQ) AS RIGA, FD.SEQ, UM.CODICE AS UM, FD.PREZZO, FD.QUANTITA, FD.IMPORTO, FD.DESCRIZIONE, I.DESCRIZIONE AS DESC_IVA, I.ALIQUOTA, I.CODICE AS CODICE_IVA FROM vend.T_FATTURE_DETTAGLIO FD INNER JOIN cont.T_ALIQUOTE_IVA I ON I.ID_ALIQUOTA = FD.ALIQUOTA_IVA_ID INNER JOIN magaz.T_ARTICOLI ART ON ART.ID_ARTICOLO = FD.ARTICOLO_ID LEFT OUTER JOIN anag.T_UM UM ON UM.ID_UM = ART.UM_ID WHERE FATTURA_ID = @prmIDFattura ) DETTAGLI ON DETTAGLI.RIGA = RF.ROW_NUM