Skip to main content

Posts

Showing posts with the label crystal report pdf

Code to export crystal report to pdf directly

Code to export crystal report to pdf directly //Declare Reportdocument Object ReportDocument rpt=new ReportDocument(); //set a ReportPath and assign the dataset to reportdocument object rpt.Load(Server.MapPath("Report1.rpt")); rpt.SetDataSource(ds); //assign the values to crystal report viewer CrystalReportViewer1.ReportSource = rpt; CrystalReportViewer1.DataBind(); //Exporting PDF MemoryStream oStream; // using System.IO oStream = (MemoryStream) rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.BinaryWrite(oStream.ToArray()); Response.End();