简体   繁体   中英

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";
}

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM