Crystal Reports - export to pdf in MVC


Crystal Reports - export to pdf in MVC



I have integrated the below code in my application to generate a 'pdf' file using crystal reports in MVC project. However, after the request is processed, i get to see only 2 pages in the pdf file while my 'data' returns more than 2 records. Also, the pdf isn't rendered as soon as the page is processed but instead i have to refresh atleast once, then the pdf is rendered on 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 from here in SO but modified it like above.

TIA.

EDIT: This works on Firefox, not in IE7.


Trying to read FormsAuthentication tickets to read in other areas of site

1:

Configuration and Views
I finally found the quick fix here on SO. C# and ASP.NET MVC: Using #if directive in a viewIt had nothing to did with MVC although the way IE treats popup window.. How do I get my asp.net MVC application to recognize the stylesheet on the live server?
Store and retrieve html from sql server 2008 and display using ASP.NET MVC?

67 out of 100 based on 42 user ratings 917 reviews

@