比较

Kaizen.io 与 IronPDF:技术比较指南

当.NET开发人员需要将HTML内容转换为PDF文档时,他们可以选择使用基于容器的服务,比如Kaizen.io HTML-to-PDF,或使用像IronPDF这样的原生.NET库。 本比较在关键技术方面对这两种方法进行了研究,以帮助开发人员、架构师和技术决策者选择适合其 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 到 PDFIronPDF
部署模式自托管Docker容器NuGet包(嵌入在应用程序中)
集成HTTP POST到容器端点直接C#方法调用
加工通过HTTP的独立容器进程在进程内渲染
基础设施需要Docker+容器编排无外部依赖性
处理开销每次转换的HTTP往返直接内存处理
离线模式需要运行容器全部功能
SDK/Package没有.NET SDK——使用标准HttpClient本地 .NET 库
定价模式一次性许可证一次性或年度许可

两种方法都在您自己的基础设施中处理文档——Kaizen.io作为Docker容器在您的服务器上运行,IronPDF则直接在您的.NET应用程序内运行。 关键区别在于操作:Kaizen.io需要管理一个独立的容器服务并通过HTTP进行通信,而IronPDF则将渲染引擎直接嵌入到您的应用程序中,没有外部进程。

基本 HTML 到 PDF 的转换

最简单的 PDF 生成场景是将 HTML 字符串转换为 PDF 文件。比较代码模式可以发现 API 设计和复杂性方面的差异。

Kaizen.io HTML 到 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返回一个带有方便的PdfDocument对象,并通过文档对象访问额外的PDF操作功能。

将 HTML 文件转换为 PDF 文件

在转换 HTML 文件而不是字符串时,库会以不同的方式处理文件读取。

Kaizen.io HTML 转 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接受HTML内容作为JSON字符串,因此开发人员必须先读取文件并通过HTTP发送。IronPDF提供了一个专用的RenderHtmlFileAsPdf方法,可以在内部处理文件读取,减少样板代码。 IronPDF还支持通过RenderingOptions直接进行页面配置,而Kaizen.io的配置选项则取决于REST API端点接受的内容。

将 URL 转换为带页眉和页脚的 PDF 文件

专业文档通常需要带有页码、公司品牌或文档元数据的页眉和页脚。 这两个库都以不同的配置模式支持该功能。

Kaizen.io HTML 转 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# 库)
POST /html-to-pdf with {"html": "...renderer.RenderHtmlAsPdf(html)
获取URL内容,然后POST HTMLrenderer.RenderUrlAsPdf(url)
读取文件,然后POST HTMLrenderer.RenderHtmlFileAsPdf(path)
HTTP响应体(PDF字节)pdf.SaveAs(path)pdf.BinaryData
JSON请求参数renderer.RenderingOptions.* properties

团队何时考虑从 Kaizen.io 迁移到 IronPDF?

有几个因素促使团队将IronPDF作为Kaizen.io HTML 到 PDF的替代方案进行评估:

简单部署:Kaizen.io需要Docker基础设施——容器编排、健康监控、端口管理和容器更新。 IronPDF作为NuGet包安装,无外部进程或容器依赖。

性能:每次Kaizen.io转换都会涉及到容器进程的HTTP往返。 IronPDF在进程中渲染,避免了每次转换的序列化和网络开销。

无需容器依赖:需要生成PDF而不使用Docker的应用程序——桌面应用程序、简单的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
dotnet add package IronPdf
SHELL

需要在应用程序启动时设置一次许可证密钥:

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 包包含所有必要的依赖项,无需特定平台包。

错误处理注意事项

Container-based and embedded library approaches require different error handling:

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 到 PDF和IronPDF之间做出选择取决于您的具体要求:

如果您已经在基础设施中使用Docker,需要将PDF渲染与应用程序进程解耦,转换需求仅限于基本HTML到PDF,并且您更喜欢语言无关的基于HTTP的集成,请考虑Kaizen.io HTML-to-PDF。

如果您希望获得一个没有容器依赖的原生.NET库,需要超越基本生成的PDF操作(合并、水印、签名、加密),更喜欢直接C# API集成和IDE支持,或者您的部署环境不支持Docker,请考虑IronPDF。

对于在 2025 年构建现代 .NET 应用程序并计划在 2026 年实现这一目标的团队来说,IronPDF 与本地处理、数据隐私和本地 .NET 集成的一致性提供了令人信服的优势。 完全控制渲染配置、消除外部依赖性以及在不向外部传输数据的情况下处理文档的能力可以满足常见的企业要求。

开始使用 IronPDF

如需评估IronPDF是否能满足您 HTML 到 PDF 的转换需求:

  1. 安装IronPDF NuGet包Install-Package IronPdf 2.查看 HTML 转 PDF 教程,了解转换模式 3.探索URL到PDF的转换,用于网页抓取
  2. 为专业文档配置页眉和页脚

IronPDF 教程为常见场景提供了全面的示例,API 参考记录了所有可用的类和方法。

Kaizen.io HTML-to-PDF和IronPDF代表了不同的PDF生成架构方法。 Kaizen.io作为一个具有REST API的自托管Docker容器运行,而IronPDF是一个原生.NET库,将渲染引擎直接嵌入您的应用程序。

对于希望无需容器基础设施进行直接库集成的.NET团队,IronPDF提供了一个更简单的部署模型和更丰富的功能集——包括超越基本HTML-to-PDF转换的PDF操作、安全性和数字签名。

根据您的部署基础设施、功能需求和集成偏好评估两种选择。

请注意Kaizen.io 是其各自所有者的注册商标。 此网站与 Kaizenio, Inc. 无关,不受其认可或赞助。 所有产品名称、徽标和品牌均为各自所有者的财产。 比较仅供参考,反映撰写时公开可用的信息。)}]