作成日: 2026/03/25 最終更新日: 2026/03/25
文書種別
使用方法
詳細
本文書では、PDFエクスポートの実行に必要となる最小限の手順を紹介します。
プロパティの設定など、より詳しい方法はヘルプをご確認ください。
-
NuGetパッケージをインストールする
NuGetパッケージマネージャーを使用してプロジェクトに以下のパッケージをインストールします。
MESCIUS.ActiveReports.Export.Pdf.ja
-
コードを記述する
アプリケーションの実行ディレクトリにPDFを出力する場合、以下のようなコードになります。
◆サンプルコード (C#)
// ページレポート/RDLレポート var fi = new System.IO.FileInfo("PageReport1.rdlx"); var pageReport = new GrapeCity.ActiveReports.PageReport(fi); var renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension(); var outputDirectory = new System.IO.DirectoryInfo(Application.StartupPath); var provider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, "sample.pdf"); provider.OverwriteOutputFile = true; var settings = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings(); pageReport.Document.Render(renderingExtension, provider, settings); // セクションレポート(コード形式) var sectionReport = new SectionReport1(); sectionReport.Run(); var pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport(); pdfExport.Export(sectionReport.Document, "sample.pdf"); // セクションレポート(XML形式) var xtr = new System.Xml.XmlTextReader("SectionReport1.rpx"); var sectionReport = new GrapeCity.ActiveReports.SectionReport(); sectionReport.LoadLayout(xtr); xtr.Close(); sectionReport.Run(); var pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport(); pdfExport.Export(sectionReport.Document, "sample.pdf");◆サンプルコード (VB.NET)
' ページレポート/RDLレポート Dim fi As New System.IO.FileInfo("PageReport1.rdlx") Dim pageReport As New GrapeCity.ActiveReports.PageReport(fi) Dim renderingExtension As New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension() Dim outputDirectory As New System.IO.DirectoryInfo(Application.StartupPath) Dim provider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, "sample.pdf") provider.OverwriteOutputFile = True Dim settings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings() pageReport.Document.Render(renderingExtension, provider, settings) ' セクションレポート(コード形式) Dim sectionReport As New SectionReport1() sectionReport.Run() Dim pdfExport As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport() pdfExport.Export(sectionReport.Document, "sample.pdf") ' セクションレポート(XML形式) Dim xtr As New System.Xml.XmlTextReader("SectionReport1.rpx") Dim sectionReport As New GrapeCity.ActiveReports.SectionReport() sectionReport.LoadLayout(xtr) xtr.Close() sectionReport.Run() Dim pdfExport As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport() pdfExport.Export(sectionReport.Document, "sample.pdf")※上記のコードはファイル(rdlx/rpx)が実行ディレクトリの直下に存在することを前提にしています。