简体   繁体   中英

report viewer control exporting content to pdf

I am creating asp.net net app for a client and he likes to have reports on his page so i have on the page rdlc file and im using default asp.net report viewer control to present this file on the page...everything is ok except when the client wants to save the file as pdf the structure of the page changes and it doesnt look the same also i have notice that some of the values in fields are empty but they appear on the page and when im saving the same report in Word(*.doc) format also the word file is like it should be...the problem is only with the pdf. Any suggestions are welcome

The problem was due to the Margins settings in the Report Properties if you are having the same problem set the Margins settings (Left,Right,Top,Bottom) to 0in. And your problem is solve.

Try out this code.... it will help to displayy ur data in pdf format

    protected void submit_Click(object sender, EventArgs e)
    {
        bindReportData();  
        try
        {
            // Export the Report to Response stream in PDF format and file name Customers

            abc_reportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ABC");
            // There are other format options available such as Word, Excel, CVS, and HTML in the ExportFormatType Enum given by crystal reports
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            ex = null;
        }
    }



    private void bindReportData()
    {
        abc_reportDocument = new ReportDocument();
        dsReport = new DataSet();
        dsReport = getAccumulationData();
        if (dsReport.Tables[0].Rows.Count > 0)
        {
            abc_reportDocument.Load(this.MapPath("report1.rpt"));
            abc_reportDocument.Database.Tables[0].SetDataSource(dsReport.Tables[0]);
            rptviewerAccumulation.ReportSource = abc_reportDocument;
            rptviewerAccumulation.DataBind();


        }

}

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