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

ChromeでHTMLをデバッグしてピクセルパーフェクトなPDFを作成する方法

iTextからIronPDFへの移行は、プログラムAPI(コード内でCellオブジェクトを構築する)から、CSS3とJavaScriptサポートを備えたHTMLファーストの手法へと、.NET PDFワークフローを移行します。 このガイドは、AGPLの暴露を取り除き、別のpdfHTMLアドオンを必要としないステップバイステップの移行パスを提供します。

なぜiTextからIronPDFに移行するのか

AGPLライセンスの考慮

iText(iText Group / Apryse Group NVが所有)は、商用チームがあらかじめ考慮すべきライセンス特性を備えています:

  1. AGPLウイルスライセンス: iTextをオープンソースライセンスでウェブアプリケーションで使用する場合、AGPLは通常、そのネットワークを介してアプリケーションと対話する誰にでもソースを公開することを求めると解釈されます。 クローズドソースの商用ソフトウェアの場合、通常は商用ライセンスの購入が必要です。

  2. サブスクリプションのみの商用ライセンス: iTextの商用ライセンスは、PDF処理量に基づいた年間サブスクリプションとして販売されています; 永続オプションは公開価格ページには掲載されていません(カスタムOEM条件は見積のみです)。

  3. pdfHTML追加の費用: HTMLからPDFへの変換には、itextパッケージ(現在バージョン9.6.0)の上で別売りされています。

  4. 複雑なライセンス監査: エンタープライズ展開はライセンスの複雑さと監査リスクに直面します。

  5. プログラムファーストAPI: コアイテキストは、コード内でCellオブジェクトを構成してPDFを作成します。 pdfHTMLはHTMLから始めることを可能にします。

  6. 定義されたCSSサブセット、レンダリング時のJSなし: pdfHTMLはCSSの定義されたサブセットをサポートしており、HTMLをPDFに変換する際にJavaScriptは実行されません(PDFレベルのJSフォームアクションは別途サポートされた機能です)。

iTextとIronPDFの比較

フィーチャー iText 9 / iTextSharp 5.x IronPDF
ライセンス AGPL(ウイルス)または商用の年次サブスクリプション 商用、永久オプション
HTMLからPDFへ 別売りのitext.pdfhtml追加(6.3.2) 内蔵Chromiumレンダラー
CSSサポート pdfHTMLでの定義済みCSSサブセット フルCSS3、フレックスボックス、グリッド
レンダリング時 for JavaScript pdfHTMLはHTML→PDF変換時にJSを実行しません レンダリング時の完全なJS実行
APIパラダイム プログラム(段落、表、セル) CSSによるHTMLファースト
学習曲線 スティープ(PDF座標系) ウェブ開発者フレンドリー
オープンソースリスク AGPLの下でオープンソースのウェブアプリケーションを提供すること。 ウイルス要件なし
価格モデル 年間サブスクリプション(ボリュームベース)またはカスタムOEM 永久またはサブスクリプション

最新 for .NETに標準化するチームにとって、IronPDFのHTMLファーストアプローチは、既に持っているウェブ開発スキルを活用します。


マイグレーションの複雑さの評価

機能別の見積もり作業

フィーチャー 移行の複雑さ
HTMLからPDFへ 低レベル
PDFのマージ 低レベル
テキストと画像 低レベル
中規模
ヘッダー/フッター 中規模
セキュリティ/暗号化 低レベル

パラダイムシフト

この iText 移行における基本的な変化は、プログラムによる PDF 構築からHTML ファーストのレンダリングへの変化です。

iText:    PdfWriter → PdfDocument → Document → Add(Paragraph) → Add(Table)
IronPDF:  ChromePdfRenderer → RenderHtmlAsPdf(htmlString) → SaveAs()

iTextのオブジェクトモデルを学ぶ代わりに、ウェブ開発者がすでに持っている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からライセンスキーを取得します。

NuGetパッケージの変更

# Remove iText packages (current naming is 'itext'; 'itext7' is the deprecated alias)
dotnet remove package itext
dotnet remove package itext.pdfhtml
dotnet remove package itext7
dotnet remove package itext7.pdfhtml
dotnet remove package itextsharp

# Install IronPDF
dotnet add package IronPdf
# Remove iText packages (current naming is 'itext'; 'itext7' is the deprecated alias)
dotnet remove package itext
dotnet remove package itext.pdfhtml
dotnet remove package itext7
dotnet remove package itext7.pdfhtml
dotnet remove package itextsharp

# Install IronPDF
dotnet add package IronPdf
SHELL

ライセンス構成

// 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

iTextの使用方法を確認する

# Find all iText references
grep -r "using iText\|using iTextSharp" --include="*.cs" .
grep -r "PdfWriter\|PdfDocument\|Document\|Paragraph\|Table\|Cell" --include="*.cs" .
grep -r "HtmlConverter\|ConverterProperties" --include="*.cs" .
# Find all iText references
grep -r "using iText\|using iTextSharp" --include="*.cs" .
grep -r "PdfWriter\|PdfDocument\|Document\|Paragraph\|Table\|Cell" --include="*.cs" .
grep -r "HtmlConverter\|ConverterProperties" --include="*.cs" .
SHELL

完全な API リファレンス

クラスマッピング

iText 7+ クラス iTextSharp 5.x クラス IronPDF 同等物
PdfWriter PdfWriter ChromePdfRenderer
PdfDocument Document PdfDocument
Document Document ChromePdfRenderer.RenderHtmlAsPdf()
Paragraph Paragraph HTML <h1>など
Table PdfPTable HTML <table>
Cell PdfPCell HTML <th>
Image Image HTML <img>
PdfReader PdfReader PdfDocument.FromFile()
PdfMerger 該当なし PdfDocument.Merge()

名前空間マッピング

iTextネームスペース IronPDF 同等物
iText.Kernel.Pdf IronPdf
iText.Layout IronPdf
iText.Layout.Element HTML要素の使用
iText.Html2pdf IronPdf(ビルトイン)
iText.IO.Image HTML <img>を使用する
iText.Kernel.Utils IronPdf

コード移行の例

例1: HTMLからPDFへの変換

Before (iText):

// NuGet: Install-Package itext7
using iText.Html2pdf;
using System.IO;

class Program
{
    static void Main()
    {
        string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";
        string outputPath = "output.pdf";

        using (FileStream fs = new FileStream(outputPath, FileMode.Create))
        {
            HtmlConverter.ConvertToPdf(html, fs);
        }
    }
}
// NuGet: Install-Package itext7
using iText.Html2pdf;
using System.IO;

class Program
{
    static void Main()
    {
        string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";
        string outputPath = "output.pdf";

        using (FileStream fs = new FileStream(outputPath, FileMode.Create))
        {
            HtmlConverter.ConvertToPdf(html, fs);
        }
    }
}
Imports iText.Html2pdf
Imports System.IO

Class Program
    Shared Sub Main()
        Dim html As String = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>"
        Dim outputPath As String = "output.pdf"

        Using fs As FileStream = New FileStream(outputPath, FileMode.Create)
            HtmlConverter.ConvertToPdf(html, fs)
        End Using
    End Sub
End Class
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim html As String = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>"

        Dim pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

iTextのアプローチは、別売りのitext 9.6.0の上に別売り)を必要とし、環境を整えるためにusingステートメントでラップします。 HtmlConverter.ConvertToPdf()メソッドは直接ストリームに書き込みます。

IronPDFのアプローチはよりクリーンです:SaveAs()を呼び出します。 別パッケージ、ストリーム管理は不要で、Chromiumレンダリングエンジンは優れたCSS3とJavaScriptをサポートします。 その他のレンダリングオプションについては、HTML to PDF documentationを参照してください。

例2: 複数のPDFをマージする

Before (iText):

// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Kernel.Utils;
using System.IO;

class Program
{
    static void Main()
    {
        string outputPath = "merged.pdf";
        string[] inputFiles = { "document1.pdf", "document2.pdf", "document3.pdf" };

        using (PdfWriter writer = new PdfWriter(outputPath))
        using (PdfDocument pdfDoc = new PdfDocument(writer))
        {
            PdfMerger merger = new PdfMerger(pdfDoc);

            foreach (string file in inputFiles)
            {
                using (PdfDocument sourcePdf = new PdfDocument(new PdfReader(file)))
                {
                    merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages());
                }
            }
        }
    }
}
// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Kernel.Utils;
using System.IO;

class Program
{
    static void Main()
    {
        string outputPath = "merged.pdf";
        string[] inputFiles = { "document1.pdf", "document2.pdf", "document3.pdf" };

        using (PdfWriter writer = new PdfWriter(outputPath))
        using (PdfDocument pdfDoc = new PdfDocument(writer))
        {
            PdfMerger merger = new PdfMerger(pdfDoc);

            foreach (string file in inputFiles)
            {
                using (PdfDocument sourcePdf = new PdfDocument(new PdfReader(file)))
                {
                    merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages());
                }
            }
        }
    }
}
Imports iText.Kernel.Pdf
Imports iText.Kernel.Utils
Imports System.IO

Class Program
    Shared Sub Main()
        Dim outputPath As String = "merged.pdf"
        Dim inputFiles As String() = {"document1.pdf", "document2.pdf", "document3.pdf"}

        Using writer As New PdfWriter(outputPath)
            Using pdfDoc As New PdfDocument(writer)
                Dim merger As New PdfMerger(pdfDoc)

                For Each file As String In inputFiles
                    Using sourcePdf As New PdfDocument(New PdfReader(file))
                        merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages())
                    End Using
                Next
            End Using
        End Using
    End Sub
End Class
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

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

class Program
{
    static void Main()
    {
        var pdfDocuments = new List<PdfDocument>
        {
            PdfDocument.FromFile("document1.pdf"),
            PdfDocument.FromFile("document2.pdf"),
            PdfDocument.FromFile("document3.pdf")
        };

        var merged = PdfDocument.Merge(pdfDocuments);
        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdfDocuments = new List<PdfDocument>
        {
            PdfDocument.FromFile("document1.pdf"),
            PdfDocument.FromFile("document2.pdf"),
            PdfDocument.FromFile("document3.pdf")
        };

        var merged = PdfDocument.Merge(pdfDocuments);
        merged.SaveAs("merged.pdf");
    }
}
Imports IronPdf
Imports System.Collections.Generic

Class Program
    Shared Sub Main()
        Dim pdfDocuments As New List(Of PdfDocument) From {
            PdfDocument.FromFile("document1.pdf"),
            PdfDocument.FromFile("document2.pdf"),
            PdfDocument.FromFile("document3.pdf")
        }

        Dim merged = PdfDocument.Merge(pdfDocuments)
        merged.SaveAs("merged.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

iTextのマージ操作には、かなりのボイラープレートが必要です。出力のためにusingステートメントでソースファイルを反復します。 また、merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages())でページ範囲を指定する必要があります。

IronPDFでは、これを3つのステップに簡略化します:PdfDocument.Merge()メソッドを呼び出し、保存します。 マージ作業全体が読みやすく、保守しやすくなります。 PDFのマージと分割については、こちらをご覧ください。

例3: テキストと画像でPDFを作成する

Before (iText):

// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.IO.Image;

class Program
{
    static void Main()
    {
        string outputPath = "document.pdf";

        using (PdfWriter writer = new PdfWriter(outputPath))
        using (PdfDocument pdf = new PdfDocument(writer))
        using (Document document = new Document(pdf))
        {
            document.Add(new Paragraph("Sample PDF Document"));
            document.Add(new Paragraph("This document contains text and an image."));

            Image img = new Image(ImageDataFactory.Create("image.jpg"));
            img.SetWidth(200);
            document.Add(img);
        }
    }
}
// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.IO.Image;

class Program
{
    static void Main()
    {
        string outputPath = "document.pdf";

        using (PdfWriter writer = new PdfWriter(outputPath))
        using (PdfDocument pdf = new PdfDocument(writer))
        using (Document document = new Document(pdf))
        {
            document.Add(new Paragraph("Sample PDF Document"));
            document.Add(new Paragraph("This document contains text and an image."));

            Image img = new Image(ImageDataFactory.Create("image.jpg"));
            img.SetWidth(200);
            document.Add(img);
        }
    }
}
Imports iText.Kernel.Pdf
Imports iText.Layout
Imports iText.Layout.Element
Imports iText.IO.Image

Class Program
    Shared Sub Main()
        Dim outputPath As String = "document.pdf"

        Using writer As New PdfWriter(outputPath),
              pdf As New PdfDocument(writer),
              document As New Document(pdf)

            document.Add(New Paragraph("Sample PDF Document"))
            document.Add(New Paragraph("This document contains text and an image."))

            Dim img As New Image(ImageDataFactory.Create("image.jpg"))
            img.SetWidth(200)
            document.Add(img)
        End Using
    End Sub
End Class
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;

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

        string html = @"
            <h1>Sample PDF Document</h1>
            <p>This document contains text and an image.</p>
            <img src='image.jpg' width='200' />";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("document.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

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

        string html = @"
            <h1>Sample PDF Document</h1>
            <p>This document contains text and an image.</p>
            <img src='image.jpg' width='200' />";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("document.pdf");
    }
}
Imports IronPdf

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

        Dim html As String = "
            <h1>Sample PDF Document</h1>
            <p>This document contains text and an image.</p>
            <img src='image.jpg' width='200' />"

        Dim pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs("document.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

この例は、パラダイムシフトを最も明確に示しています。 iTextが必要です:

  • トリプルネストされたDocument
  • Paragraphオブジェクトを作成
  • ImageDataFactory.Create()を使用して画像を読み込む
  • SetWidth()を別々に呼び出し
  • 各要素に対してdocument.Add()を呼び出す

IronPDFは標準のHTMLを使用します:見出しに<img> ウェブ開発者は既存のスキルをすぐに活用でき、デザイナーはすでに知っているCSSを使ってドキュメントをスタイリングできます。


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

パラダイムシフト:プログラムからHTMLファーストへ

このiTextの移行で最も大きな変更は、概念的なものです。 iTextはプログラムでPDFを作成します:

// iText approach
document.Add(new Paragraph("Title")
    .SetTextAlignment(TextAlignment.CENTER)
    .SetFontSize(24)
    .SetBold());

var table = new Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth();
table.AddHeaderCell(new Cell().Add(new Paragraph("ID")));
table.AddHeaderCell(new Cell().Add(new Paragraph("Name")));
// ... many more lines
// iText approach
document.Add(new Paragraph("Title")
    .SetTextAlignment(TextAlignment.CENTER)
    .SetFontSize(24)
    .SetBold());

var table = new Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth();
table.AddHeaderCell(new Cell().Add(new Paragraph("ID")));
table.AddHeaderCell(new Cell().Add(new Paragraph("Name")));
// ... many more lines
' iText approach
document.Add(New Paragraph("Title") _
    .SetTextAlignment(TextAlignment.CENTER) _
    .SetFontSize(24) _
    .SetBold())

Dim table = New Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth()
table.AddHeaderCell(New Cell().Add(New Paragraph("ID")))
table.AddHeaderCell(New Cell().Add(New Paragraph("Name")))
' ... many more lines
$vbLabelText   $csharpLabel

IronPDFはHTMLとCSSを使用しています:

//IronPDFapproach
string html = @"
    <style>
        h1 { text-align: center; font-size: 24px; font-weight: bold; }
        table { width: 100%; border-collapse: collapse; }
        th { background-color: #4CAF50; color: white; padding: 8px; }
    </style>
    <h1>Title</h1>
    <table>
        <tr><th>ID</th><th>Name</th></tr>
    </table>";

var pdf = renderer.RenderHtmlAsPdf(html);
//IronPDFapproach
string html = @"
    <style>
        h1 { text-align: center; font-size: 24px; font-weight: bold; }
        table { width: 100%; border-collapse: collapse; }
        th { background-color: #4CAF50; color: white; padding: 8px; }
    </style>
    <h1>Title</h1>
    <table>
        <tr><th>ID</th><th>Name</th></tr>
    </table>";

var pdf = renderer.RenderHtmlAsPdf(html);
'IronPDFapproach
Dim html As String = "
    <style>
        h1 { text-align: center; font-size: 24px; font-weight: bold; }
        table { width: 100%; border-collapse: collapse; }
        th { background-color: #4CAF50; color: white; padding: 8px; }
    </style>
    <h1>Title</h1>
    <table>
        <tr><th>ID</th><th>Name</th></tr>
    </table>"

Dim pdf = renderer.RenderHtmlAsPdf(html)
$vbLabelText   $csharpLabel

AGPLの暴露を排除

iTextのAGPL条件下では、iTextを使用するウェブアプリケーションは通常、そのネットワークを介してアプリケーションと対話する人にソースを公開することが期待されます; 商用ライセンスが代替パスです。 IronPDFの商用ライセンスにより、ウイルスライセンス要件なしにプロプライエタリなソフトウェアに導入することができます。

pdfHTMLアドオンは必要ありません

iTextは、HTMLからPDFへの変換のために別売りのitextパッケージの上で販売されています。 IronPDFはベースパッケージにChromiumベースのHTMLレンダリングを含んでいます。

メソッド置換パターン

iTextパターン IronPDFの置き換え
SetTextAlignment(TextAlignment.CENTER) CSS text-align: center
SetFontSize(24) CSS font-size: 24px
SetBold() CSS font-weight: bold
new Table(3) HTML <table>
AddHeaderCell(new Cell().Add(new Paragraph())) HTML <th>
AddCell(new Cell().Add(new Paragraph())) HTML <td>

トラブルシューティング

問題 1: PdfWriter/Document パターン

問題: コードはPdfWriterPdfDocumentDocumentというネストパターンを使用しています。

解決策: ChromePdfRendererに置き換えます。

// Delete this iText pattern:
// using (var writer = new PdfWriter(outputPath))
// using (var pdfDoc = new PdfDocument(writer))
// using (var document = new Document(pdfDoc))

// Replace with:
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(outputPath);
// Delete this iText pattern:
// using (var writer = new PdfWriter(outputPath))
// using (var pdfDoc = new PdfDocument(writer))
// using (var document = new Document(pdfDoc))

// Replace with:
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(outputPath);
Imports IronPdf

Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs(outputPath)
$vbLabelText   $csharpLabel

課題2:HtmlConverterが見つかりません

問題: コードはitext.pdfhtml追加に含まれています。

解決策:IronPDFの組み込み HTML レンダリングを使用します。

// iText (requires pdfHTML add-on)
HtmlConverter.ConvertToPdf(html, fileStream);

//IronPDF(built-in)
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(outputPath);
// iText (requires pdfHTML add-on)
HtmlConverter.ConvertToPdf(html, fileStream);

//IronPDF(built-in)
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(outputPath);
' iText (requires pdfHTML add-on)
HtmlConverter.ConvertToPdf(html, fileStream)

' IronPDF(built-in)
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs(outputPath)
$vbLabelText   $csharpLabel

問題 3: PdfMerger の複雑さ

問題: iTextのPdfMergerはネストされたリーダーとページ範囲の指定を必要とします。

解決策:IronPDFの静的マージメソッドを使用します。

// iText merger pattern (delete this)
// using (PdfDocument pdfDoc = new PdfDocument(writer))
// {
//     PdfMerger merger = new PdfMerger(pdfDoc);
//     foreach (string file in inputFiles)
//     {
//         using (PdfDocument sourcePdf = new PdfDocument(new PdfReader(file)))
//         {
//             merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages());
//         }
//     }
// }

//IronPDF(simple)
var merged = PdfDocument.Merge(pdfDocuments);
merged.SaveAs("merged.pdf");
// iText merger pattern (delete this)
// using (PdfDocument pdfDoc = new PdfDocument(writer))
// {
//     PdfMerger merger = new PdfMerger(pdfDoc);
//     foreach (string file in inputFiles)
//     {
//         using (PdfDocument sourcePdf = new PdfDocument(new PdfReader(file)))
//         {
//             merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages());
//         }
//     }
// }

//IronPDF(simple)
var merged = PdfDocument.Merge(pdfDocuments);
merged.SaveAs("merged.pdf");
Imports System.Collections.Generic

' iText merger pattern (delete this)
' Using pdfDoc As New PdfDocument(writer)
'     Dim merger As New PdfMerger(pdfDoc)
'     For Each file As String In inputFiles
'         Using sourcePdf As New PdfDocument(New PdfReader(file))
'             merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages())
'         End Using
'     Next
' End Using

' IronPDF(simple)
Dim merged = PdfDocument.Merge(pdfDocuments)
merged.SaveAs("merged.pdf")
$vbLabelText   $csharpLabel

移行チェックリスト

移行前

  • コードベース内のすべての iText API 呼び出しをインベントリする
  • プログラムによる PDF 構築パターン (段落、表、セル) を識別する
  • ドキュメント HtmlConverter の使用法 (pdfHTML アドオン)
  • AGPLコンプライアンスリスクを評価する
  • IronPDFライセンスキーを取得する

コードの移行

  • iText NuGetパッケージを削除します:itext.pdfhtml / iTextSharpが存在する場合) -IronPDFNuGetパッケージをインストールします:dotnet add package IronPdf
  • 名前空間のインポートを更新します(using iText.*using IronPdf
  • ChromePdfRendererに置き換えます
  • CellをHTML要素に変換します
  • RenderHtmlAsPdf()で置き換えます
  • マージ操作をPdfDocument.Merge()に更新します
  • 起動時にライセンスキーの初期化を追加

テスティング

  • すべてのPDF生成パスをテストする
  • 視覚的な出力が期待通りであることを確認する
  • 複雑なHTML/CSSコンテンツでテストする
  • ベンチマークパフォーマンス

移行後

  • iTextのライセンスファイルと参照を削除します
  • ドキュメントの更新
  • iTextサブスクリプションをキャンセルする(該当する場合)
  • レガシー iText コードをアーカイブする

[[i: (iTextはその所有者の登録商標です。 本サイトは、iText Groupと提携しているわけでも、iText Groupが推奨しているわけでも、iText Groupがスポンサーしているわけでもありません。すべての製品名、ロゴ、ブランドは、それぞれの所有者に帰属します。 比較は情報提供のみを目的としており、執筆時点で公開されている情報を反映しています。)]]

Curtis Chau
テクニカルライター

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

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

アイアンサポートチーム

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