Conversion of RPT file to PDF c #

0

Good morning

I have the following file in .rtp and I need to convert / convert the data from this report to pdf .

  

BalanceCompany.rpt

I need this to be done through a click event.

    
asked by anonymous 14.06.2017 / 16:36

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:

    
14.06.2017 / 17:05