Reputation: 1
My report is generated successfully in IIS and now I want to get that report in PDF format. Please guide me - I listed my source below:
protected void Button1_Click(object sender, EventArgs e)
{
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("MR.rpt"));
rpt.SetDatabaseLogon("", "", "RAMYA-BD", "");
rpt.SetParameterValue("MRNO", ddlmrno.SelectedItem.Text);
CrystalReportViewer1.ReportSource = rpt;
Response.ContentType = "application/pdf";
}
Upvotes: 0
Views: 3359
Reputation: 339
If you not have add Viewer:
Stream st = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=\"xxx.pdf\"");
st.CopyStream(Response.OutputStream);
Response.Output.Flush();
Response.End();
Database connection maybe
rep.DataSourceConnections[0].SetLogon("Login","Password");
Upvotes: 1
Reputation:
Go through following Links:
http://www.dotnetspider.com/resources/4946-Create-pdf-from-crystal-report.aspx
http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-export-pdf.htm
or the stack overflow same problem: Converting Crystal report to PDF
Upvotes: 1