RPT file conversion to PDF c#

Asked

Viewed 251 times

0

Good morning

I have the following file on .rtp and, I need to convert/transform the data in that report to pdf.

Saldoestoqueempresa.rpt

I need it done through a click event.

1 answer

1

If the report you want in pdf will be generated in rpt, then you need to create the report before turning it into pdf, something like this:

public void GerarRelatorio(){
        Warning[] warnings;
        string[] streamIds;
        string mimeType = string.Empty;
        string encoding = string.Empty;
        string extension = string.Empty;
        string HIJRA_TODAY = "01/10/1435";
        ReportParameter[] param = new ReportParameter[3];
        param[0] = new ReportParameter("CUSTOMER_NUM", CUSTOMER_NUMTBX.Text);
        param[1] = new ReportParameter("REF_CD", REF_CDTB.Text);
        param[2] = new ReportParameter("HIJRA_TODAY", HIJRA_TODAY);

        byte[] bytes = ReportViewer1.LocalReport.Render(
            "PDF", 
            null, 
            out mimeType, 
            out encoding, 
            out extension, 
            out streamIds, 
            out warnings);

        Response.Buffer = true;
        Response.Clear();
        Response.ContentType = mimeType;
        Response.AddHeader(
            "content-disposition", 
            "attachment; filename= filename" + "." + extension);
        Response.OutputStream.Write(bytes, 0, bytes.Length); // create the file  
        Response.Flush(); // send it to the client to download  
        Response.End();
}

Here is a post with a question similar to yours: https://stackoverflow.com/questions/2684221/creating-a-pdf-from-a-rdlc-report-in-the-background

  • Actually I want to generate this report . rpt to . pdf

Browser other questions tagged

You are not signed in. Login or sign up in order to post.