作成日: 2026/03/25 最終更新日: 2026/03/25
文書種別
使用方法
詳細
ページレポート/RDLレポートの場合
用紙サイズや向きの異なるレポートを結合することはできません。
代替案としては、PDFにエクスポートしてから結合する方法が考えられます。
先に出力したPDFのファイルパスをDocumentToAddAfterReport/DocumentToAddBeforeReportプロパティに設定すると、複数のレポートを結合したPDFを出力できます。
◆サンプルコード
var rptA3 = new PageReport(new FileInfo(Application.StartupPath + @"PageReport_A3.rdlx"));
var rptA4 = new PageReport(new FileInfo(Application.StartupPath + @"PageReport_A4.rdlx"));
// A3をPDFにエクスポート
var pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
var outputDirectory = new System.IO.DirectoryInfo(Application.StartupPath);
var outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, "A3");
outputProvider.OverwriteOutputFile = true;
var pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
rptA3.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);
// A4をPDFにエクスポートするときにA3のPDFと結合
outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, "A4");
pdfSetting.DocumentToAddAfterReport = outputDirectory.FullName + @"A3.pdf";
pdfSetting.DocumentToAddBeforeReport = outputDirectory.FullName + @"A3.pdf";
rptA4.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);
なお、ページレポートの場合は、ページ単位で用紙サイズを設定することができます。
製品ヘルプの「ページのサイズ、余白、向きの設定(ページレポート)」をご参照ください。
ただし、この方法で用紙サイズを設定しても、ページ単位で異なる用紙サイズに印刷することはできません。この方法は、印刷せずにビューワに表示するのみである場合や、PDFにエクスポートする場合に有効な方法です。
セクションレポートの場合
用紙サイズや向きの異なるレポートをページ単位で結合することができます。
◆サンプルコード
var rptA3 = new SectionReport_A3();
var rptA4 = new SectionReport_A4();
rptA3.Run();
rptA4.Run();
// A4の前にA3を1ページだけ挿入する場合
rptA4.Document.Pages.Insert(0, rptA3.Document.Pages[0]);
// A4の後にA3の全ページを追加する場合
rptA4.Document.Pages.AddRange(rptA3.Document.Pages);
// PDFにエクスポート
var pdf = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
pdf.Export(rptA4.Document, "SectionReport.pdf");
ただし、この方法でレポートを結合しても、ページ単位で異なる用紙サイズに印刷することはできません。この方法は、印刷せずにビューワに表示するのみである場合や、PDFにエクスポートする場合に有効な方法です。