.NET 8用ドキュメント生成ライブラリの選択
.NET 8では、従来のPDFライブラリの多くとの互換性を壊すランタイムの変更が導入されました。 System.Drawing.CommonはWindows以外のプラットフォームでは非推奨となり、Native AOTはリフレクションを多用するライブラリに新たな制約を課し、コンテナファーストのデプロイモデルはWindowsの開発マシンでは表面化しなかった依存性の問題を露呈します。 .NET Frameworkや.NET 6でも動作していたライブラリが、.NET 8ではNU1202、DllNotFoundException、PlatformNotSupportedExceptionエラーで失敗することがあります。
この記事では、どのPDFライブラリが.NET 8で動作するかを文書化し、互換性のないライブラリで遭遇する具体的なエラーを示し、DockerとAzure Functionsのデプロイ設定を提供します。
クイックスタート:.NET 8でHTMLからPDFを生成する
using IronPdf;
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4;
var pdf = renderer.RenderHtmlAsPdf(@"
<html>
<head><style>
body { font-family: 'Segoe UI', sans-serif; padding: 40px; }
h1 { color: #2563eb; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th { background: #2563eb; color: white; padding: 12px; text-align: left; }
td { padding: 10px; border-bottom: 1px solid #e5e7eb; }
</style></head>
<body>
<h1>Q4 Report</h1>
<table>
<tr><th>Metric</th><th>Value</th><th>Change</th></tr>
<tr><td>Revenue</td><td>$1.2M</td><td>+12%</td></tr>
<tr><td>Users</td><td>45,230</td><td>+23%</td></tr>
</table>
</body></html>");
pdf.SaveAs("report.pdf");using IronPdf;
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4;
var pdf = renderer.RenderHtmlAsPdf(@"
<html>
<head><style>
body { font-family: 'Segoe UI', sans-serif; padding: 40px; }
h1 { color: #2563eb; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th { background: #2563eb; color: white; padding: 12px; text-align: left; }
td { padding: 10px; border-bottom: 1px solid #e5e7eb; }
</style></head>
<body>
<h1>Q4 Report</h1>
<table>
<tr><th>Metric</th><th>Value</th><th>Change</th></tr>
<tr><td>Revenue</td><td>$1.2M</td><td>+12%</td></tr>
<tr><td>Users</td><td>45,230</td><td>+23%</td></tr>
</table>
</body></html>");
pdf.SaveAs("report.pdf");Imports IronPdf
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4
Dim pdf = renderer.RenderHtmlAsPdf("
<html>
<head><style>
body { font-family: 'Segoe UI', sans-serif; padding: 40px; }
h1 { color: #2563eb; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th { background: #2563eb; color: white; padding: 12px; text-align: left; }
td { padding: 10px; border-bottom: 1px solid #e5e7eb; }
</style></head>
<body>
<h1>Q4 Report</h1>
<table>
<tr><th>Metric</th><th>Value</th><th>Change</th></tr>
<tr><td>Revenue</td><td>$1.2M</td><td>+12%</td></tr>
<tr><td>Users</td><td>45,230</td><td>+23%</td></tr>
</table>
</body></html>")
pdf.SaveAs("report.pdf")NuGet経由でインストールします:Install-Package IronPdf。 追加設定なしでnet8.0を対象とします。 Windows、Linux、macOS、Docker、Azureに、プラットフォーム固有の設定なしでデプロイできます。
なぜ古い PDF ライブラリは .NET 8 で失敗するのか
iTextSharp - .NET 8 とは互換性がありません。
iTextSharp(iTextのオリジナルの.NET移植版)は2018年以降更新されていません。.NET Frameworkのみを対象としています:
エラーNU1202:iTextSharp 5.5.13パッケージはnet8.0と互換性がありません。移行経路はiText 7ですが、これはAPIが異なり、AGPL準拠(アプリケーション全体をオープンソース化する)か商用ライセンスのどちらかが必要です。 価格は公表されていませんが、サードパーティのデータによると、年間15,000~210,000ドルとなっています。
wkhtmltopdf Wrappers - .NET 8 での DLL ロード失敗
wkhtmltopdfのC#ラッパー(DinkToPdf、Rotativa、NReco.PdfGenerator)は、.NET 8のデプロイメントモデル特有のプラットフォーム固有のエラーで失敗します:
DinkToPdf - ネイティブライブラリが見つかりません:
System.DllNotFoundException:DLL 'libwkhtmltox' をロードできません。Rotativa.AspNetCore - 手動でのバイナリパス設定が必要で、.NET 8のコンテナファーストデプロイメントと競合します:
// This pattern requires deploying wkhtmltopdf binaries alongside your app
// and breaks in Docker containers without explicit path configuration
RotativaConfiguration.Setup(env.WebRootPath, "wkhtmltopdf");// This pattern requires deploying wkhtmltopdf binaries alongside your app
// and breaks in Docker containers without explicit path configuration
RotativaConfiguration.Setup(env.WebRootPath, "wkhtmltopdf");' This pattern requires deploying wkhtmltopdf binaries alongside your app
' and breaks in Docker containers without explicit path configuration
RotativaConfiguration.Setup(env.WebRootPath, "wkhtmltopdf")TuesPechkin / NReco - アーキテクチャの不一致:
System.BadImageFormatException:ファイルまたはアセンブリをロードできませんでしたこれらのエラーは、より深い問題を反映しています。wkhtmltopdfは、パッチが適用されていないCVEで2024年7月にアーカイブされました。 ネイティブ・バイナリ・アーキテクチャは、.NET 8のプラットフォーム検出の改善より前のものです。 修正はありません。別のライブラリへの移行のみです。
PdfSharp - Linux上のSystem.Drawing.Common Failures
PdfSharpはSystem.Drawing.Commonに依存していますが、Microsoftは.NET 6で非Windowsプラットフォーム向けに非推奨としました。.NET 8では、LinuxやDockerにデプロイする際にランタイム障害が発生します:
using PdfSharp.Pdf;
using PdfSharp.Drawing;
var document = new PdfDocument();
// PlatformNotSupportedException on Linux:
// System.Drawing.Common is not supported on this platformusing PdfSharp.Pdf;
using PdfSharp.Drawing;
var document = new PdfDocument();
// PlatformNotSupportedException on Linux:
// System.Drawing.Common is not supported on this platformImports PdfSharp.Pdf
Imports PdfSharp.Drawing
Dim document As New PdfDocument()
' PlatformNotSupportedException on Linux:
' System.Drawing.Common is not supported on this platformPdfSharp 6.xでは、この依存関係を取り除くための取り組みを行っていますが、クロスプラットフォームのサポートは2026年初頭の時点で不完全なままです。Windowsのみのデプロイでは、PdfSharpは.NET 8で動作します。Linux、Docker、またはクラウドデプロイメントでは、信頼できません。
どのPDFライブラリが.NET 8で動作しますか?
IronPDF- .NET 8フルサポート、クロスプラットフォーム
IronPDFはnet8.0をターゲットとしており、Chromiumレンダリングが組み込まれています。 System.Drawing.Commonへの依存、ネイティブのバイナリ管理、プラットフォーム固有の設定はありません。
最小限のAPI統合(.NET 8の主なパターン):
using IronPdf;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/invoice/{id}/pdf", async (int id, InvoiceService service) =>
{
var invoice = await service.GetInvoiceAsync(id);
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(invoice.ToHtml());
return Results.File(pdf.BinaryData, "application/pdf", $"invoice-{id}.pdf");
});
app.Run();using IronPdf;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/invoice/{id}/pdf", async (int id, InvoiceService service) =>
{
var invoice = await service.GetInvoiceAsync(id);
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(invoice.ToHtml());
return Results.File(pdf.BinaryData, "application/pdf", $"invoice-{id}.pdf");
});
app.Run();Imports IronPdf
Dim builder = WebApplication.CreateBuilder(args)
Dim app = builder.Build()
app.MapGet("/invoice/{id}/pdf", Async Function(id As Integer, service As InvoiceService)
Dim invoice = Await service.GetInvoiceAsync(id)
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(invoice.ToHtml())
Return Results.File(pdf.BinaryData, "application/pdf", $"invoice-{id}.pdf")
End Function)
app.Run()RenderHtmlAsPdfは.BinaryDataでバイトに変換できるPdfDocumentを返します。
ライセンス: 749ドルからの永続ライセンス(Lite - 1開発者、1プロジェクト)。 Professional:1,499ドル(開発者10名)。 Enterprise:2,999ドル(無制限)。 ironPdf.comで公開されています。
QuestPDF - .NET 8 互換、HTMLなし
QuestPDFは、プラットフォームに依存することなく、.NET 8で動作します。 その流暢なC# APIは、HTMLパーサーもCSSエンジンもブラウザエンジンも使わずに、プログラムでドキュメントを構築します:
using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
QuestPDF.Settings.License = LicenseType.Community; // Free under $1M revenue
Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
page.Content().Column(col =>
{
col.Item().Text("Q4 Report").FontSize(24).Bold();
col.Item().Table(table =>
{
table.ColumnsDefinition(c => { c.RelativeColumn(2); c.RelativeColumn(1); c.RelativeColumn(1); });
table.Header(h =>
{
h.Cell().Text("Metric").Bold();
h.Cell().Text("Value").Bold();
h.Cell().Text("Change").Bold();
});
table.Cell().Text("Revenue"); table.Cell().Text("$1.2M"); table.Cell().Text("+12%");
table.Cell().Text("Users"); table.Cell().Text("45,230"); table.Cell().Text("+23%");
});
});
});
}).GeneratePdf("report.pdf");using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
QuestPDF.Settings.License = LicenseType.Community; // Free under $1M revenue
Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
page.Content().Column(col =>
{
col.Item().Text("Q4 Report").FontSize(24).Bold();
col.Item().Table(table =>
{
table.ColumnsDefinition(c => { c.RelativeColumn(2); c.RelativeColumn(1); c.RelativeColumn(1); });
table.Header(h =>
{
h.Cell().Text("Metric").Bold();
h.Cell().Text("Value").Bold();
h.Cell().Text("Change").Bold();
});
table.Cell().Text("Revenue"); table.Cell().Text("$1.2M"); table.Cell().Text("+12%");
table.Cell().Text("Users"); table.Cell().Text("45,230"); table.Cell().Text("+23%");
});
});
});
}).GeneratePdf("report.pdf");Imports QuestPDF.Fluent
Imports QuestPDF.Infrastructure
QuestPDF.Settings.License = LicenseType.Community ' Free under $1M revenue
Document.Create(Sub(container)
container.Page(Sub(page)
page.Size(PageSizes.A4)
page.Margin(2, Unit.Centimetre)
page.Content().Column(Sub(col)
col.Item().Text("Q4 Report").FontSize(24).Bold()
col.Item().Table(Sub(table)
table.ColumnsDefinition(Sub(c)
c.RelativeColumn(2)
c.RelativeColumn(1)
c.RelativeColumn(1)
End Sub)
table.Header(Sub(h)
h.Cell().Text("Metric").Bold()
h.Cell().Text("Value").Bold()
h.Cell().Text("Change").Bold()
End Sub)
table.Cell().Text("Revenue")
table.Cell().Text("$1.2M")
table.Cell().Text("+12%")
table.Cell().Text("Users")
table.Cell().Text("45,230")
table.Cell().Text("+23%")
End Sub)
End Sub)
End Sub)
End Sub).GeneratePdf("report.pdf")QuestPDFはHTMLを変換しません。 ワークフローでHTMLテンプレート(Razorビュー、ダッシュボードエクスポート、ウェブコンテンツアーカイブ)を使用する場合は、別のライブラリが必要です。 コミュニティライセンスは、年間収益100万ドル未満の企業を対象としています; その上で、商用ライセンスが必要です。
iText 7 - .NET 8 互換、AGPL ライセンス
iText 7(iTextSharpの後継)は.NET 8をサポートしています。pdfHTMLアドオンは、ブラウザエンジンではなくカスタムパーサーでHTMLからPDFへの変換を行うため、最新のCSS機能(Flexbox、Grid)は正しくレンダリングされません。
ライセンスAGPL for open source use, 商業ライセンス(サブスクリプション、価格は公表されていません) for proprietary applications. iText は、2024年にサブスクリプションベースの商用ライセンスに移行しました。
Dockerの展開
標準的な Debian のイメージ (推奨)。
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["MyApp.csproj", "."]
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
#IronPDFworks without additional apt-get installs
# Chromium dependencies are handled internally
COPY --from=build /app/publish .
ENV DOTNET_RUNNING_IN_CONTAINER=true
EXPOSE 8080
ENTRYPOINT ["dotnet", "MyApp.dll"]アルパインイメージ(小さいフットプリント)
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
WORKDIR /src
COPY ["MyApp.csproj", "."]
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
WORKDIR /app
# Alpine requires explicit Chromium dependencies
RUN apk add --no-cache chromium nss freetype harfbuzz ca-certificates ttf-freefont
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]Debian イメージには追加パッケージは必要ありません。 Alpineイメージはより小さいですが、明示的なChromiumライブラリのインストールが必要です。 ほとんどのデプロイでは、標準の Debian イメージの方がシンプルで信頼できます。
Azureファンクション (孤立ワーカー)
.NET 8 Azure Functionsは、孤立ワーカーモデルを使用します。 IronPdfはこのモデルでオンデマンドPDF生成を行います:
using IronPdf;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
namespace MyApp.Functions;
public class PdfFunctions
{
[Function("GenerateInvoice")]
public async Task<HttpResponseData> GenerateInvoice(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req)
{
var invoice = await req.ReadFromJsonAsync<InvoiceRequest>();
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(BuildInvoiceHtml(invoice));
var response = req.CreateResponse(System.Net.HttpStatusCode.OK);
response.Headers.Add("Content-Type", "application/pdf");
response.Headers.Add("Content-Disposition",
$"attachment; filename=invoice-{invoice.Id}.pdf");
await response.Body.WriteAsync(pdf.BinaryData);
return response;
}
private string BuildInvoiceHtml(InvoiceRequest invoice)
{
return $@"<html><body>
<h1>Invoice #{invoice.Id}</h1>
<p>Amount: ${invoice.Amount:F2}</p>
</body></html>";
}
}
public record InvoiceRequest(string Id, decimal Amount);using IronPdf;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
namespace MyApp.Functions;
public class PdfFunctions
{
[Function("GenerateInvoice")]
public async Task<HttpResponseData> GenerateInvoice(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req)
{
var invoice = await req.ReadFromJsonAsync<InvoiceRequest>();
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(BuildInvoiceHtml(invoice));
var response = req.CreateResponse(System.Net.HttpStatusCode.OK);
response.Headers.Add("Content-Type", "application/pdf");
response.Headers.Add("Content-Disposition",
$"attachment; filename=invoice-{invoice.Id}.pdf");
await response.Body.WriteAsync(pdf.BinaryData);
return response;
}
private string BuildInvoiceHtml(InvoiceRequest invoice)
{
return $@"<html><body>
<h1>Invoice #{invoice.Id}</h1>
<p>Amount: ${invoice.Amount:F2}</p>
</body></html>";
}
}
public record InvoiceRequest(string Id, decimal Amount);Imports IronPdf
Imports Microsoft.Azure.Functions.Worker
Imports Microsoft.Azure.Functions.Worker.Http
Namespace MyApp.Functions
Public Class PdfFunctions
<Function("GenerateInvoice")>
Public Async Function GenerateInvoice(
<HttpTrigger(AuthorizationLevel.Function, "post")> req As HttpRequestData) As Task(Of HttpResponseData)
Dim invoice = Await req.ReadFromJsonAsync(Of InvoiceRequest)()
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(BuildInvoiceHtml(invoice))
Dim response = req.CreateResponse(System.Net.HttpStatusCode.OK)
response.Headers.Add("Content-Type", "application/pdf")
response.Headers.Add("Content-Disposition", $"attachment; filename=invoice-{invoice.Id}.pdf")
Await response.Body.WriteAsync(pdf.BinaryData)
Return response
End Function
Private Function BuildInvoiceHtml(invoice As InvoiceRequest) As String
Return $"<html><body>
<h1>Invoice #{invoice.Id}</h1>
<p>Amount: ${invoice.Amount:F2}</p>
</body></html>"
End Function
End Class
Public Class InvoiceRequest
Public Property Id As String
Public Property Amount As Decimal
Public Sub New(id As String, amount As Decimal)
Me.Id = id
Me.Amount = amount
End Sub
End Class
End Namespaceデプロイメントの考慮事項: IronPDFのChromiumバイナリはデプロイメントパッケージに~200MBを追加します。 Azure Functionsの消費プランには1.5GBのデプロイサイズ制限があります。PremiumまたはDedicatedプランでは、この制限は適用されません。 最初のPDF生成のコールドスタートの待ち時間は、Chromiumが初期化される2-5秒です。
ネイティブ
AOT 互換性.NET 8ではネイティブAOTサポートが拡張されましたが、PDFライブラリは基本的な制約に直面しています。 Chromiumベースのライブラリ(IronPDF, Puppeteer Sharp)は、ブラウザプロセスを埋め込んだり生成したりするため、AOTをコンパイルできません。 iText 7は、トリミングと競合する広範なリフレクションを使用しています。
<publishAot>true</publishAot>の現在のステータスです:
| ライブラリ | AOTステータス | 翻訳理由 |
|---|---|---|
| IronPDF | 互換性なし | Chromiumランタイムを埋め込む |
| iText 7 | 互換性なし | 重いリフレクション、動的コード生成 |
| QuestPDF | パーシャル(TrimMode=partial付き) | リフレクションの使用例 |
| PdfSharp | 互換性なし | System.Drawing.Common依存関係 |
ネイティブAOTが難しい要件であれば、TrimMode=partial付きのQuestPDFが最も近い選択肢です。 HTMLからPDFへのシナリオでは、AOTは現在どのライブラリでも実行可能ではありません。
ライセンスの比較
| ライブラリ | モデル | コスト | .NET 8サポート |
|---|---|---|---|
| IronPDF | 永久 | 749ドル (Lite) / 1499ドル (Pro) / 2999ドル (Enterprise) | フル |
| iText 7 | AGPLまたはサブスクリプション | 未公開 (推定年俸 $15K-$210K) | フル |
| QuestPDF | コミュニティ / 商用 | 無料<100万ドルの収益、その後商用 | フル |
| PdfSharp | MIT (無料) | $0 | Windowsのみ(Linuxは未対応) |
| Aspose.PDF | 開発者ごと | ~$999+ | フル(Linuxのメモリ問題) |
.NET 9 フォワード互換性
.NET 9(2025年11月リリース)は、.NET 8で確立されたパターンを引き継いでいます。.NET 8で動作するライブラリは、一般的に.NET 9でも変更なく動作します。 PDF生成に関連する.NET 9の主な追加機能は、ARM64パフォーマンスの向上(Apple SiliconとAWS Graviton上のChromiumベースのレンダリングの利点)と、Native AOTの継続的な改善です(PDFライブラリの基本的な制約は残っていますが)。
.NET 9をターゲットにしている場合やアップグレードを計画している場合は、.NET 8のクロスプラットフォーム展開を完全にサポートしているライブラリを選択するのが最も安全な方法です。 プラットフォーム固有の問題があるライブラリ(Linux上のPdfSharp、libgdiplusを使用したAspose)は、根本的な依存関係の廃止が恒久的であるため、.NET 9でそれらの問題が解決される可能性は低いです。
移行ガイド
iTextSharpからIronPDFへ
iTextSharpからIronPDFへ
// Before (iTextSharp — doesn't compile against net8.0)
using iTextSharp.text;
using iTextSharp.text.pdf;
var doc = new Document();
PdfWriter.GetInstance(doc, new FileStream("output.pdf", FileMode.Create));
doc.Open();
doc.Add(new Paragraph("Hello World"));
doc.Close();
// After (IronPDF — targets net8.0)
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<p>Hello World</p>");
pdf.SaveAs("output.pdf");// Before (iTextSharp — doesn't compile against net8.0)
using iTextSharp.text;
using iTextSharp.text.pdf;
var doc = new Document();
PdfWriter.GetInstance(doc, new FileStream("output.pdf", FileMode.Create));
doc.Open();
doc.Add(new Paragraph("Hello World"));
doc.Close();
// After (IronPDF — targets net8.0)
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<p>Hello World</p>");
pdf.SaveAs("output.pdf");Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports IronPdf
Imports System.IO
' Before (iTextSharp — doesn't compile against net8.0)
Dim doc As New Document()
PdfWriter.GetInstance(doc, New FileStream("output.pdf", FileMode.Create))
doc.Open()
doc.Add(New Paragraph("Hello World"))
doc.Close()
' After (IronPDF — targets net8.0)
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<p>Hello World</p>")
pdf.SaveAs("output.pdf")wkhtmltopdfラッパーからIronPDFへ
// Before (DinkToPdf — DllNotFoundException on .NET 8)
var converter = new SynchronizedConverter(new PdfTools());
var doc = new HtmlToPdfDocument
{
Objects = { new ObjectSettings { HtmlContent = html } }
};
var bytes = converter.Convert(doc);
// After (IronPDF — native .NET 8 support)
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
var bytes = pdf.BinaryData;// Before (DinkToPdf — DllNotFoundException on .NET 8)
var converter = new SynchronizedConverter(new PdfTools());
var doc = new HtmlToPdfDocument
{
Objects = { new ObjectSettings { HtmlContent = html } }
};
var bytes = converter.Convert(doc);
// After (IronPDF — native .NET 8 support)
using IronPdf;
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
var bytes = pdf.BinaryData;Imports IronPdf
' Before (DinkToPdf — DllNotFoundException on .NET 8)
Dim converter = New SynchronizedConverter(New PdfTools())
Dim doc = New HtmlToPdfDocument With {
.Objects = {New ObjectSettings With {.HtmlContent = html}}
}
Dim bytes = converter.Convert(doc)
' After (IronPDF — native .NET 8 support)
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
bytes = pdf.BinaryDataどちらの場合も、APIの表面はよりシンプルです。 主な移行コストは、既存の HTML テンプレートを新しいレンダラーでテストし、出力が期待に一致することを確認することです。
推薦文
HTMLからPDFへの変換を必要とする.NET 8プロジェクトのために:IronPDFは設定なしでクロスプラットフォームで動作する埋め込みChromiumレンダリングを提供します。 Dockerデプロイメント、Azure Functions、Linuxコンテナをすぐに扱えます。
.NET 8 プロジェクトでは、データからプログラムで文書を作成します:QuestPDFの流暢なAPIはよく設計されており、.NET 8と互換性があり、コミュニティライセンスはほとんどの新興企業や小規模チームをカバーしています。
Windows上でのPDF操作(結合、分割、フォーム):展開先がWindowsのみであれば、PdfSharpは引き続き使用可能です。
iTextSharp(互換性なし)、wkhtmltopdfラッパー(アーカイブ、CVEs)、クロスプラットフォーム展開のためのSystem.Drawing.Commonに依存するライブラリは避けてください。