How to Add Table of Contents in C# | IronPDF
Full Comparison
Looking for a detailed feature-by-feature breakdown? See how IronPDF stacks up against Syncfusion PDF on pricing, HTML support, and licensing.
Syncfusion PDF FrameworkからIronPDFに移行することで、PDF生成ワークフローは、大規模なスイートにバンドルされた座標ベースのグラフィックスAPIから、最新のChromiumレンダリングを備えたスタンドアロンのHTML/CSSファーストライブラリに変わります。 このガイドは、スイートのみのライセンス、複雑な展開要件、および座標ベースの位置決めを排除する、完全で段階的な移行パスを提供します。
なぜSyncfusion PDFからIronPDFへ移行するのか
SyncfusionのPDFフレームワークを理解する
Syncfusion PDF Frameworkは、C#を使用してPDFドキュメントを作成、編集、保護するための幅広い機能を提供する包括的なライブラリです。 SyncfusionのEssential Studioの一部として提供され、複数のプラットフォームにわたって1000以上のコンポーネントが含まれています。
PDFライブラリは単一コンポーネントとして購入できません。 Syncfusionは、UIコンポーネントなしでPDF、Word、Excel、PowerPointライブラリをバンドルした"Document SDK"ティアを提供し、フルEssential Studioスイートに加わります。PDF機能のみが必要なチームは、Document SDKを最低限取得しなければならず、他のドキュメントライブラリが未使用の場合は手間です。
バンドルライセンスの問題
Syncfusionのライセンスモデルは、PDF機能のみを必要とするチームにとって大きな課題となります:
- ライブラリごとの購入はできません: PDFはDocument SDK(PDF + Word + Excel + PowerPoint)またはフルEssential Studioにバンドルされており、単独でライセンスされることはできません。
- コミュニティライセンスの制限: 無料ティアは年収<$1M、≤5人の開発者、総従業員数≤10人に加え、外部資金の生涯上限$3Mを要求します。 3.複雑な展開ライセンス: Web、デスクトップ、サーバーの展開ごとに異なるライセンス
- 年間更新が必要: 年間コスト(最低1年の期限)のサブスクリプションモデル 5.開発者ごとの価格設定:コストはチームの規模に応じて比例して増加します
- バンドルの過剰: ドキュメントSDKはWord/Excel/PowerPointの依存関係を引き込み、PDFのみが必要な場合でも; フルEssential Studioは1000以上のUIコンポーネントを追加します
SyncfusionPDFとIronPDFの比較
| アスペクト | シンクフュージョンPDF | IronPDF |
|---|---|---|
| 購入モデル | ドキュメントSDKバンドルまたはフルEssential Studio(ライブラリごとのSKUなし) | スタンドアロン |
| ライセンスについて | 複雑な階層 | 開発者ごとのシンプルな |
| コミュニティの制限 | <$1M revenue, ≤5 devs, ≤10 employees, ≤$3M outside capital | 無料トライアル、その後ライセンス |
| デプロイメント | 複数のライセンスタイプ | 1つのライセンスで |
| APIスタイル | 座標を基にしたグラフィック+HTMLコンバーター | HTML/CSSファースト |
| HTMLエンジン | Blink (別々のWindows/Linux/Mac NuGets) | Chromiumをバンドル |
| CSSサポート | 最新 (Blink) — Chromiumのパリティに近い | フルCSS3/フレックスボックス/グリッド |
| 依存関係について | 複数のパッケージ | 単一のNuGet |
| バンドル要件 | はい (Document SDK または Essential Studio) | なし |
| PDFにフォーカス。 | 幅広い; より大きなバンドルの一部 | 狭い; PDFフォーカス |
IronPDFはPDF機能をスタンドアロン製品として提供することで、より焦点を絞ったアプローチを提供します。 この違いは、コストの検討と統合の容易さの両方に大きく影響します。
最新 for .NETを採用するチームにとって、IronPDFのスタンドアロンライセンスとHTML/CSSを優先するアプローチは、バンドル依存性なしで柔軟性を提供します。
始める前に
前提条件
- .NET環境: .NET Framework 4.6.2+ または.NET Core 3.1+ / .NET 5/6/7/8/9+
- NuGetアクセス: NuGetパッケージをインストールする機能
- IronPDFライセンス: IronPDFからライセンスキーを取得します。
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
ライセンス構成
シンクフュージョン:
// 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");
' Must register before any Syncfusion calls
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR-SYNCFUSION-KEY")
IronPDF:
// One-time at startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// One-time at startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' One-time at startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
完全な 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;
Imports IronPdf
Imports IronPdf.Rendering
コア API マッピング
| Syncfusion | IronPDF |
|---|---|
PdfDocument |
ChromePdfRenderer |
PdfLoadedDocument |
PdfDocument.FromFile() |
HtmlToPdfConverter |
ChromePdfRenderer |
graphics.DrawString() |
HTMLテキスト要素 |
graphics.DrawImage() |
<img> タグ |
PdfGrid |
HTML <table> |
PdfStandardFont |
CSS font-family |
PdfBrushes.Black |
CSS color: black |
document.Security |
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();
}
}
Imports Syncfusion.HtmlConverter
Imports Syncfusion.Pdf
Imports System.IO
Module Program
Sub Main()
' Initialize HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter()
' Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.example.com")
' Save the document
Dim fileStream As New FileStream("Output.pdf", FileMode.Create)
document.Save(fileStream)
document.Close(True)
fileStream.Close()
End Sub
End Module
翻訳後(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");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
' Create a PDF from a URL
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderUrlAsPdf("https://www.example.com")
' Save the PDF
pdf.SaveAs("Output.pdf")
End Sub
End Class
この例は、基本的なAPIの違いを示しています。 Syncfusion PDFはFileStreamを手動で作成し、ドキュメントとストリームの両方を保存して閉じます。
IronPDFは、わずか3行のコードでRenderUrlAsPdf()とともに使用します。 Close()呼び出しは不要—I()ronPDFがクリーンアップを自動で処理します。 包括的な例については、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();
}
}
Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Graphics
Imports Syncfusion.Drawing
Imports System.IO
Module Program
Sub Main()
' Create a new PDF document
Dim document As New PdfDocument()
' Add a page
Dim page As PdfPage = document.Pages.Add()
' Create a font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
' Draw text
page.Graphics.DrawString("Hello, World!", font, PdfBrushes.Black, New PointF(10, 10))
' Save the document
Dim fileStream As New FileStream("Output.pdf", FileMode.Create)
document.Save(fileStream)
document.Close(True)
fileStream.Close()
End Sub
End Module
翻訳後(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");
}
}
Imports IronPdf
Imports IronPdf.Rendering
Class Program
Shared Sub Main()
' Create a PDF from HTML string
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello, World!</h1>")
' Save the document
pdf.SaveAs("Output.pdf")
End Sub
End Class
Syncfusion PDFは座標ベースのグラフィックモデルを使用しています。 まずPdfBrushes.Black)で呼び出します。 最後に、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();
}
}
Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Parsing
Imports System.IO
Class Program
Shared Sub Main()
' Load the first PDF document
Dim stream1 As New FileStream("Document1.pdf", FileMode.Open, FileAccess.Read)
Dim loadedDocument1 As New PdfLoadedDocument(stream1)
' Load the second PDF document
Dim stream2 As New FileStream("Document2.pdf", FileMode.Open, FileAccess.Read)
Dim loadedDocument2 As New PdfLoadedDocument(stream2)
' Merge the documents
Dim finalDocument As New PdfDocument()
finalDocument.ImportPageRange(loadedDocument1, 0, loadedDocument1.Pages.Count - 1)
finalDocument.ImportPageRange(loadedDocument2, 0, loadedDocument2.Pages.Count - 1)
' Save the merged document
Dim outputStream As 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()
End Sub
End Class
翻訳後(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");
}
}
Imports IronPdf
Imports System.Collections.Generic
Class Program
Shared Sub Main()
' Load PDF documents
Dim pdf1 = PdfDocument.FromFile("Document1.pdf")
Dim pdf2 = PdfDocument.FromFile("Document2.pdf")
' Merge PDFs
Dim merged = PdfDocument.Merge(New List(Of PdfDocument) From {pdf1, pdf2})
' Save the merged document
merged.SaveAs("Merged.pdf")
End Sub
End Class
PDFをマージする際のコントラストは劇的です。 Syncfusion PDFでは、各入力ドキュメントに対しoutputStream)を閉じます。
IronPDFは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));
' Syncfusion: マニュアル positioning
page.Graphics.DrawString("Text", font, PdfBrushes.Black, New PointF(100, 200))
page.Graphics.DrawRectangle(brush, New RectangleF(50, 50, 200, 100))
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);
' IronPDF: CSS-based positioning
Dim html As String = "
<div style='margin: 50px; padding: 20px; border: 1px solid black;'>
<p style='color: black;'>Text</p>
</div>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
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();
' Syncfusion: マニュアル cleanup
Dim fileStream As New FileStream("Output.pdf", FileMode.Create)
document.Save(fileStream)
document.Close(True)
fileStream.Close()
IronPDFは自動的にクリーンアップを行います:
// IronPDF:自動翻訳cleanup
pdf.SaveAs("Output.pdf");
// IronPDF:自動翻訳cleanup
pdf.SaveAs("Output.pdf");
' IronPDF:自動翻訳cleanup
pdf.SaveAs("Output.pdf")
機能比較
| フィーチャー | シンクフュージョンPDF | IronPDF |
|---|---|---|
| スタンダロンの購入 | いいえ (Document SDK または Essential Studio) | はい |
| ライセンスについて | コミュニティ制限付き商用 | 簡易商用 |
| HTMLエンジン | Blink (プラットフォーム固有のNuGets) | Chromiumをバンドル |
| CSS3のサポート。 | Blink経由で最新 | フル(フレックスボックス、グリッド) |
| APIスタイル | 座標を基にしたグラフィック+HTMLコンバーター | HTML/CSSファースト |
| ストリーム管理 | マニュアル | 自動翻訳 |
| 依存関係について | 複数のパッケージ | 単一のNuGet |
| 展開の複雑さ | 複雑な | ストレート |
移行チェックリスト
移行前
- コードベース内のすべてのSyncfusion PDFの使用状況をインベントリする
- ライセンスコストと展開要件を文書化する
HtmlToPdfConverterの使用を特定する- IronPDFからIronPDFライセンスキーを取得します
コードの更新
- Syncfusionパッケージを削除する(
Syncfusion.Licensing) IronPdfNuGetパッケージをインストールする- 名前空間インポートを更新する(
using Syncfusion.Pdf;→using IronPdf;) IronPdf.License.LicenseKey = "..."に置き換えるRenderHtmlAsPdf()に置き換えるPdfDocument+Pages.Add()+ChromePdfRenderer.RenderHtmlAsPdf()に置き換えるPdfDocument.FromFile()に置き換えるPdfDocument.Merge()に置き換えるpdf.SaveAs(path)に置き換える- すべての
stream.Close()呼び出しを削除する PdfGridをHTML<table>要素に置き換えるPdfStandardFontをCSSfont-familyに置き換えるPdfBrushesをCSScolorプロパティに置き換える
テスティング
- PDF出力の視覚的な比較
- CSS レンダリングの改善を検証 (flexbox、グリッドが動作するようになりました)
- テストテキスト抽出
- テストのマージと分割
- パフォーマンス比較

