简体   繁体   English

Crystal Reports ASP.NET 将 PDF 导出为多页

[英]Crystal Reports ASP.NET Export PDF as Multiple Pages

I use CR to export PDF file according to parameters I send from my ASP.NET Web Forms application.我使用 CR 导出 PDF 文件,根据我从 ASP.NET Web Z6450242Z68531912328A863 应用程序发送的参数In the current situation, I can export one page PDF but I want to add more pages with different info.在当前情况下,我可以导出一页 PDF 但我想添加更多具有不同信息的页面。
Current situation: When I export PDF from my ASP.NET app当前情况:当我从我的 ASP.NET 应用程序中导出 PDF
What I try to achieve: Different Pages with different information but same format我试图实现的目标:具有不同信息但格式相同的不同页面

In summary, I am trying to add pages in the for loop, is that possible to add different pages in the same format?总之,我正在尝试在 for 循环中添加页面,是否可以以相同的格式添加不同的页面?

My CR report: CR report我的 CR 报告: CR 报告

My code in ASP.NET Web Forms application: (dt datatable in the code is actually have more rows but I couldn't find how to show each record in seperate page in the example above)我在 ASP.NET Web Forms 应用程序中的代码:(代码中的 dt 数据表实际上有更多行,但我找不到如何在上面的示例中显示每个记录)

ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load(Server.MapPath(@"Report\MyReportFile.rpt"));


        DataTable dt = new DataTable();
        dt = new DummyDL().PROCEDURE_GET_DUMMY_DATA(DUMMY_NO);


        reportDocument.SetParameterValue("P_DUMMY", DUMMY);
        reportDocument.SetParameterValue("P_DUMMY1", Convert.ToString(dt.Rows[0]["DUMMY1"]));
        reportDocument.SetParameterValue("P_DUMMY2", Convert.ToString(dt.Rows[0]["DUMMY2"]));
        reportDocument.SetParameterValue("P_DUMMY3", Convert.ToString(dt.Rows[0]["DUMMY3"]));


        PrintOptions printOptions = reportDocument.PrintOptions;


        ExportOptions exportOpts = new ExportOptions();
        PdfFormatOptions pdfOpts = ExportOptions.CreatePdfFormatOptions();

        exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
        exportOpts.ExportFormatOptions = pdfOpts;
        
        reportDocument.ExportToHttpResponse(exportOpts, Response,false, "");

        if (!IsPostBack) CrystalReportViewer1.Error += new ErrorEventHandler(CrystalReportViewer1_Error);
        CrystalReportViewer1.ReportSource = reportDocument;
        CrystalReportViewer1.DataBind();

Simply add the data for the other pages to the data source.只需将其他页面的数据添加到数据源。

For example, if you are limiting the data to one order by passing a parameter of OrderID and applying a record selection based on that parameter, change the parameter to allow multiple values.例如,如果您通过传递 OrderID 参数并应用基于该参数的记录选择来将数据限制为一个订单,请更改该参数以允许多个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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