Wednesday, 7 August 2013

Export a pdf using FastReport.net and asp.net

Export a pdf using FastReport.net and asp.net

How is it possible to export a pdf using FastReport.net and asp.net? I
would like to export the File in a Controller. I tried it this way
supported on the FastReport Website:
public FileResult GetFile()
{
WebReport webReport = new WebReport();
// bind data
System.Data.DataSet dataSet = new System.Data.DataSet();
dataSet.ReadXml(report_path + "nwind.xml");
webReport.Report.RegisterData(dataSet, "NorthWind");
// load report
webReport.ReportFile =
this.Server.MapPath("~/App_Data/report.frx");
// prepare report
webReport.Report.Prepare();
// save file in stream
Stream stream = new MemoryStream();
webReport.Report.Export(new PDFExport(), stream);
stream.Position = 0;
// return stream in browser
return File(stream, "application/zip", "report.pdf");
}
but then the size of the pdf is always 0 bytes.
Does someone know a solution to my problem?

No comments:

Post a Comment