How to export rdlc report to PDF without using ReportViewer
-
is it possible to export report directly into pdf file?
try
{
stmtDataSetTableAdapters.IOB_StmtTableAdapter ds = new stmtDataSetTableAdapters.IOB_StmtTableAdapter();
// Create Report DataSource
ReportDataSource rds = new ReportDataSource("IOB_Stmt");// Variables Warning\[\] warnings; string\[\] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; // Setup the report viewer object and get the array of bytes ReportViewer viewer = new ReportViewer(); viewer.ProcessingMode = ProcessingMode.Remote; viewer.LocalReport.ReportPath = "~/Report.rdlc"; viewer.LocalReport.DataSources.Add(rds); // Add datasource here ** byte\[\] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);**//Error Occured // Now that you have all the bytes representing the PDF report, buffer it and send it to the client. Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension); Response.BinaryWrite(bytes); // create the file Response.Flush(); // send it to the client to download } catch (Exception ex) { Response.Write(ex.ToString()); }
error on bold line An error occurred during local report processing. Please give the solution. thanks
-
is it possible to export report directly into pdf file?
try
{
stmtDataSetTableAdapters.IOB_StmtTableAdapter ds = new stmtDataSetTableAdapters.IOB_StmtTableAdapter();
// Create Report DataSource
ReportDataSource rds = new ReportDataSource("IOB_Stmt");// Variables Warning\[\] warnings; string\[\] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; // Setup the report viewer object and get the array of bytes ReportViewer viewer = new ReportViewer(); viewer.ProcessingMode = ProcessingMode.Remote; viewer.LocalReport.ReportPath = "~/Report.rdlc"; viewer.LocalReport.DataSources.Add(rds); // Add datasource here ** byte\[\] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);**//Error Occured // Now that you have all the bytes representing the PDF report, buffer it and send it to the client. Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension); Response.BinaryWrite(bytes); // create the file Response.Flush(); // send it to the client to download } catch (Exception ex) { Response.Write(ex.ToString()); }
error on bold line An error occurred during local report processing. Please give the solution. thanks
Yes, It is possible to export report directly into pdf file.