How to Rotate Text in PDFs Using C#
GemBox.PdfからIronPDFへの移行により、.NET PDFワークフローが座標ベースのプログラム的なドキュメント構築から、最新のHTML/CSSベースのレンダリングに変わります。 このガイドは、2ページのフリーモード制限を解除し、プロ for .NET開発者向けにドキュメント作成を簡素化する包括的なステップバイステップの移行パスを提供します。
なぜGemBox.PdfからIronPDFに移行するのか
GemBox.Pdfの課題
GemBox.Pdfは有能な.NET PDFコンポーネントですが、実際の開発において考慮すべき制限があります:
-
2ページのフリーモード制限: 無料バージョンでは2ページを超えるPDFを読み込みまたは保存する場合、
FreeLimitReachedExceptionがスローされるため、1ページの領収書または2ページの請求書を超えるものには、有料ライセンスが必要です。 (Source: gemboxsoftware.com/pdf/free-version.) -
HTMLからPDFへの変換不可: GemBox.PdfはHTMLをレンダリングできません—
PdfDocument.Loadは既存のPDFファイルを開くだけです。 HTMLをPDFに変換するには、別のGemBox.Document製品を購入する必要があります(異なるSKU、異なるライセンス)。 -
座標ベースのレイアウト: GemBox.Pdfは低レベルのPDFコンテンツストリームAPIです。 テキストを配置するには、PDFユーザースペース単位でX/Yを計算し、
page.Content.DrawText(formattedText, new PdfPoint(x, y))を呼び出します。 フローレイアウトはありません。 - OfficeからPDFへの変換には他のSKUが必要: Word→PDFにはGemBox.Documentが、Excel→PDFにはGemBox.Spreadsheetがそれぞれ必要で、個別のライセンスが必要です; GemBox.Bundleはそれらすべてをカバーしますが、コストが高くなります。
5.プログラムのみ:設計を変更するたびにコードの変更が必要になります。 スペースを調整しますか? 座標を再計算します。 フォントサイズを変更しますか?それ以下のY位置を調整します。
-
商業ライセンス価格: 個別開発者ライセンスは$890(更新$534)、小チーム(10人の開発者)は$4,450、大チーム(50人の開発者)は$13,350です。(出典:gemboxsoftware.com/pdf/pricing.)
- デザインの習得曲線: 開発者はドキュメントフローではなく座標で考えなければならないため、"段落を追加"するような単純なタスクでも意外に手間がかかります。
GemBox.Pdf対IronPDFの比較
| アスペクト | GemBox.Pdf | IronPDF |
|---|---|---|
| 無料版の制限 | 2ページの最大(FreeLimitReachedException) | ウォーターマークのみ、ページ制限なし |
| HTMLからPDFへ | サポートなし(GemBox.Documentが必要) | フルChromiumエンジン |
| Word/Excel → PDF | 別のSKU(GemBox.Document / GemBox.Spreadsheet) | HTMLパイプライン経由でレンダリング |
| レイアウトアプローチ | 座標ベース、マニュアル | HTML/CSSフローレイアウト |
| モダンCSS | 該当なし | Flexbox、グリッド、CSS3アニメーション |
| JavaScriptサポート | 該当なし | 完全なJavaScriptの実行 |
| デザインの変更 | 座標の再計算 | HTML/CSSの編集 |
| 学習曲線 | PDF座標系 | HTML/CSS(ウェブに精通している) |
IronPDFは、現代 for .NET上でPDFを生成するために、なじみのあるWeb技術を活用します。
マイグレーションの複雑さの評価
機能別の見積もり作業
| フィーチャー | 移行の複雑さ |
|---|---|
| PDFの読み込み/保存 | 低レベル |
| PDFのマージ | 低レベル |
| PDFの分割 | 低レベル |
| テキスト抽出 | 低レベル |
| テキストの追加 | 中規模 |
| 表 | 低レベル |
| 画像 | 低レベル |
| 透かし | 低レベル |
| パスワード保護 | 中規模 |
| フォームフィールド | 中規模 |
パラダイムシフト
このGemBox.Pdfの移行における最大の変化は、座標ベースのレイアウトからHTML/CSSレイアウトに移行することです:
GemBox.Pdf: "位置(100, 700)にテキストを描画"
IronPDF: "CSSスタイリングでこのHTMLをレンダリングする"
このパラダイムシフトは、ウェブ技術に精通した開発者にとっては一般的に容易ですが、PDFについては別の考え方が必要です。
始める前に
前提条件
- .NETバージョン: IronPDFは.NET Framework 4.6.2+および.NET Core 2.0+ / .NET 5+をサポートしています。 2.ライセンスキー: IronPDFからIronPDFライセンスキーを取得します。 3.バックアップ:移行作業用のブランチを作成する
- HTML/CSSの知識:基本的な知識があれば役立ちますが、必須ではありません
すべてのGemBox.Pdfの使用を特定する
# Find all GemBox.Pdf references
grep -r "GemBox\.Pdf\|PdfDocument\|PdfPage\|PdfFormattedText\|ComponentInfo\.SetLicense" --include="*.cs" .
# Find package references
grep -r "GemBox\.Pdf" --include="*.csproj" .
# Find all GemBox.Pdf references
grep -r "GemBox\.Pdf\|PdfDocument\|PdfPage\|PdfFormattedText\|ComponentInfo\.SetLicense" --include="*.cs" .
# Find package references
grep -r "GemBox\.Pdf" --include="*.csproj" .
NuGetパッケージの変更
# Remove GemBox.Pdf
dotnet remove package GemBox.Pdf
# Install IronPDF
dotnet add package IronPdf
# Remove GemBox.Pdf
dotnet remove package GemBox.Pdf
# Install IronPDF
dotnet add package IronPdf
クイック スタート マイグレーション
ステップ 1: ライセンス構成の更新
前(GemBox.Pdf):
// Must call before any GemBox.Pdf operations
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// Or for professional:
ComponentInfo.SetLicense("YOUR-PROFESSIONAL-LICENSE");
// Must call before any GemBox.Pdf operations
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// Or for professional:
ComponentInfo.SetLicense("YOUR-PROFESSIONAL-LICENSE");
' Must call before any GemBox.Pdf operations
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
' Or for professional:
ComponentInfo.SetLicense("YOUR-PROFESSIONAL-LICENSE")
翻訳後(IronPDF):。
// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Or in appsettings.json:
// { "IronPdf.License.LicenseKey": "YOUR-LICENSE-KEY" }
// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Or in appsettings.json:
// { "IronPdf.License.LicenseKey": "YOUR-LICENSE-KEY" }
Imports IronPdf
' Set once at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
' Or in appsettings.json:
' { "IronPdf.License.LicenseKey": "YOUR-LICENSE-KEY" }
ステップ 2: 名前空間インポートを更新する
// Before (GemBox.Pdf)
using GemBox.Pdf;
using GemBox.Pdf.Content;
// After (IronPDF)
using IronPdf;
using IronPdf.Editing;
// Before (GemBox.Pdf)
using GemBox.Pdf;
using GemBox.Pdf.Content;
// After (IronPDF)
using IronPdf;
using IronPdf.Editing;
Imports IronPdf
Imports IronPdf.Editing
ステップ 3: 基本的な変換パターン
前(GemBox.Pdf):
using GemBox.Pdf;
using GemBox.Pdf.Content;
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var page = document.Pages.Add();
// PdfFormattedText has no Text property; use Append/AppendLine.
var formattedText = new PdfFormattedText();
formattedText.FontSize = 24;
formattedText.Append("Hello World");
page.Content.DrawText(formattedText, new PdfPoint(100, 700));
document.Save("output.pdf");
}
using GemBox.Pdf;
using GemBox.Pdf.Content;
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var page = document.Pages.Add();
// PdfFormattedText has no Text property; use Append/AppendLine.
var formattedText = new PdfFormattedText();
formattedText.FontSize = 24;
formattedText.Append("Hello World");
page.Content.DrawText(formattedText, new PdfPoint(100, 700));
document.Save("output.pdf");
}
Imports GemBox.Pdf
Imports GemBox.Pdf.Content
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Using document As New PdfDocument()
Dim page = document.Pages.Add()
' PdfFormattedText has no Text property; use Append/AppendLine.
Dim formattedText As New PdfFormattedText()
formattedText.FontSize = 24
formattedText.Append("Hello World")
page.Content.DrawText(formattedText, New PdfPoint(100, 700))
document.Save("output.pdf")
End Using
翻訳後(IronPDF):。
using IronPdf;
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1 style='font-size:24px;'>Hello World</h1>");
pdf.SaveAs("output.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1 style='font-size:24px;'>Hello World</h1>");
pdf.SaveAs("output.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1 style='font-size:24px;'>Hello World</h1>")
pdf.SaveAs("output.pdf")
主な違い:
- 座標計算不要
- プログラムレイアウトの代わりにHTML/CSS
- 2ページのフリーモード天井なし
- よりシンプルで読みやすいコード
完全な API リファレンス
名前空間マッピング
| GemBox.Pdf | IronPDF |
|---|---|
GemBox.Pdf |
IronPdf |
GemBox.Pdf.Content |
IronPdf (コンテンツはHTMLです) |
GemBox.Pdf.Security |
IronPdf (セキュリティ設定) |
GemBox.Pdf.Forms |
IronPdf.Forms |
コア クラス マッピング
| GemBox.Pdf | IronPDF | 翻訳内容 |
|---|---|---|
PdfDocument |
PdfDocument |
主なPDF文書クラス |
PdfPage |
PdfDocument.Pages[i] |
ページ表現 |
PdfContent |
該当なし(HTMLを使用) | ページ内容 |
PdfFormattedText |
該当なし(HTMLを使用) | 書式付きテキスト |
PdfPoint |
該当なし(CSSポジショニングを使用) | ポジショニング |
ComponentInfo.SetLicense() |
IronPdf.License.LicenseKey |
ライセンス管理 |
ドキュメント操作
| GemBox.Pdf | IronPDF |
|---|---|
new PdfDocument() |
new PdfDocument() |
PdfDocument.Load(path) |
PdfDocument.FromFile(path) |
PdfDocument.Load(stream) |
PdfDocument.FromStream(stream) |
document.Save(path) |
pdf.SaveAs(path) |
document.Save(stream) |
pdf.BinaryData (返す値はbyte[]です) |
ページ操作
| GemBox.Pdf | IronPDF |
|---|---|
document.Pages.Add() |
HTMLレンダリングによる作成 |
document.Pages.Count |
pdf.PageCount |
document.Pages[index] |
pdf.Pages[index] |
document.Pages.AddClone(pages) |
PdfDocument.Merge() |
テキストとコンテンツの操作
| GemBox.Pdf | IronPDF |
|---|---|
new PdfFormattedText() |
HTML文字列 |
formattedText.Append(text) |
HTMLに含める |
formattedText.AppendLine(text) |
HTMLに含める |
formattedText.FontSize = 12 |
CSS font-size: 12pt |
formattedText.Font = ... |
CSS font-family: ... |
page.Content.DrawText(text, point) |
renderer.RenderHtmlAsPdf(html) |
page.Content.GetText() |
pdf.ExtractTextFromPage(i) |
コード移行の例
例1: HTMLからPDFへの変換
前(GemBox.Pdf)—GemBox.Pdfではサポートされていません; 別のGemBox.Document SKUが必要です:
// NuGet: Install-Package GemBox.Document
// NOTE: GemBox.Pdf does NOT support HTML-to-PDF. PdfDocument.Load only opens
// existing PDF files. To convert HTML to PDF you must use the separate
// GemBox.Document product (different SKU, different license).
using GemBox.Document;
class Program
{
static void Main()
{
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// GemBox.Document loads HTML and saves as PDF.
var document = DocumentModel.Load("input.html");
document.Save("output.pdf");
}
}
// NuGet: Install-Package GemBox.Document
// NOTE: GemBox.Pdf does NOT support HTML-to-PDF. PdfDocument.Load only opens
// existing PDF files. To convert HTML to PDF you must use the separate
// GemBox.Document product (different SKU, different license).
using GemBox.Document;
class Program
{
static void Main()
{
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// GemBox.Document loads HTML and saves as PDF.
var document = DocumentModel.Load("input.html");
document.Save("output.pdf");
}
}
Imports GemBox.Document
Module Program
Sub Main()
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
' GemBox.Document loads HTML and saves as PDF.
Dim document = DocumentModel.Load("input.html")
document.Save("output.pdf")
End Sub
End Module
翻訳後(IronPDF):。
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
pdf.SaveAs("output.pdf")
End Sub
End Class
IronPDFのChromePdfRendererは、HTML/CSS/JavaScriptレンダリングにモダンなChromiumエンジンを使用しているため、1つのNuGetパッケージでHTMLからPDFへの変換が直接カバーされ、別のSKUは必要ありません。 レンダリングオプションについては、HTML to PDF documentationを参照してください。
例2: PDFファイルをマージする
前(GemBox.Pdf):
// NuGet: Install-Package GemBox.Pdf
using GemBox.Pdf;
using System.Linq;
class Program
{
static void Main()
{
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var source1 = PdfDocument.Load("document1.pdf");
var source2 = PdfDocument.Load("document2.pdf");
document.Pages.AddClone(source1.Pages);
document.Pages.AddClone(source2.Pages);
document.Save("merged.pdf");
}
}
}
// NuGet: Install-Package GemBox.Pdf
using GemBox.Pdf;
using System.Linq;
class Program
{
static void Main()
{
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var source1 = PdfDocument.Load("document1.pdf");
var source2 = PdfDocument.Load("document2.pdf");
document.Pages.AddClone(source1.Pages);
document.Pages.AddClone(source2.Pages);
document.Save("merged.pdf");
}
}
}
Imports GemBox.Pdf
Imports System.Linq
Module Program
Sub Main()
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Using document As New PdfDocument()
Dim source1 = PdfDocument.Load("document1.pdf")
Dim source2 = PdfDocument.Load("document2.pdf")
document.Pages.AddClone(source1.Pages)
document.Pages.AddClone(source2.Pages)
document.Save("merged.pdf")
End Using
End Sub
End Module
翻訳後(IronPDF):。
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("merged.pdf")
End Sub
End Class
IronPDFの静的Mergeメソッドは操作を簡素化します—空のドキュメントを作成してページを個別にクローンする必要はありません。 PDFのマージと分割については、こちらをご覧ください。
例3: PDFにテキストを追加する
前(GemBox.Pdf):
// NuGet: Install-Package GemBox.Pdf
using GemBox.Pdf;
using GemBox.Pdf.Content;
class Program
{
static void Main()
{
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var page = document.Pages.Add();
// PdfFormattedText has no Text property; use Append/AppendLine.
var formattedText = new PdfFormattedText();
formattedText.FontSize = 24;
formattedText.Append("Hello World");
page.Content.DrawText(formattedText, new PdfPoint(100, 700));
document.Save("output.pdf");
}
}
}
// NuGet: Install-Package GemBox.Pdf
using GemBox.Pdf;
using GemBox.Pdf.Content;
class Program
{
static void Main()
{
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var page = document.Pages.Add();
// PdfFormattedText has no Text property; use Append/AppendLine.
var formattedText = new PdfFormattedText();
formattedText.FontSize = 24;
formattedText.Append("Hello World");
page.Content.DrawText(formattedText, new PdfPoint(100, 700));
document.Save("output.pdf");
}
}
}
Imports GemBox.Pdf
Imports GemBox.Pdf.Content
Module Program
Sub Main()
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Using document As New PdfDocument()
Dim page = document.Pages.Add()
' PdfFormattedText has no Text property; use Append/AppendLine.
Dim formattedText As New PdfFormattedText()
formattedText.FontSize = 24
formattedText.Append("Hello World")
page.Content.DrawText(formattedText, New PdfPoint(100, 700))
document.Save("output.pdf")
End Using
End Sub
End Module
翻訳後(IronPDF):。
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<p>Original Content</p>");
var stamper = new TextStamper()
{
Text = "Hello World",
FontSize = 24,
HorizontalOffset = 100,
VerticalOffset = 700
};
pdf.ApplyStamp(stamper);
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<p>Original Content</p>");
var stamper = new TextStamper()
{
Text = "Hello World",
FontSize = 24,
HorizontalOffset = 100,
VerticalOffset = 700
};
pdf.ApplyStamp(stamper);
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Imports IronPdf.Editing
Class Program
Shared Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<p>Original Content</p>")
Dim stamper = New TextStamper() With {
.Text = "Hello World",
.FontSize = 24,
.HorizontalOffset = 100,
.VerticalOffset = 700
}
pdf.ApplyStamp(stamper)
pdf.SaveAs("output.pdf")
End Sub
End Class
既存のPDFにテキストを追加するために、IronPDFは正確な位置制御を提供するTextStamperクラスを提供しています。 新しいドキュメントの場合は、HTMLテンプレートにテキストを含めるだけです。 追加オプションについては、スタンプのドキュメントを参照してください。
例4: テーブルの作成 (最大の改善点!)
前(GemBox.Pdf)—フリーモードでは2ページに制限された座標ベースのレイアウト:
using GemBox.Pdf;
using GemBox.Pdf.Content;
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var page = document.Pages.Add();
double y = 700;
double[] xPositions = { 50, 200, 300, 400 };
// Headers
var headers = new[] { "Product", "Price", "Qty", "Total" };
for (int i = 0; i < headers.Length; i++)
{
var text = new PdfFormattedText();
text.FontSize = 12;
text.Append(headers[i]);
page.Content.DrawText(text, new PdfPoint(xPositions[i], y));
}
y -= 20;
// Data rows — each row requires manual Y advancement,
// and free mode caps the saved file at 2 pages total.
document.Save("products.pdf");
}
using GemBox.Pdf;
using GemBox.Pdf.Content;
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
var page = document.Pages.Add();
double y = 700;
double[] xPositions = { 50, 200, 300, 400 };
// Headers
var headers = new[] { "Product", "Price", "Qty", "Total" };
for (int i = 0; i < headers.Length; i++)
{
var text = new PdfFormattedText();
text.FontSize = 12;
text.Append(headers[i]);
page.Content.DrawText(text, new PdfPoint(xPositions[i], y));
}
y -= 20;
// Data rows — each row requires manual Y advancement,
// and free mode caps the saved file at 2 pages total.
document.Save("products.pdf");
}
Imports GemBox.Pdf
Imports GemBox.Pdf.Content
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Using document As New PdfDocument()
Dim page = document.Pages.Add()
Dim y As Double = 700
Dim xPositions As Double() = {50, 200, 300, 400}
' Headers
Dim headers = New String() {"Product", "Price", "Qty", "Total"}
For i As Integer = 0 To headers.Length - 1
Dim text As New PdfFormattedText()
text.FontSize = 12
text.Append(headers(i))
page.Content.DrawText(text, New PdfPoint(xPositions(i), y))
Next
y -= 20
' Data rows — each row requires manual Y advancement,
' and free mode caps the saved file at 2 pages total.
document.Save("products.pdf")
End Using
後(IronPDF)—ページ制限なし、適切なHTMLテーブル:
using IronPdf;
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var html = @"
<html>
<head>
<style>
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #4CAF50; color: white; }
tr:nth-child(even) { background-color: #f2f2f2; }
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Product</th>
<th>Price</th>
<th>Qty</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr><td>Widget A</td><td>$19.99</td><td>5</td><td>$99.95</td></tr>
<tr><td>Widget B</td><td>$29.99</td><td>3</td><td>$89.97</td></tr>
</tbody>
</table>
</body>
</html>";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("products.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var html = @"
<html>
<head>
<style>
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #4CAF50; color: white; }
tr:nth-child(even) { background-color: #f2f2f2; }
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Product</th>
<th>Price</th>
<th>Qty</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr><td>Widget A</td><td>$19.99</td><td>5</td><td>$99.95</td></tr>
<tr><td>Widget B</td><td>$29.99</td><td>3</td><td>$89.97</td></tr>
</tbody>
</table>
</body>
</html>";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("products.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim html As String = "
<html>
<head>
<style>
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #4CAF50; color: white; }
tr:nth-child(even) { background-color: #f2f2f2; }
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Product</th>
<th>Price</th>
<th>Qty</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr><td>Widget A</td><td>$19.99</td><td>5</td><td>$99.95</td></tr>
<tr><td>Widget B</td><td>$29.99</td><td>3</td><td>$89.97</td></tr>
</tbody>
</table>
</body>
</html>"
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("products.pdf")
これはGemBox.Pdfの移行における最も重要な改善です。 フリーモードのGemBox.Pdfドキュメントを2ページ制限を超えてレンダリングするテーブルは、IronPDFでその制限なしにCSSスタイリングサポートでレンダリングされます。
重要な移行に関する注意事項
CSSポジショニングへの調整
ピクセルパーフェクトのポジショニング(GemBox.Pdfの座標系に似ている)を必要とする場合、CSS絶対ポジショニングを使用してください:
<div style="position:absolute; left:50px; top:750px; font-size:24px;">
Text positioned at specific coordinates
</div>
<div style="position:absolute; left:50px; top:750px; font-size:24px;">
Text positioned at specific coordinates
</div>
ページ索引
GemBox.PdfとIronPDFのどちらも0インデックスのページを使用しているため、この移行の側面は簡単です:
// GemBox.Pdf
var page = document.Pages[0];
// IronPDF
var page = pdf.Pages[0];
// GemBox.Pdf
var page = document.Pages[0];
// IronPDF
var page = pdf.Pages[0];
' GemBox.Pdf
Dim page = document.Pages(0)
' IronPDF
Dim page = pdf.Pages(0)
セキュリティ設定
// GemBox.Pdf
var encryption = document.SaveOptions.SetPasswordEncryption();
encryption.DocumentOpenPassword = "userPassword";
encryption.PermissionsPassword = "ownerPassword";
// IronPDF
pdf.SecuritySettings.UserPassword = "userPassword";
pdf.SecuritySettings.OwnerPassword = "ownerPassword";
// GemBox.Pdf
var encryption = document.SaveOptions.SetPasswordEncryption();
encryption.DocumentOpenPassword = "userPassword";
encryption.PermissionsPassword = "ownerPassword";
// IronPDF
pdf.SecuritySettings.UserPassword = "userPassword";
pdf.SecuritySettings.OwnerPassword = "ownerPassword";
' GemBox.Pdf
Dim encryption = document.SaveOptions.SetPasswordEncryption()
encryption.DocumentOpenPassword = "userPassword"
encryption.PermissionsPassword = "ownerPassword"
' IronPDF
pdf.SecuritySettings.UserPassword = "userPassword"
pdf.SecuritySettings.OwnerPassword = "ownerPassword"
トラブルシューティング
問題 1: PdfFormattedText が見つかりません
問題: IronPDFにはPdfFormattedTextが存在しません。
解決策: CSS スタイルを使用した HTML を使用する:
// GemBox.Pdf
var text = new PdfFormattedText();
text.FontSize = 24;
text.Append("Hello");
// IronPDF
var html = "<p style='font-size:24px;'>Hello</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
// GemBox.Pdf
var text = new PdfFormattedText();
text.FontSize = 24;
text.Append("Hello");
// IronPDF
var html = "<p style='font-size:24px;'>Hello</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
Imports GemBox.Pdf
Imports IronPDF
Dim text As New PdfFormattedText()
text.FontSize = 24
text.Append("Hello")
Dim html As String = "<p style='font-size:24px;'>Hello</p>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
問題 2: DrawText メソッドが見つかりません
問題: page.Content.DrawText()は利用できません。
解決策: HTML レンダリングでコンテンツを作成するか、スタンパーを使用します。
// For new documents - render HTML
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Content</h1>");
// For existing documents - use stampers
var stamper = new TextStamper() { Text = "Added Text" };
pdf.ApplyStamp(stamper);
// For new documents - render HTML
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Content</h1>");
// For existing documents - use stampers
var stamper = new TextStamper() { Text = "Added Text" };
pdf.ApplyStamp(stamper);
Imports System
' For new documents - render HTML
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Content</h1>")
' For existing documents - use stampers
Dim stamper As New TextStamper() With {.Text = "Added Text"}
pdf.ApplyStamp(stamper)
課題3:ドキュメントの読み込みの違い
問題: PdfDocument.Load()が見つかりません。
解決策: FromStream()を使用します:
// GemBox.Pdf
var doc = PdfDocument.Load("input.pdf");
// IronPDF
var pdf = PdfDocument.FromFile("input.pdf");
// GemBox.Pdf
var doc = PdfDocument.Load("input.pdf");
// IronPDF
var pdf = PdfDocument.FromFile("input.pdf");
Imports GemBox.Pdf
Imports IronPdf
Dim doc = PdfDocument.Load("input.pdf")
Dim pdf = PdfDocument.FromFile("input.pdf")
課題4:保存メソッドの違い
問題: document.Save()メソッドのシグネチャが異なります。
解決策: SaveAs()を使用してください:
// GemBox.Pdf
document.Save("output.pdf");
// IronPDF
pdf.SaveAs("output.pdf");
// GemBox.Pdf
document.Save("output.pdf");
// IronPDF
pdf.SaveAs("output.pdf");
移行チェックリスト
移行前
- コードベース内のすべてのGemBox.Pdfの使用をインベントリします
- HTML 変換が必要な座標ベースのレイアウトを識別する
- どこで2ページのフリーモード制限がコードに影響を与えるかを評価します
- IronPDFライセンスキーを取得する
- バージョン管理に移行ブランチを作成する
コードの移行
- GemBox.PdfのNuGetパッケージを削除します:
dotnet remove package GemBox.Pdf - IronPDFのNuGetパッケージをインストールします:
dotnet add package IronPdf - 名前空間のインポートを更新する
IronPdf.License.LicenseKeyに置き換えますPdfDocument.FromFile()に変換しますpdf.SaveAs()に変換します- 座標ベースのテキストをHTMLコンテンツに置き換える
PdfFormattedTextをCSSスタイリングを使用してHTMLに変換します- マージ操作を
PdfDocument.Merge()を使用するように更新します
テスティング
- すべてのドキュメントが正しく生成されたことを確認する
- ドキュメントの外観が期待どおりであることを検証する
- マルチページ出力をテストします(以前はフリーモードで2ページに制限されていました)
- テキスト抽出が正しく機能していることを確認する
- マージと分割操作をテストする
- セキュリティ/暗号化機能の検証
移行後
- GemBox.Pdfライセンスキーを削除します
- ドキュメントの更新
- PDF の HTML/CSS アプローチについてチームをトレーニングする
- フリーモード制限なしに無制限のページカウントを楽しんでください!

