比較

Expert PDF與IronPDF:技術比較指南

當.NET開發人員需要將HTML內容轉換為PDF文件時,他們可以選擇基於容器的服務如Kaizen.io HTML-to-PDF或本機的.NET程式庫如IronPDF。 本比較將檢視這兩種方法在關鍵技術維度上的表現,以幫助開發人員、架構師和技術決策者選擇適合其PDF生成工作流程的解決方案。

什麼是Kaizen.io HTML-to-PDF?

Kaizen.io HTML-to-PDF是一種自託管的Docker容器,它透過REST API將HTML內容轉換為PDF文件。 開發人員佈署容器(例如,docker run kaizenio.azurecr.io/html-to-pdf:latest)並使用JSON資料將HTTP POST請求發送到http://localhost:8080/html-to-pdf。 服務會在響應正文中返回呈現的PDF。

這種架構意味著開發人員管理容器基礎設施,但是不需要將呈現引擎嵌入到他們的應用程式中。 整合使用任何語言的標準HTTP客戶端——沒有Kaizen.io的NuGet包或.NET SDK。

然而,這種架構引入了對Docker的依賴,並且需要容器編排來進行生產部署,每次轉換增加了HTTP往返開銷。

什麼是 IronPDF?

IronPDF 是一個本機C#程式庫,能夠在您的.NET應用程式中完全處理PDF生成。 而不是將資料發送到外部伺服器,IronPDF使用嵌入的Chromium呈現引擎在本地將HTML、CSS和JavaScript轉換為PDF文件。

ChromePdfRenderer類作為轉換的主要介面。 開發人員可以透過RenderUrlAsPdf()的方法來生成PDF文件。 生成的PdfDocument物件提供了對二進位資料、文件儲存和其他操作功能的直接存取。

這種本地處理模型消除了網路依賴,並讓開發人員對呈現配置和資料隱私擁有完全控制。

架構比較:容器服務對嵌入式程式庫

Kaizen.io HTML-to-PDF和IronPDF之間的根本區別在於PDF呈現如何整合到您的應用程式中。 這種架構上的區別影響了部署的複雜性、性能特徵和開發人員的體驗。

功能Kaizen.io HTML-to-PDFIronPDF
部署模型自託管的Docker容器NuGet包(嵌入在應用程式中)
整合HTTP POST到容器端點直接的C#方法呼叫
處理透過HTTP的單獨容器處理進程內呈現
基礎設施需要Docker+容器編排無外部依賴
處理開銷每次轉換的HTTP往返直接的記憶體處理
離線模式需要運行中的容器完整功能
SDK/包沒有.NET SDK——使用標準HttpClient本機.NET程式庫
定價模型一次性授權一次性或年度授權

兩種方法都是在您自己的基礎設施內處理文件——Kaizen.io作為Docker容器運行在您的伺服器上,而IronPDF直接在您的.NET應用程式中運行。 關鍵區別在於操作:Kaizen.io需要管理一個單獨的容器服務並通過HTTP通信,而IronPDF將呈現引擎直接嵌入到您的應用程式中,沒有外部過程。

基本HTML到PDF轉換

最簡單的PDF生成情景涉及將一個HTML字串轉換為PDF文件。比較程式碼模式揭示了API設計和複雜度的差異。

Kaizen.io HTML-to-PDF實現:

// Requires: docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
using System.Net.Http;
using System.Net.Http.Json;
using System.IO;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        var html = "<html><body><h1>Hello World</h1></body></html>";

        var response = await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            new { html });
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();
        File.WriteAllBytes("output.pdf", pdfBytes);
    }
}
// Requires: docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
using System.Net.Http;
using System.Net.Http.Json;
using System.IO;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        var html = "<html><body><h1>Hello World</h1></body></html>";

        var response = await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            new { html });
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();
        File.WriteAllBytes("output.pdf", pdfBytes);
    }
}
Imports System.Net.Http
Imports System.Net.Http.Json
Imports System.IO
Imports System.Threading.Tasks

Module Program
    Async Function Main() As Task
        Dim client As New HttpClient()
        Dim html As String = "<html><body><h1>Hello World</h1></body></html>"

        Dim response = Await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            New With {Key .html = html})
        Dim pdfBytes = Await response.Content.ReadAsByteArrayAsync()
        File.WriteAllBytes("output.pdf", pdfBytes)
    End Function
End Module
$vbLabelText   $csharpLabel

IronPDF 實現:

// NuGet: Install-Package IronPdf
using IronPdf;
using System.IO;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var html = "<html><body><h1>Hello World</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System.IO;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var html = "<html><body><h1>Hello World</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System.IO

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim html = "<html><body><h1>Hello World</h1></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

Kaizen.io需要設置一個Docker容器並進行HTTP請求——沒有.NET SDK或NuGet包。 REST API返回原始的PDF位元組。 IronPDF返回一個SaveAs()方法,並可通過文件物件存取額外的PDF操作功能。

HTML文件到PDF轉換

將HTML文件而非字串進行轉換時,程式庫處理文件讀取的方式不同。

Kaizen.io HTML-to-PDF方法:

// Requires: docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
using System.Net.Http;
using System.Net.Http.Json;
using System.IO;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        var htmlContent = File.ReadAllText("input.html");

        var response = await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            new { html = htmlContent });
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();
        File.WriteAllBytes("document.pdf", pdfBytes);
    }
}
// Requires: docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
using System.Net.Http;
using System.Net.Http.Json;
using System.IO;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        var htmlContent = File.ReadAllText("input.html");

        var response = await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            new { html = htmlContent });
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();
        File.WriteAllBytes("document.pdf", pdfBytes);
    }
}
Imports System.Net.Http
Imports System.Net.Http.Json
Imports System.IO
Imports System.Threading.Tasks

Module Program
    Async Function Main() As Task
        Dim client As New HttpClient()
        Dim htmlContent As String = File.ReadAllText("input.html")

        Dim response = Await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            New With {.html = htmlContent})
        Dim pdfBytes As Byte() = Await response.Content.ReadAsByteArrayAsync()
        File.WriteAllBytes("document.pdf", pdfBytes)
    End Function
End Module
$vbLabelText   $csharpLabel

IronPDF 方法:

// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait;
        var pdf = renderer.RenderHtmlFileAsPdf("input.html");
        pdf.SaveAs("document.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait;
        var pdf = renderer.RenderHtmlFileAsPdf("input.html");
        pdf.SaveAs("document.pdf");
    }
}
Imports IronPdf
Imports System
Imports System.IO

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait
        Dim pdf = renderer.RenderHtmlFileAsPdf("input.html")
        pdf.SaveAs("document.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

Kaizen.io的REST API接受作為JSON字串的HTML內容,因此開發人員必須首先讀取文件並通過HTTP發送。IronPDF提供了一個專用的RenderHtmlFileAsPdf方法,內部處理文件讀取,從而減少板塊程式碼。 IronPDF還通過RenderingOptions支持直接配置頁面,而Kaizen.io的配置選項依賴於REST API端點接受的內容。

帶頁眉和頁腳的URL到PDF

專業文件通常需要具有頁碼、公司品牌或文件元資料的頁眉和頁腳。 兩種程式庫支持此功能,但配置模式不同。

Kaizen.io HTML-to-PDF方法:

Kaizen.io的REST API通過POST http://localhost:8080/html-to-pdf接受HTML字串。 為進行URL到PDF的轉換,應用程式必須先獲取網頁內容,然後發送到容器。 頁眉/頁腳支持取決於容器的API功能——請參閱Kaizen.io文件以了解可用選項。

// Requires: docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
using System.Net.Http;
using System.Net.Http.Json;
using System.IO;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        // Kaizen.io accepts HTML content — URL fetching must be done separately
        var html = await client.GetStringAsync("https://example.com");

        var response = await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            new { html });
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();
        File.WriteAllBytes("webpage.pdf", pdfBytes);
    }
}
// Requires: docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
using System.Net.Http;
using System.Net.Http.Json;
using System.IO;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        // Kaizen.io accepts HTML content — URL fetching must be done separately
        var html = await client.GetStringAsync("https://example.com");

        var response = await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            new { html });
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();
        File.WriteAllBytes("webpage.pdf", pdfBytes);
    }
}
Imports System.Net.Http
Imports System.Net.Http.Json
Imports System.IO
Imports System.Threading.Tasks

Module Program
    Async Function Main() As Task
        Dim client As New HttpClient()
        ' Kaizen.io accepts HTML content — URL fetching must be done separately
        Dim html As String = Await client.GetStringAsync("https://example.com")

        Dim response = Await client.PostAsJsonAsync(
            "http://localhost:8080/html-to-pdf",
            New With {Key .html = html})
        Dim pdfBytes As Byte() = Await response.Content.ReadAsByteArrayAsync()
        File.WriteAllBytes("webpage.pdf", pdfBytes)
    End Function
End Module
$vbLabelText   $csharpLabel

帶有頁眉和頁腳的 IronPDF:

// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.TextHeader.CenterText = "Company Header";
        renderer.RenderingOptions.TextFooter.CenterText = "Page {page} of {total-pages}";
        renderer.RenderingOptions.MarginTop = 20;
        renderer.RenderingOptions.MarginBottom = 20;
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.TextHeader.CenterText = "Company Header";
        renderer.RenderingOptions.TextFooter.CenterText = "Page {page} of {total-pages}";
        renderer.RenderingOptions.MarginTop = 20;
        renderer.RenderingOptions.MarginBottom = 20;
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf
Imports System
Imports System.IO

Module Program
    Sub Main()
        Dim renderer As New ChromePdfRenderer()
        renderer.RenderingOptions.TextHeader.CenterText = "Company Header"
        renderer.RenderingOptions.TextFooter.CenterText = "Page {page} of {total-pages}"
        renderer.RenderingOptions.MarginTop = 20
        renderer.RenderingOptions.MarginBottom = 20
        Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
        pdf.SaveAs("webpage.pdf")
    End Sub
End Module
$vbLabelText   $csharpLabel

IronPDF提供了HtmlFooter以支持複雜的HTML設計。 RenderingOptions類集中所有配置,通過IDE自動補全輕鬆發現可用選項。

IronPDF支持頁眉和頁腳中的動態佔位符,包括{url}。 Kaizen.io的頁眉/頁腳功能取決於容器的REST API——請查閱其文件以了解支持的選項。

API設計比較

整合方法從根本上是不同的。 Kaizen.io是一種REST API——開發人員發送帶有JSON資料的HTTP請求並接收PDF位元組。 沒有.NET類、方法或配置物件可映射。IronPDF是本機.NET程式庫,擁有豐富的C# API。

整合模式比較

Kaizen.io(REST API)IronPDF(C#程式庫)
{"html": "...renderer.RenderHtmlAsPdf(html)
獲取URL內容,然後POST HTMLrenderer.RenderUrlAsPdf(url)
讀取文件,然後POST HTMLrenderer.RenderHtmlFileAsPdf(path)
HTTP響應正文(PDF位元組)pdf.BinaryData
JSON請求參數renderer.RenderingOptions.*屬性

團隊考慮從Kaizen.io轉移到IronPDF的情況

有幾個因素驅使團隊評估IronPDF作為Kaizen.io HTML-to-PDF的替代方案:

更簡單的部署:Kaizen.io需要Docker基礎設施——容器編排、健康監控、埠管理和容器更新。 IronPDF以NuGet包形式安裝,無需外部過程或容器依賴。

性能:每次Kaizen.io轉換涉及到容器過程的HTTP往返。 IronPDF是在進程內進行呈現,避免了每次轉換的序列化和網路開銷。

無容器依賴:需要無Docker生成PDF的應用程式——桌面應用程式、簡單的Web伺服器或不支持容器的環境——從IronPDF的嵌入式架構中受益。

豐富的API:Kaizen.io的REST API接受HTML並返回PDF位元組——這就是它的範圍。 IronPDF提供了一個完整的.NET API,具備PDF合併、拆分、加水印、表單填寫、數位簽名以及超出基本生成的安全設置。

開發者體驗:IronPDF直接整合到C#程式碼中,並有IDE自動補全、型別安全和同步或異步方法調用。 Kaizen.io需要HTTP客戶端板塊程式碼、JSON序列化和手動位元組陣列處理。

回傳型別差異

一個關鍵的API區別影響應用程式如何處理轉換結果:

Kaizen.io回傳原始HTTP響應位元組:

var response = await client.PostAsJsonAsync("http://localhost:8080/html-to-pdf", new { html });
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("output.pdf", pdfBytes);
var response = await client.PostAsJsonAsync("http://localhost:8080/html-to-pdf", new { html });
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("output.pdf", pdfBytes);
Imports System.IO
Imports System.Net.Http
Imports System.Threading.Tasks

Dim response = Await client.PostAsJsonAsync("http://localhost:8080/html-to-pdf", New With {Key .html})
Dim pdfBytes = Await response.Content.ReadAsByteArrayAsync()
File.WriteAllBytes("output.pdf", pdfBytes)
$vbLabelText   $csharpLabel

IronPDF返回PdfDocument物件:

var pdf = renderer.RenderHtmlAsPdf(html);
byte[] bytes = pdf.BinaryData;  // Get bytes if needed
pdf.SaveAs("output.pdf");        // Or save directly
var pdf = renderer.RenderHtmlAsPdf(html);
byte[] bytes = pdf.BinaryData;  // Get bytes if needed
pdf.SaveAs("output.pdf");        // Or save directly
Dim pdf = renderer.RenderHtmlAsPdf(html)
Dim bytes As Byte() = pdf.BinaryData  ' Get bytes if needed
pdf.SaveAs("output.pdf")  ' Or save directly
$vbLabelText   $csharpLabel

IronPDF PdfDocument 物件通過SaveAs()的便利方法。 超出了基本輸出,PdfDocument 還允許額外操作如合併文件新增水印表單填寫應用安全設置

安裝和設置

兩種方法的安裝過程差異很大:

Kaizen.io設置:

docker pull kaizenio.azurecr.io/html-to-pdf:latest
docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
docker pull kaizenio.azurecr.io/html-to-pdf:latest
docker run -d -p 8080:8080 kaizenio.azurecr.io/html-to-pdf:latest
SHELL

沒有NuGet包——整合使用標準HttpClient以調用容器的REST API。

IronPDF設置:

dotnet add package IronPdf

需要在應用啟動時設置一次授權金鑰:

IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

IronPDF支持.NET Framework 4.6.2+和.NET Core 3.1+/ .NET 5+,使其相容以.NET 10和C# 14為目標的現代.NET開發。單個NuGet包包含了所有必要的依賴項,而無需平台專用的包。

錯誤處理考量

基於容器和嵌入式程式庫的方法需要不同的錯誤處理:

Kaizen.io錯誤場景:

  • 容器未運行或無法存取
  • 到容器端點的HTTP連接失敗
  • 容器資源限制(記憶體,CPU)
  • 請求超時處理
  • 容器重啟/健康監測

IronPDF錯誤場景:

  • HTML解析問題
  • 資源載入失敗
  • 大文件的記憶體約束
  • 文件系統存取錯誤

從Kaizen.io遷移到IronPDF的團隊可以透過去除HTTP客戶端邏輯、容器健康檢查以及進程間通信來簡化其錯誤處理。 IronPDF的進程內呈現消除了管理單獨容器服務的故障模式。

性能考量

IronPDF在第一次使用時初始化其Chromium呈現引擎,可能會為初始轉換引入短暫的延遲。 對於對延遲敏感啟動需求的應用程式,在應用初始化時預熱渲染器可以防止此延遲影響面對使用者的操作。

// In Program.cs or Startup.cs
new ChromePdfRenderer().RenderHtmlAsPdf("<html></html>");
// In Program.cs or Startup.cs
new ChromePdfRenderer().RenderHtmlAsPdf("<html></html>");
' In Program.vb or Startup.vb
Call New ChromePdfRenderer().RenderHtmlAsPdf("<html></html>")
$vbLabelText   $csharpLabel

初始化後,隨後的轉換將以全速執行。IronPDF文件提供了高負載場景下的其他優化技術。

做出決策

在Kaizen.io HTML-to-PDF和IronPDF之間的選擇取決於您的具體需求:

考慮Kaizen.io HTML-to-PDF的情況:您已在基礎設施中使用Docker,您希望將PDF呈現與應用程式進程解耦,您的轉換需求僅限於基本HTML到PDF,您更喜歡語言無關的基於HTTP的整合。

考慮IronPDF的情況:您需要本機的.NET程式庫,無需容器依賴,您需要超出基本生成(PDF合併、水印、簽名、加密)的PDF操作,您更喜歡具有IDE支持的直接C# API整合,或您的部署環境不支持Docker。

對於計畫向2026年邁進並建設現代.NET應用程式的團隊,IronPDF在本地處理、資料隱私和本機.NET整合方面提供了引人注目的優勢。 完全控制呈現配置的能力,消除外部依賴性,並且能夠在不發送資料到外部的情況下處理文件,滿足了普通企業的要求。

開始使用 IronPDF

要評估IronPDF是否適合您的HTML到PDF轉換需求:

  1. 安裝IronPDF NuGet包Install-Package IronPdf
  2. 查看HTML到PDF教程以獲取轉換模式
  3. 探索URL到PDF轉換以捕捉網頁
  4. 為專業文件配置頁眉和頁腳

IronPDF教程提供了常見場景的全面範例,API參考文件列出了所有可用的類和方法。

Kaizen.io HTML-to-PDF和IronPDF代表了PDF生成的不同架構方法。 Kaizen.io運作為自託管Docker容器,擁有REST API,IronPDF則是一個本機.NET程式庫,將呈現引擎直接嵌入您的應用程式。

對於想要無需容器基礎設施的直接程式庫整合的.NET團隊,IronPDF提供了一個更簡便的部署模式和更豐富的功能集——包括PDF操作、安全性和數位簽名,這超出了基本HTML到PDF轉換。

根據您的部署基礎設施、功能需求和整合偏好評估兩個選項。

請注意Kaizen.io是其相應所有者註冊商標。 本網站不隸屬於、亦不由Kaizenio, Inc.支持或贊助。 所有產品名稱、標誌和品牌均為其各自所有者的財產。 比較僅供資訊參考,並反映了撰寫時公開的資訊。)}