Crystal Reports - export to pdf in MVC

I have included the code below in my application to create a "pdf" file using crystal reports in an MVC project. However, after processing the request, I see only 2 pages in the pdf file, and my data returns more than 2 records. In addition, the PDF file does not appear as soon as the page is processed, but instead I have to update it at least once, then the pdf is displayed in the browser.

using CrystalDecisions.CrystalReports.Engine; public FileStreamResult Report() { ReportClass rptH = new ReportClass(); List<sampledataset> data = objdb.getdataset(); rptH.FileName = Server.MapPath("[reportName].rpt"); rptH.Load(); rptH.SetDatabaseLogon("un", "pwd", "server", "db"); rptH.SetDataSource(data); Stream stream = rptH.ExportToStream (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, System.IO.SeekOrigin.Begin); return new FileStreamResult(stream, "application/pdf"); } 

I took the code here in SO, but changed it as above.

TIA.

EDIT . This works in Firefox, not in IE7.

+4
source share
1 answer

Finally, I found a solution here . This had nothing to do with MVC, but the way IE handles the popup.

+2
source

Source: https://habr.com/ru/post/1309339/


All Articles