从 Crystal 报告查看器中的每个页面获取内容并将其导出为 pdf

Get contents from each page in Crystal Report viewer and export it to a pdf

我需要获取 crystal 报告查看器每个页面内的内容并将其导出到 pdf 文件,以便每个页面都成为一个单独的 pdf 并需要将它们压缩。 现在我使用 DotNetZip dll this.That 没问题。

问题是我需要获取每个 page.Please 帮助的内容..下面是几行代码

Response.ContentType = "application/zip";
Response.AppendHeader("content-disposition", "attachment; filename=Reports.zip");
int i = 1;
int PageCount = report.FormatEngine.GetLastPageNumber(new 
                                    CrystalDecisions.Shared.ReportPageRequestContext());
if(PageCount >= 1){
     using (ZipFile zip = new ZipFile())
     {
        for (i = 1; i <= PageCount; i++){
             var re = report.ExportToStream(ExportFormatType.PortableDocFormat);
             string Name = "Page" + i + ".pdf";
             zip.AddEntry(Name, re);
             
        }
        zip.Save(Response.OutputStream);
     }
}

终于找到答案了!!..可能对以后的人有帮助。

Response.ContentType = "application/zip";
Response.AppendHeader("content-disposition", "attachment; filename=Reports.zip");
int PageCount = report.FormatEngine.GetLastPageNumber(new 
                                      CrystalDecisions.Shared.ReportPageRequestContext());
if (PageCount >= 1)
{
    using (ZipFile zip = new ZipFile())
        {
           for (int i = 1; i <= PageCount; i++)
               {
                   PdfRtfWordFormatOptions pdfRtfWordOpts = ExportOptions.CreatePdfRtfWordFormatOptions();
                   DiskFileDestinationOptions destinationOpts = ExportOptions.CreateDiskFileDestinationOptions();
                   ExportRequestContext req = new ExportRequestContext();
                   pdfRtfWordOpts.FirstPageNumber = i;
                   pdfRtfWordOpts.LastPageNumber = i;
                   pdfRtfWordOpts.UsePageRange = true;
                   ExportOptions CrExportOptions = report.ExportOptions;
                   {
                       CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                       CrExportOptions.FormatOptions = pdfRtfWordOpts;
                       req.ExportInfo = CrExportOptions;
                   }
                   Stream s = report.FormatEngine.ExportToStream(req);
                   string Name = "Page" + i + ".pdf";
                   zip.AddEntry(Name, s);
               }
               zip.Save(Response.OutputStream);
        }
}