vivek
vivek

Reputation: 1

convert crystal reports into pdf formats

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

Answers (2)

Rafal T
Rafal T

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

Related Questions