フッターコンテンツにスキップ
ビデオ

How to Convert Razor to PDF in Blazor Server Using C#

FastReport.NETは、.NETエコシステムのために構築された強力なレポートソリューションで、複雑なデータ駆動型レポートを作成するためのビジュアルレポートデザイナーとバンドベースのアーキテクチャを特徴としています。 しかし、FastReportは、コードファースト開発を制限するレポートデザイナーの依存性、バンドベースの概念(DataBand、PageHeaderBand)についての急な学習曲線、独自の書式を使用する限られたCSSサポート、RegisterData()ボイラープレートによる複雑なデータバインディング、複数のインストールを必要とする断片化されたNuGetパッケージなど、最新のPDF生成ワークフローにとって重要な課題を提示しています。 この包括的なガイドでは、FastReportからIronPDFへのステップバイステップの移行パスを提供します。IronPDFは、柔軟でプログラム的なドキュメント生成のためにHTML/CSSウェブ技術を活用する汎用PDFライブラリです。

なぜFastReportからIronPDFに移行するのですか?

FastReport.NETのレポーティングへの特化は、多用途のPDF生成を必要とする開発チームに摩擦を生じさせます。 これらのアーキテクチャの違いを理解することは、移行を計画する上で不可欠です。

FastReportの課題

1.レポート デザイナーの依存性:複雑なレイアウトを作成するには、ビジュアル デザイナーまたは .frx ファイル構造に関する深い知識が必要であり、コードファースト開発アプローチには適していません。

2.学習曲線が急:FastReportのバンドベースのアーキテクチャ (DataBand、PageHeaderBand、PageFooterBand) では、他のテクノロジには適用できないレポート固有の概念を理解する必要があります。

  1. CSS サポートが制限されている: Web 標準のスタイルはネイティブではサポートされていません。 スタイリングは、使い慣れたCSSではなく、FastReport独自のフォーマットで行います。

4.複雑なデータ バインディング: RegisterData() および DataSource 接続により、単純な PDF 生成シナリオ用の定型句が追加されます。

5.断片化されたパッケージ:完全な機能を利用するには複数のNuGetパッケージが必要です (FastReport.OpenSource、FastReport.OpenSource.Export.PdfSimple など)。 PDFSimpleExport を使用したOpenSource版ではページがラスタライザされ、出力されたPDFには選択可能なテキストではなく、テキストの画像が含まれます。

  1. ライセンスの複雑さ: OpenSource版(MIT)は、PDFSimpleExport を介して画像ベースのPDFフォールバックを提供します。 選択可能なテキストPDFのエクスポート、暗号化、デジタル署名、PDF/Aは、FastReportのプライベートNuGetフィード(https://nuget.fast-report.com/api/v3/index.json)に公開されている商用 FastReport.Net パッケージが必要です(nuget.orgにはありません)。 nuget.orgにあるのは、FastReport.Net.Demo(ページ制限、透かし付き)だけです。

アーキテクチャの比較

アスペクト FastReport IronPDF
デザインアプローチ ビジュアルデザイナー + .frx ファイル HTML/CSS(ウェブ技術)
ラーニングカーブ スティープ(バンドベースのコンセプト) ジェントル(HTML/CSSの知識)
データバインディング RegisterData(), DataBand 文字列補間、Razor、テンプレート化
CSSサポート 制限的 フルCSS3とFlexbox/Grid
パッケージモデル 複数のパッケージ 単一パッケージ(全機能)
レンダリングエンジン カスタムレポートエンジン;OpenSource PDFエクスポートはラスタライズします。 埋め込まれたChromium
PDF操作 輸出向け フル(マージ、分割、セキュリティ、フォーム)
モダン.NET .NET Framework 4.6.2+ / .NET 6+ .NET Framework 4.6.2+ / .NET 6/7/8/9+

主な移行のメリット

  1. Webテクノロジー:独自のバンドベースのレイアウトではなく、使い慣れたHTML/CSSを使用する 2.コードファースト開発:ビジュアルデザイナーに依存せずにプログラムでPDFを生成する 3.単一パッケージ: 1つのNuGetパッケージにすべてのPDF機能が含まれています 4.モダンレンダリング:ピクセルパーフェクトなCSS3出力を実現する最新のChromiumエンジン
  2. PDFの完全な操作:エクスポートだけでなく、結合、分割、セキュリティ、フォームなど

移行前の準備

前提条件

あなたの環境がこれらの要件を満たしていることを確認してください:

  • .NET Framework 4.6.2+または.NET Core 3.1 / .NET 5-9
  • Visual Studio 2019+またはC#拡張機能付きVS Code
  • NuGetパッケージマネージャへのアクセス
  • IronPDFライセンスキー (ironpdf.com にて無料トライアル可能)

FastReportの使用法を監査する

ソリューションディレクトリでこれらのコマンドを実行し、すべてのFastReport参照を識別します:

# Find allFastReportreferences
grep -r "FastReport\|\.frx\|PDFExport\|PDFSimpleExport\|DataBand\|RegisterData" --include="*.cs" --include="*.csproj" .

# Check NuGet packages
dotnet list package | grep FastReport
# Find allFastReportreferences
grep -r "FastReport\|\.frx\|PDFExport\|PDFSimpleExport\|DataBand\|RegisterData" --include="*.cs" --include="*.csproj" .

# Check NuGet packages
dotnet list package | grep FastReport
SHELL

レポートテンプレートの文書化

移行前に、すべての .frx ファイルとその目的をカタログ化してください。

  • レポート名と目的
  • 使用データソース
  • ヘッダー/フッターの設定
  • ページ番号の要件
  • 特殊なフォーマットやスタイル

パラダイムシフトを理解する

FastReportからIronPDFへの移行で最も大きな変更は、基本的な設計アプローチです。 FastReportは、.frx テンプレートファイルやDataBand、PageHeaderBand、RegisterData()のような独自の概念を持つバンドベースのビジュアルデザインを使用します。 IronPDFはほとんどの開発者がすでに知っているHTML/CSS-ウェブ技術を使用しています。

これは、FastReportバンド構成をHTMLテンプレートに変換すること、RegisterData()を文字列補間またはRazorテンプレートを介した直接データバインディングに置き換えること、PageHeaderBand/PageFooterBandをHTMLベースのヘッダーとフッターに変換することを意味します。

ステップごとの移行プロセス

ステップ 1: NuGet パッケージを更新する

すべてのFastReportパッケージを削除し、IronPDFをインストールしてください:

# Remove allFastReportpackages
dotnet remove package FastReport.OpenSource
dotnet remove package FastReport.OpenSource.Export.PdfSimple
dotnet remove package FastReport.OpenSource.Web
dotnet remove package FastReport.OpenSource.Data.MsSql

# InstallIronPDF(includes all features)
dotnet add package IronPdf
# Remove allFastReportpackages
dotnet remove package FastReport.OpenSource
dotnet remove package FastReport.OpenSource.Export.PdfSimple
dotnet remove package FastReport.OpenSource.Web
dotnet remove package FastReport.OpenSource.Data.MsSql

# InstallIronPDF(includes all features)
dotnet add package IronPdf
SHELL

ステップ 2: 名前空間参照の更新

FastReportの名前空間をIronPDFに置き換えてください:

// Remove these
using FastReport;
using FastReport.Export.PdfSimple;
using System.IO;

// Add this
using IronPdf;
// Remove these
using FastReport;
using FastReport.Export.PdfSimple;
using System.IO;

// Add this
using IronPdf;
Imports IronPdf
$vbLabelText   $csharpLabel

ステップ 3: ライセンスの設定

// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

完全な API 移行のリファレンス

コア クラス マッピング

FastReport クラス IronPDF 同等物
Report ChromePdfRenderer
PDFExport ChromePdfRenderer + SecuritySettings
PDFSimpleExport ChromePdfRenderer
ReportPage HTML <body> または <div>
TextObject HTML <p>, <span>, <div>
HTMLObject 直接HTMLレンダリング
PageHeaderBand HtmlHeaderFooter
PageFooterBand HtmlHeaderFooter

メソッドマッピング

FastReport メソッド IronPDF 同等物
report.Load("template.frx") HTMLテンプレートファイルまたは文字列
report.RegisterData(data, "name") 文字列補間またはRazor
report.Prepare() 該当なし
report.Export(export, stream) pdf.SaveAs(path)

ページ番号プレースホルダーの変換

FastReportとIronPDFはページ番号に異なるプレースホルダー構文を使用します:

FastReport IronPDF
[Page] {page}
[TotalPages] {total-pages}

コード移行の例

HTMLからPDFへの変換

この例はFastReportのHTMLObjectアプローチとIronPDFのダイレクトレンダリングの基本的な違いを示しています。

FastReportの実装:

// NuGet: Install-Package FastReport.OpenSource
//        Install-Package FastReport.OpenSource.Export.PdfSimple
using FastReport;
using FastReport.Export.PdfSimple;
using System.Drawing;
using System.IO;

class Program
{
    static void Main()
    {
        using (Report report = new Report())
        {
            //FastReportrenders nothing unless objects live on a band that lives on a ReportPage.
            ReportPage page = new ReportPage();
            report.Pages.Add(page);
            page.ReportTitle = new ReportTitleBand { Height = Units.Millimeters * 100 };

            // Create HTML object (FastReport class is HtmlObject)
            HtmlObject htmlObject = new HtmlObject();
            htmlObject.Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 100);
            htmlObject.Text = "<html><body><h1>Hello World</h1><p>This is a test PDF</p></body></html>";
            page.ReportTitle.Objects.Add(htmlObject);

            report.Prepare();

            // PDFSimpleExport rasterizes each page — text is not selectable
            PDFSimpleExport pdfExport = new PDFSimpleExport();
            using (FileStream fs = new FileStream("output.pdf", FileMode.Create))
            {
                report.Export(pdfExport, fs);
            }
        }
    }
}
// NuGet: Install-Package FastReport.OpenSource
//        Install-Package FastReport.OpenSource.Export.PdfSimple
using FastReport;
using FastReport.Export.PdfSimple;
using System.Drawing;
using System.IO;

class Program
{
    static void Main()
    {
        using (Report report = new Report())
        {
            //FastReportrenders nothing unless objects live on a band that lives on a ReportPage.
            ReportPage page = new ReportPage();
            report.Pages.Add(page);
            page.ReportTitle = new ReportTitleBand { Height = Units.Millimeters * 100 };

            // Create HTML object (FastReport class is HtmlObject)
            HtmlObject htmlObject = new HtmlObject();
            htmlObject.Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 100);
            htmlObject.Text = "<html><body><h1>Hello World</h1><p>This is a test PDF</p></body></html>";
            page.ReportTitle.Objects.Add(htmlObject);

            report.Prepare();

            // PDFSimpleExport rasterizes each page — text is not selectable
            PDFSimpleExport pdfExport = new PDFSimpleExport();
            using (FileStream fs = new FileStream("output.pdf", FileMode.Create))
            {
                report.Export(pdfExport, fs);
            }
        }
    }
}
Imports FastReport
Imports FastReport.Export.PdfSimple
Imports System.Drawing
Imports System.IO

Module Program
    Sub Main()
        Using report As New Report()
            ' FastReport renders nothing unless objects live on a band that lives on a ReportPage.
            Dim page As New ReportPage()
            report.Pages.Add(page)
            page.ReportTitle = New ReportTitleBand With {.Height = Units.Millimeters * 100}

            ' Create HTML object (FastReport class is HtmlObject)
            Dim htmlObject As New HtmlObject()
            htmlObject.Bounds = New RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 100)
            htmlObject.Text = "<html><body><h1>Hello World</h1><p>This is a test PDF</p></body></html>"
            page.ReportTitle.Objects.Add(htmlObject)

            report.Prepare()

            ' PDFSimpleExport rasterizes each page — text is not selectable
            Dim pdfExport As New PDFSimpleExport()
            Using fs As New FileStream("output.pdf", FileMode.Create)
                report.Export(pdfExport, fs)
            End Using
        End Using
    End Sub
End Module
$vbLabelText   $csharpLabel

IronPDFの実装:

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1><p>This is a test PDF</p></body></html>");
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1><p>This is a test PDF</p></body></html>");
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1><p>This is a test PDF</p></body></html>")
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

FastReportは、Reportオブジェクトを作成し、ReportPageReportTitleBand をアタッチし、バンドに明確な境界を持つ HtmlObject を配置し、レポートを準備してストリーム経由でエクスポートすることを要求します。 PDFSimpleExport は出力をラスタライズするため、結果のPDFには選択可能なテキストではなく、テキストの画像が含まれます。 IronPDFは、直接HTMLレンダリングと選択可能なテキスト出力で、3行で同じ結果を達成します。 その他のオプションについては、HTML to PDF documentationを参照してください。

URLからPDFへの変換

この例では、FastReportが手動でHTMLをダウンロードする必要があるのに対して、IronPDFはURLレンダリングをネイティブで処理することを強調しています。

FastReportの実装:

// NuGet: Install-Package FastReport.OpenSource
//        Install-Package FastReport.OpenSource.Export.PdfSimple
//FastReporthas no native URL-to-PDF. You must download the HTML yourself
// and feed it into HtmlObject — which handles only a limited HTML 4 subset,
// no JavaScript and no modern CSS.
using FastReport;
using FastReport.Export.PdfSimple;
using System.Drawing;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        // Download HTML content from URL
        string htmlContent;
        using (var client = new HttpClient())
        {
            htmlContent = await client.GetStringAsync("https://example.com");
        }

        using (Report report = new Report())
        {
            ReportPage page = new ReportPage();
            report.Pages.Add(page);
            page.ReportTitle = new ReportTitleBand { Height = Units.Millimeters * 250 };

            HtmlObject htmlObject = new HtmlObject();
            htmlObject.Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 250);
            htmlObject.Text = htmlContent;
            page.ReportTitle.Objects.Add(htmlObject);

            report.Prepare();

            PDFSimpleExport pdfExport = new PDFSimpleExport();
            using (FileStream fs = new FileStream("webpage.pdf", FileMode.Create))
            {
                report.Export(pdfExport, fs);
            }
        }
    }
}
// NuGet: Install-Package FastReport.OpenSource
//        Install-Package FastReport.OpenSource.Export.PdfSimple
//FastReporthas no native URL-to-PDF. You must download the HTML yourself
// and feed it into HtmlObject — which handles only a limited HTML 4 subset,
// no JavaScript and no modern CSS.
using FastReport;
using FastReport.Export.PdfSimple;
using System.Drawing;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        // Download HTML content from URL
        string htmlContent;
        using (var client = new HttpClient())
        {
            htmlContent = await client.GetStringAsync("https://example.com");
        }

        using (Report report = new Report())
        {
            ReportPage page = new ReportPage();
            report.Pages.Add(page);
            page.ReportTitle = new ReportTitleBand { Height = Units.Millimeters * 250 };

            HtmlObject htmlObject = new HtmlObject();
            htmlObject.Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 250);
            htmlObject.Text = htmlContent;
            page.ReportTitle.Objects.Add(htmlObject);

            report.Prepare();

            PDFSimpleExport pdfExport = new PDFSimpleExport();
            using (FileStream fs = new FileStream("webpage.pdf", FileMode.Create))
            {
                report.Export(pdfExport, fs);
            }
        }
    }
}
Imports FastReport
Imports FastReport.Export.PdfSimple
Imports System.Drawing
Imports System.IO
Imports System.Net.Http
Imports System.Threading.Tasks

Module Program
    Async Function Main() As Task
        ' Download HTML content from URL
        Dim htmlContent As String
        Using client As New HttpClient()
            htmlContent = Await client.GetStringAsync("https://example.com")
        End Using

        Using report As New Report()
            Dim page As New ReportPage()
            report.Pages.Add(page)
            page.ReportTitle = New ReportTitleBand With {.Height = Units.Millimeters * 250}

            Dim htmlObject As New HtmlObject()
            htmlObject.Bounds = New RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 250)
            htmlObject.Text = htmlContent
            page.ReportTitle.Objects.Add(htmlObject)

            report.Prepare()

            Dim pdfExport As New PDFSimpleExport()
            Using fs As New FileStream("webpage.pdf", FileMode.Create)
                report.Export(pdfExport, fs)
            End Using
        End Using
    End Function
End Module
$vbLabelText   $csharpLabel

IronPDFの実装:

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
        pdf.SaveAs("webpage.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

FastReportにはネイティブなURL-to-PDF機能がなく、HttpClient でHTMLを自分でダウンロードし、バンドに HtmlObject として埋め込んでエクスポートします。 HtmlObject は限られたHTML 4のサブセットのみを処理し、JavaScriptの実行や最新のCSSはなく、PDFSimpleExport は出力をラスタライズします。 IronPDFの RenderUrlAsPdf は組み込みのChromiumエンジンを使用して、完全なJavaScriptの実行でライブウェブページを直接レンダリングします。詳細はURL to PDFドキュメントをご覧ください。

ページ番号を含むヘッダーとフッター

この例は、FastReportのバンドベースのシステムとIronPDFのHTMLベースのアプローチの複雑さの違いを示しています。

FastReportの実装:

// NuGet: Install-Package FastReport.OpenSource
//        Install-Package FastReport.OpenSource.Export.PdfSimple
using FastReport;
using FastReport.Export.PdfSimple;
using System.Drawing;
using System.IO;

class Program
{
    static void Main()
    {
        using (Report report = new Report())
        {
            report.Load("template.frx");

            // Cast to ReportPage (Report.Pages can hold dialog pages too)
            ReportPage page = report.Pages[0] as ReportPage;

            // Page header — assigned to the band slot on the page
            page.PageHeader = new PageHeaderBand { Height = Units.Millimeters * 15 };
            TextObject headerText = new TextObject
            {
                Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 10),
                Text = "Document Header",
                HorzAlign = HorzAlign.Center
            };
            page.PageHeader.Objects.Add(headerText);

            // Page footer withFastReportpage tokens [Page] and [TotalPages]
            page.PageFooter = new PageFooterBand { Height = Units.Millimeters * 15 };
            TextObject footerText = new TextObject
            {
                Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 10),
                Text = "Page [Page] of [TotalPages]",
                HorzAlign = HorzAlign.Right
            };
            page.PageFooter.Objects.Add(footerText);

            report.Prepare();

            PDFSimpleExport pdfExport = new PDFSimpleExport();
            using (FileStream fs = new FileStream("report.pdf", FileMode.Create))
            {
                report.Export(pdfExport, fs);
            }
        }
    }
}
// NuGet: Install-Package FastReport.OpenSource
//        Install-Package FastReport.OpenSource.Export.PdfSimple
using FastReport;
using FastReport.Export.PdfSimple;
using System.Drawing;
using System.IO;

class Program
{
    static void Main()
    {
        using (Report report = new Report())
        {
            report.Load("template.frx");

            // Cast to ReportPage (Report.Pages can hold dialog pages too)
            ReportPage page = report.Pages[0] as ReportPage;

            // Page header — assigned to the band slot on the page
            page.PageHeader = new PageHeaderBand { Height = Units.Millimeters * 15 };
            TextObject headerText = new TextObject
            {
                Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 10),
                Text = "Document Header",
                HorzAlign = HorzAlign.Center
            };
            page.PageHeader.Objects.Add(headerText);

            // Page footer withFastReportpage tokens [Page] and [TotalPages]
            page.PageFooter = new PageFooterBand { Height = Units.Millimeters * 15 };
            TextObject footerText = new TextObject
            {
                Bounds = new RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 10),
                Text = "Page [Page] of [TotalPages]",
                HorzAlign = HorzAlign.Right
            };
            page.PageFooter.Objects.Add(footerText);

            report.Prepare();

            PDFSimpleExport pdfExport = new PDFSimpleExport();
            using (FileStream fs = new FileStream("report.pdf", FileMode.Create))
            {
                report.Export(pdfExport, fs);
            }
        }
    }
}
Imports FastReport
Imports FastReport.Export.PdfSimple
Imports System.Drawing
Imports System.IO

Module Program
    Sub Main()
        Using report As New Report()
            report.Load("template.frx")

            ' Cast to ReportPage (Report.Pages can hold dialog pages too)
            Dim page As ReportPage = TryCast(report.Pages(0), ReportPage)

            ' Page header — assigned to the band slot on the page
            page.PageHeader = New PageHeaderBand With {.Height = Units.Millimeters * 15}
            Dim headerText As New TextObject With {
                .Bounds = New RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 10),
                .Text = "Document Header",
                .HorzAlign = HorzAlign.Center
            }
            page.PageHeader.Objects.Add(headerText)

            ' Page footer with FastReport page tokens [Page] and [TotalPages]
            page.PageFooter = New PageFooterBand With {.Height = Units.Millimeters * 15}
            Dim footerText As New TextObject With {
                .Bounds = New RectangleF(0, 0, Units.Millimeters * 190, Units.Millimeters * 10),
                .Text = "Page [Page] of [TotalPages]",
                .HorzAlign = HorzAlign.Right
            }
            page.PageFooter.Objects.Add(footerText)

            report.Prepare()

            Dim pdfExport As New PDFSimpleExport()
            Using fs As New FileStream("report.pdf", FileMode.Create)
                report.Export(pdfExport, fs)
            End Using
        End Using
    End Sub
End Module
$vbLabelText   $csharpLabel

IronPDFの実装:

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        // Configure header and footer
        renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Document Header</div>"
        };

        renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
        };

        var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Report Content</h1><p>This is the main content.</p></body></html>");
        pdf.SaveAs("report.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        // Configure header and footer
        renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Document Header</div>"
        };

        renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
        };

        var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Report Content</h1><p>This is the main content.</p></body></html>");
        pdf.SaveAs("report.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()

        ' Configure header and footer
        renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
            .HtmlFragment = "<div style='text-align:center'>Document Header</div>"
        }

        renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With {
            .HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
        }

        Dim pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Report Content</h1><p>This is the main content.</p></body></html>")
        pdf.SaveAs("report.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

FastReportはテンプレートのロード、Pages[0]ReportPage にキャスト、ページの PageHeader / PageFooter スロットにヘッダーおよびフッターバンドインスタンスを割り当て、各バンドに TextObject インスタンスを明示的な Bounds でアタッチすることを要求します。 IronPDFは、単純なHTMLフラグメントで HtmlHeaderFooter を使用します。ヘッダーとフッターのスタイルを完全なCSSで設定できます。 ページ番号の構文の変更に注意:[Page]{page} になり、[TotalPages]{total-pages} になります。 その他のオプションについては、headers and footers documentationを参照してください。

重要な移行に関する注意事項

.frxテンプレートファイルはありません

FastReportテンプレート(.frx)はIronPDFでは動作しません。 レイアウトをHTML/CSSテンプレートに変換します:

//FastReport- loads .frx template
report.Load("report.frx");

//IronPDF- use HTML template
var html = File.ReadAllText("template.html");
var pdf = renderer.RenderHtmlAsPdf(html);
//FastReport- loads .frx template
report.Load("report.frx");

//IronPDF- use HTML template
var html = File.ReadAllText("template.html");
var pdf = renderer.RenderHtmlAsPdf(html);
' FastReport - loads .frx template
report.Load("report.frx")

' IronPDF - use HTML template
Dim html As String = File.ReadAllText("template.html")
Dim pdf = renderer.RenderHtmlAsPdf(html)
$vbLabelText   $csharpLabel

データ バインディング変換

RegisterData() を HTML の直接生成に置き換えてください:

// FastReport
report.RegisterData(dataSet, "Data");
report.GetDataSource("Data").Enabled = true;

//IronPDF- use string interpolation or StringBuilder
var html = new StringBuilder();
foreach (var item in data)
{
    html.Append($"<tr><td>{item.Name}</td><td>{item.Value}</td></tr>");
}
var pdf = renderer.RenderHtmlAsPdf(html.ToString());
// FastReport
report.RegisterData(dataSet, "Data");
report.GetDataSource("Data").Enabled = true;

//IronPDF- use string interpolation or StringBuilder
var html = new StringBuilder();
foreach (var item in data)
{
    html.Append($"<tr><td>{item.Name}</td><td>{item.Value}</td></tr>");
}
var pdf = renderer.RenderHtmlAsPdf(html.ToString());
Imports System.Text

' FastReport
report.RegisterData(dataSet, "Data")
report.GetDataSource("Data").Enabled = True

' IronPDF - use string interpolation or StringBuilder
Dim html As New StringBuilder()
For Each item In data
    html.Append($"<tr><td>{item.Name}</td><td>{item.Value}</td></tr>")
Next
Dim pdf = renderer.RenderHtmlAsPdf(html.ToString())
$vbLabelText   $csharpLabel

セキュリティ設定

//IronPDFsecurity
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SecuritySettings.UserPassword = "password";
pdf.SecuritySettings.OwnerPassword = "ownerPassword";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
//IronPDFsecurity
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SecuritySettings.UserPassword = "password";
pdf.SecuritySettings.OwnerPassword = "ownerPassword";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
'IronPDFsecurity
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SecuritySettings.UserPassword = "password"
pdf.SecuritySettings.OwnerPassword = "ownerPassword"
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights
$vbLabelText   $csharpLabel

包括的なセキュリティ オプションについては、暗号化のドキュメントを参照してください。

移行後のチェックリスト

コードの移行が完了したら、以下を確認してください:

  • 生成されたPDFの視覚的な比較
  • ヘッダー/フッターとページ番号を確認する
  • 本番環境のデータ量でテストする
  • セキュリティ/暗号化機能の検証
  • パフォーマンスベンチマーク
  • 未使用の.frxテンプレートファイルを削除する
  • FastReport関連のコードを削除する
  • ドキュメントの更新

その他のリソース


FastReportからIronPDFへの移行は、ビジュアルデザイナーへの依存、バンドベースの学習曲線、断片化されたパッケージモデルを排除します。 HTML/CSSベースのPDF生成への移行は、使い慣れたWeb技術を活用しながら、PDFの完全な操作機能(マージ、分割、セキュリティ、フォーム)を単一のパッケージで提供します。

ご注意FastReportはその所有者の登録商標です。 当サイトはFast Reportsと提携しておらず、Fast Reportsによる承認または後援を受けていません。 すべての製品名、ロゴ、およびブランドは各所有者の所有物です。 比較は情報提供のみを目的としており、執筆時点で公開されている情報を反映しています。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

アイアンサポートチーム

私たちは週5日、24時間オンラインで対応しています。
チャット
メール
電話してね