How to Export Crystal Report to PDF format in asp.net.
We have already learned in older post how to create and bind crystal reports in asp.net.
Create and bind crystal reports in asp.net
Design a asp.net web form with crystalreportviewer along with a Button.
write below code on Button for export crystal reports to PDF in asp.net.
protected void Button1_Click(object sender, EventArgs e)
{
DataSet1.STUDENT_SELECTDataTable StuDT = new DataSet1.STUDENT_SELECTDataTable();
DataSet1TableAdapters.STUDENT_SELECTTableAdapter StuAdapter = new DataSet1TableAdapters.STUDENT_SELECTTableAdapter();StuDT = StuAdapter.Select();
ReportDocument rept = new ReportDocument();rept.Load(Server.MapPath(“~/CrystalReport.rpt”));
rept.SetDataSource((DataTable)StuDT);
CrystalReportViewer1.ReportSource = rept;rept.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @”E:\Meera.pdf”);
}