フッターコンテンツにスキップ
移行ガイド

C#でSyncfusion PDFからIronPDFへ移行する方法

Syncfusion PDF FrameworkからIronPDFに移行することで、PDF生成ワークフローは、大規模なスイートにバンドルされた座標ベースのグラフィックスAPIから、最新のChromiumレンダリングを備えたスタンドアロンのHTML/CSSファーストライブラリに変わります。 このガイドは、スイートのみのライセンス、複雑な展開要件、および座標ベースの位置決めを排除する、完全で段階的な移行パスを提供します。

なぜSyncfusion PDFからIronPDFへ移行するのか

SyncfusionのPDFフレームワークを理解する

Syncfusion PDF Frameworkは、C#を使用してPDFドキュメントを作成、編集、保護するための幅広い機能を提供する包括的なライブラリです。 SyncfusionのEssential Studioの一部として提供され、複数のプラットフォームにわたって1000以上のコンポーネントが含まれています。

しかし、最も大きな欠点の1つは、単体で購入できないことです; 開発者は、Syncfusionのコンポーネント一式を購入する必要があります。 この要件は、PDFの機能だけに関心のあるチームにとっては面倒なものです。特に、このバンドルには、自分たちのプロジェクトには不要なツールが含まれている可能性があるからです。

バンドルライセンスの問題

Syncfusionのライセンスモデルは、PDF機能のみを必要とするチームにとって大きな課題となります:

  1. Suiteのみの購入: PDFライブラリを単独で購入することはできません。Essential Studio全体を購入する必要があります。 2.コミュニティライセンスの制限:無料プランでは、収益が100万ドル未満かつ開発者が5人未満である必要があります。 3.複雑な展開ライセンス: Web、デスクトップ、サーバーの展開ごとに異なるライセンス 4.毎年更新が必要:年間費用がかかるサブスクリプションモデル 5.開発者ごとの価格設定:コストはチームの規模に応じて比例して増加します 6.スイートの肥大化:必要のないコンポーネントが1000個以上含まれている

SyncfusionPDFとIronPDFの比較

アスペクト シンクフュージョンPDF IronPDF
購入モデル スイートバンドルのみ スタンドアロン
ライセンスについて 複雑な階層 開発者ごとのシンプルな
コミュニティの制限 <$1Mかつ<5人の開発者 無料トライアル、その後ライセンス
デプロイメント 複数のライセンスタイプ 1つのライセンスで
APIスタイル 座標ベースのグラフィック HTML/CSSファースト
HTMLのサポート BlinkBinariesが必要です ネイティブChromium
CSSサポート 制限的 フルCSS3/フレックスボックス/グリッド
依存関係について 複数のパッケージ 単一のNuGet
スイートの要件 はい(スイート全体) なし
PDFにフォーカス 幅広い; より大きなスイートの一部 狭い; PDFフォーカス

IronPDFはPDF機能をスタンドアロン製品として提供することで、より焦点を絞ったアプローチを提供します。 この違いは、コストの検討と統合の容易さの両方に大きく影響します。

2025年と2026年まで.NET 10とC# 14の採用を計画しているチームにとって、IronPDFのスタンドアロンライセンスとHTML/CSSファーストのアプローチは、スイートに依存することなく柔軟性を提供します。


始める前に

前提条件

  1. .NET 環境: .NET Framework 4.6.2+ または .NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGetアクセス: NuGetパッケージをインストールする機能
  3. IronPDFライセンス: ironpdf.comからライセンスキーを取得します。

NuGetパッケージの変更

# Remove Syncfusion packages
dotnet remove package Syncfusion.Pdf.Net.Core
dotnet remove package Syncfusion.HtmlToPdfConverter.Net.Windows
dotnet remove package Syncfusion.Licensing

# Install IronPDF
dotnet add package IronPdf
# Remove Syncfusion packages
dotnet remove package Syncfusion.Pdf.Net.Core
dotnet remove package Syncfusion.HtmlToPdfConverter.Net.Windows
dotnet remove package Syncfusion.Licensing

# Install IronPDF
dotnet add package IronPdf
SHELL

ライセンス構成

シンクフュージョン:

// Must register before any Syncfusion calls
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR-SYNCFUSION-KEY");
// Must register before any Syncfusion calls
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR-SYNCFUSION-KEY");
$vbLabelText   $csharpLabel

IronPDF:

// One-time at startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-KEY";
// One-time at startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-KEY";
$vbLabelText   $csharpLabel

完全な API リファレンス

名前空間の変更

// Before: Syncfusion PDF
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Parsing;
using Syncfusion.HtmlConverter;
using Syncfusion.Drawing;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
// Before: Syncfusion PDF
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Parsing;
using Syncfusion.HtmlConverter;
using Syncfusion.Drawing;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
$vbLabelText   $csharpLabel

コア API マッピング

Syncfusion IronPDF ノート
PdfDocument ChromePdfRenderer PDF作成
PdfLoadedDocument PdfDocument.FromFile()を使用してください。 PDFを読み込む
HtmlToPdfConverter ChromePdfRenderer HTML変換
graphics.DrawString() HTMLテキスト要素 <p>, <h1>
graphics.DrawImage() <img>タグ HTML画像
PdfGrid HTML `<テーブル>``
PdfStandardFont CSS font-family フォント
PdfBrushes.Black CSS 色: 黒
ドキュメント.セキュリティ pdf.SecuritySettings セキュリティ
PdfTextExtractor pdf.ExtractAllText()を使用してください。 テキスト抽出
ImportPageRange()を使用してください。 PdfDocument.Merge()を使用してください。 マージ
document.Save(stream)を実行します。 pdf.SaveAs(path)のようにします。 節約
document.Close(true). 不要 自動クリーンアップ

コード移行の例

例1: HTML/URLからPDFへの変換

翻訳前 (Syncfusion PDF):

// NuGet: Install-Package Syncfusion.Pdf.Net.Core
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using System.IO;

class Program
{
    static void Main()
    {
        // Initialize HTML to PDF converter
        HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

        // Convert URL to PDF
        PdfDocument document = htmlConverter.Convert("https://www.example.com");

        // Save the document
        FileStream fileStream = new FileStream("Output.pdf", FileMode.Create);
        document.Save(fileStream);
        document.Close(true);
        fileStream.Close();
    }
}
// NuGet: Install-Package Syncfusion.Pdf.Net.Core
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using System.IO;

class Program
{
    static void Main()
    {
        // Initialize HTML to PDF converter
        HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

        // Convert URL to PDF
        PdfDocument document = htmlConverter.Convert("https://www.example.com");

        // Save the document
        FileStream fileStream = new FileStream("Output.pdf", FileMode.Create);
        document.Save(fileStream);
        document.Close(true);
        fileStream.Close();
    }
}
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        // Create a PDF from a URL
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");

        // Save the PDF
        pdf.SaveAs("Output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        // Create a PDF from a URL
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");

        // Save the PDF
        pdf.SaveAs("Output.pdf");
    }
}
$vbLabelText   $csharpLabel

この例は、基本的なAPIの違いを示しています。 Syncfusion PDFでは、HtmlToPdfConverterインスタンスを作成し、PdfDocumentを返すConvert()を呼び出し、手動でFileStreamを作成し、保存し、ドキュメントとストリームの両方を閉じる必要があります。

IronPDFはChromePdfRendererRenderUrlAsPdf()をわずか3行のコードで使用します。 FileStreamの管理、Close()呼び出しはありません。 包括的な例については、HTML to PDF documentationを参照してください。

例2:テキストからPDFを作成する

翻訳前 (Syncfusion PDF):

// NuGet: Install-Package Syncfusion.Pdf.Net.Core
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Drawing;
using System.IO;

class Program
{
    static void Main()
    {
        // Create a new PDF document
        PdfDocument document = new PdfDocument();

        // Add a page
        PdfPage page = document.Pages.Add();

        // Create a font
        PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);

        // Draw text
        page.Graphics.DrawString("Hello, World!", font, PdfBrushes.Black, new PointF(10, 10));

        // Save the document
        FileStream fileStream = new FileStream("Output.pdf", FileMode.Create);
        document.Save(fileStream);
        document.Close(true);
        fileStream.Close();
    }
}
// NuGet: Install-Package Syncfusion.Pdf.Net.Core
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Drawing;
using System.IO;

class Program
{
    static void Main()
    {
        // Create a new PDF document
        PdfDocument document = new PdfDocument();

        // Add a page
        PdfPage page = document.Pages.Add();

        // Create a font
        PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);

        // Draw text
        page.Graphics.DrawString("Hello, World!", font, PdfBrushes.Black, new PointF(10, 10));

        // Save the document
        FileStream fileStream = new FileStream("Output.pdf", FileMode.Create);
        document.Save(fileStream);
        document.Close(true);
        fileStream.Close();
    }
}
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;

class Program
{
    static void Main()
    {
        // Create a PDF from HTML string
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Hello, World!</h1>");

        // Save the document
        pdf.SaveAs("Output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;

class Program
{
    static void Main()
    {
        // Create a PDF from HTML string
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Hello, World!</h1>");

        // Save the document
        pdf.SaveAs("Output.pdf");
    }
}
$vbLabelText   $csharpLabel

Syncfusion PDFは座標ベースのグラフィックモデルを使用しています。 PdfDocumentを作成し、PdfPageを追加し、PdfFontFamily.HelveticaPdfFontを作成し、座標(new PointF(10, 10))、フォント、ブラシ(PdfBrushes.Black)を指定してpage.Graphics.DrawString()を呼び出します。 最後に、FileStream の作成と廃棄を管理します。

IronPdfはHTML/CSSファーストのアプローチを採用しています。 Instead of coordinates, you write <h1>Hello, World!</h1> and let CSS handle positioning, fonts, and colors. このアプローチは、よりシンプルで保守性が高く、開発者がすでに持っているスキルを活用できます。 詳しくは、チュートリアルをご覧ください。

例 3: PDF ドキュメントをマージする

翻訳前 (Syncfusion PDF):

// NuGet: Install-Package Syncfusion.Pdf.Net.Core
using Syncfusion.Pdf;
using Syncfusion.Pdf.Parsing;
using System.IO;

class Program
{
    static void Main()
    {
        // Load the first PDF document
        FileStream stream1 = new FileStream("Document1.pdf", FileMode.Open, FileAccess.Read);
        PdfLoadedDocument loadedDocument1 = new PdfLoadedDocument(stream1);

        // Load the second PDF document
        FileStream stream2 = new FileStream("Document2.pdf", FileMode.Open, FileAccess.Read);
        PdfLoadedDocument loadedDocument2 = new PdfLoadedDocument(stream2);

        // Merge the documents
        PdfDocument finalDocument = new PdfDocument();
        finalDocument.ImportPageRange(loadedDocument1, 0, loadedDocument1.Pages.Count - 1);
        finalDocument.ImportPageRange(loadedDocument2, 0, loadedDocument2.Pages.Count - 1);

        // Save the merged document
        FileStream outputStream = new FileStream("Merged.pdf", FileMode.Create);
        finalDocument.Save(outputStream);

        // Close all documents
        finalDocument.Close(true);
        loadedDocument1.Close(true);
        loadedDocument2.Close(true);
        stream1.Close();
        stream2.Close();
        outputStream.Close();
    }
}
// NuGet: Install-Package Syncfusion.Pdf.Net.Core
using Syncfusion.Pdf;
using Syncfusion.Pdf.Parsing;
using System.IO;

class Program
{
    static void Main()
    {
        // Load the first PDF document
        FileStream stream1 = new FileStream("Document1.pdf", FileMode.Open, FileAccess.Read);
        PdfLoadedDocument loadedDocument1 = new PdfLoadedDocument(stream1);

        // Load the second PDF document
        FileStream stream2 = new FileStream("Document2.pdf", FileMode.Open, FileAccess.Read);
        PdfLoadedDocument loadedDocument2 = new PdfLoadedDocument(stream2);

        // Merge the documents
        PdfDocument finalDocument = new PdfDocument();
        finalDocument.ImportPageRange(loadedDocument1, 0, loadedDocument1.Pages.Count - 1);
        finalDocument.ImportPageRange(loadedDocument2, 0, loadedDocument2.Pages.Count - 1);

        // Save the merged document
        FileStream outputStream = new FileStream("Merged.pdf", FileMode.Create);
        finalDocument.Save(outputStream);

        // Close all documents
        finalDocument.Close(true);
        loadedDocument1.Close(true);
        loadedDocument2.Close(true);
        stream1.Close();
        stream2.Close();
        outputStream.Close();
    }
}
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        // Load PDF documents
        var pdf1 = PdfDocument.FromFile("Document1.pdf");
        var pdf2 = PdfDocument.FromFile("Document2.pdf");

        // Merge PDFs
        var merged = PdfDocument.Merge(new List<PdfDocument> { pdf1, pdf2 });

        // Save the merged document
        merged.SaveAs("Merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        // Load PDF documents
        var pdf1 = PdfDocument.FromFile("Document1.pdf");
        var pdf2 = PdfDocument.FromFile("Document2.pdf");

        // Merge PDFs
        var merged = PdfDocument.Merge(new List<PdfDocument> { pdf1, pdf2 });

        // Save the merged document
        merged.SaveAs("Merged.pdf");
    }
}
$vbLabelText   $csharpLabel

PDFをマージする際のコントラストは劇的です。 Syncfusion PDFでは、各入力ドキュメントに対してFileStreamオブジェクトを作成し、それらをPdfLoadedDocumentとして読み込み、新しいPdfDocumentを作成し、各ソースに対して開始と終了のインデックスを指定してImportPageRange()を呼び出す必要があります、出力のFileStreamを作成し、6つの別々のオブジェクトfinalDocument, loadedDocument1, loadedDocument2, stream1, stream2, outputStream)を閉じます。

IronPDFはPdfDocument.FromFile()を使って各PDFを読み込み、静的なPdfDocument.Merge()メソッドでドキュメントのリストを受け取ります。 ストリーム管理、手動でのページ範囲計算、クローズコールはありません。


API哲学の主な相違点

座標ベース vs HTML/CSSファースト

Syncfusion PDFは、従来のPDFライブラリから受け継いだ座標ベースのグラフィックモデルを使用しています:

// Syncfusion: マニュアル positioning
page.Graphics.DrawString("Text", font, PdfBrushes.Black, new PointF(100, 200));
page.Graphics.DrawRectangle(brush, new RectangleF(50, 50, 200, 100));
// Syncfusion: マニュアル positioning
page.Graphics.DrawString("Text", font, PdfBrushes.Black, new PointF(100, 200));
page.Graphics.DrawRectangle(brush, new RectangleF(50, 50, 200, 100));
$vbLabelText   $csharpLabel

IronPDFはレイアウトにHTML/CSSを使用しています:

// IronPDF: CSS-based positioning
var html = @"
<div style='margin: 50px; padding: 20px; border: 1px solid black;'>
    <p style='color: black;'>Text</p>
</div>";
var pdf = renderer.RenderHtmlAsPdf(html);
// IronPDF: CSS-based positioning
var html = @"
<div style='margin: 50px; padding: 20px; border: 1px solid black;'>
    <p style='color: black;'>Text</p>
</div>";
var pdf = renderer.RenderHtmlAsPdf(html);
$vbLabelText   $csharpLabel

HTML/CSSのアプローチは、ウェブ開発者にとってより直感的で、メンテナンスが容易で、異なるページサイズでも一貫した結果をもたらします。

ストリーム管理と自動クリーンアップの比較

Syncfusion PDFには、明示的なストリームとドキュメント廃棄が必要です:

// Syncfusion: マニュアル cleanup
FileStream fileStream = new FileStream("Output.pdf", FileMode.Create);
document.Save(fileStream);
document.Close(true);
fileStream.Close();
// Syncfusion: マニュアル cleanup
FileStream fileStream = new FileStream("Output.pdf", FileMode.Create);
document.Save(fileStream);
document.Close(true);
fileStream.Close();
$vbLabelText   $csharpLabel

IronPDFは自動的にクリーンアップを行います:

// IronPDF:自動翻訳cleanup
pdf.SaveAs("Output.pdf");
// IronPDF:自動翻訳cleanup
pdf.SaveAs("Output.pdf");
$vbLabelText   $csharpLabel

機能比較

フィーチャー シンクフュージョンPDF IronPDF
スタンダロンの購入 なし(スイートのみ) はい
ライセンスについて コミュニティ制限付き商用 簡易商用
HTMLからPDFへ BlinkBinariesが必要です ネイティブChromium
CSS3のサポート 制限的 フル(フレックスボックス、グリッド)
APIスタイル 座標ベースのグラフィック HTML/CSSファースト
ストリーム管理 マニュアル 自動翻訳
依存関係について 複数のパッケージ 単一のNuGet
展開の複雑さ 複雑な ストレート

移行チェックリスト

移行前

  • コードベース内のすべてのSyncfusion PDFの使用状況をインベントリする
  • ライセンスコストと展開要件を文書化する -PdfGridPdfGraphicsHtmlToPdfConverter`の使用法を特定する
  • ironpdf.comからIronPDFライセンスキーを取得します

コードの更新

  • Syncfusion パッケージ ( Syncfusion.Pdf.Net.CoreSyncfusion.HtmlToPdfConverter.Net.WindowsSyncfusion.Licensing ) を削除します
  • IronPdf NuGetパッケージをインストールする
  • 名前空間のインポートを更新します ( using Syncfusion.Pdf;using IronPdf; )
  • Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense()IronPdf.License.LicenseKey = &quot;...&quot;に置き換えます。
  • HtmlToPdfConverter.Convert()ChromePdfRenderer.RenderUrlAsPdf()またはRenderHtmlAsPdf()に置き換えます -PdfDocument+ Pages.Add() + Graphics.DrawString()ChromePdfRenderer.RenderHtmlAsPdf()に置き換えます -PdfLoadedDocument``PdfDocument.FromFile()に置き換えます -ImportPageRange()を使用してください。PdfDocument.Merge()に置き換えます
  • document.Save(stream)pdf.SaveAs(path)に置き換えます
  • すべてのdocument.Close(true)およびstream.Close()呼び出しを削除します。 -PdfGridHTMLに置き換える<table>要素 -PdfStandardFontCSSのfont-familyに置き換える
  • PdfBrushes CSS colorプロパティに置き換える

テスティング

  • PDF出力の視覚的な比較
  • CSS レンダリングの改善を検証 (flexbox、グリッドが動作するようになりました)
  • テストテキスト抽出
  • テストのマージと分割
  • パフォーマンス比較

カーティス・チャウ
テクニカルライター

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

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