文檔首頁>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】將多個(gè)文件導(dǎo)出為一個(gè)大PDF
【Stimulsoft Reports.WinForms教程】將多個(gè)文件導(dǎo)出為一個(gè)大PDF
【下載Stimulsoft Reports.Ultimate最新版本】
此示例項(xiàng)目演示了如何將許多不同的報(bào)表導(dǎo)出到一個(gè)大的PDF文件,并創(chuàng)建包含大量報(bào)表副本的PDF文件。例如,創(chuàng)建一個(gè)呈現(xiàn)的報(bào)表,并在輸出PDF文件中添加1000次。創(chuàng)建新的報(bào)表對象并啟用必要的選項(xiàng):
private void buttonExportClick(object sender, EventArgs e) { var report = new StiReport(); report.ReportCacheMode = StiReportCacheMode.On; report.RenderedPages.CanUseCacheMode = true; report.RenderedPages.CacheMode = true; report.RenderedPages.Clear(); ...
然后,將渲染的報(bào)表添加1000次:
... var tempReport = new StiReport(); for (int index = 0; index < 1000; index++) { using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( "ExportManyFilesToOneBigPDF.MasterDetail.mdc")) { tempReport.LoadDocument(stream); } tempReport.ReportUnit = report.ReportUnit; foreach (StiPage page in tempReport.RenderedPages) { page.Report = tempReport; page.Guid = System.Guid.NewGuid().ToString().Replace("-", ""); report.RenderedPages.Add(page); } } ...
最后,導(dǎo)出報(bào)表:
... report.ExportDocument(StiExportFormat.Pdf, "d:\\1.pdf"); }
示例代碼的結(jié)果如下圖所示: