比較

Nutrient.io vs IronPDF:技術比較指南

當.NET開發人員需要 PDF 處理功能時,他們經常會遇到 Nutrient.io(以前稱為 PSPDFKit)——該平台已從 PDF SDK 轉型為完整的文件智慧解決方案。 本文將從關鍵技術方面對 Nutrient.io 和IronPDF進行比較,以協助開發人員、架構師和技術決策者為其 PDF 產生和處理工作流程選擇合適的工具。

Nutrient.io是什麼?

Nutrient.io(前身為 PSPDFKit)已從一個以 PDF 為中心的庫轉變為一個完整的文檔智慧平台。 這項變更使其功能不再局限於簡單的 PDF 處理,而是擴展到包括 AI 驅動的文件分析和廣泛的文件工作流程功能。

該庫透過其 PdfProcessor 類別運行,該類別必須使用 PdfProcessor.CreateAsync() 非同步建立。 HTML 到 PDF 轉換、文件合併和浮水印等操作都透過 MergeAsync()AddAnnotationAsync() 等方法使用 async/await 模式。

Nutrient.io 的平台架構及其企業定價結構,使其定位為大型組織的目標客戶。 PSPDFKit 更名為 Nutrient.io 後,文件變得複雜,軟體包名稱和參考文獻有時會使用這兩個名稱。

IronPDF是什麼?

IronPDF是一個專為.NET環境設計的專用 PDF 函式庫。 IronPDF並沒有將自己定位為文件智慧平台,而是專注於 PDF 操作:產生、操作、合併、新增浮水印等等。

ChromePdfRenderer類別是 PDF 生成的主要接口,它使用基於 Chromium 的渲染引擎將 HTML、CSS 和JavaScript轉換為高保真 PDF 文件。 PdfDocument 類別為現有 PDF 提供了廣泛的操作功能。

IronPDF 的架構強調簡潔性,提供同步和非同步方法以適應不同的應用程式模式。 配置透過 RenderingOptions 屬性進行,設定可透過 IDE 自動完成功能發現。

建築方法比較

這些庫之間的根本區別在於它們的範圍和複雜性。 Nutrient.io 已發展成為一個平台,而IronPDF仍然是一個專注於特定領域的資料庫。

方面 Nutrient.io (PSPDFKit) IronPDF
範圍 文檔智慧平台 專用 PDF 庫
複雜 高,是完整平台的一部分 中等難度,專注於PDF任務
定價 企業級 適用於各種規模的團隊
PDF Focus 這是更廣泛的文檔框架的一部分 獨有的PDF功能
一體化 由於功能眾多,可能較為複雜。 簡單明了
目標用戶 需要先進文件技術的大型組織 需要可靠 PDF 工具的開發人員
API 風格 非同步優先、複雜 使用非同步選項進行同步
學習曲線 陡峭的(平台) 溫柔(圖書館)

Nutrient.io 的平台方法意味著即使只需要基本的 PDF 操作,應用程式也能獲得 AI 功能和文件工作流程功能。 這可能會為需求簡單的專案帶來不必要的複雜性。

HTML 轉 PDF

這兩個庫都支援將 HTML 內容轉換為 PDF 文件。 API模式在複雜性和風格上有顯著差異。

Nutrient.io HTML 轉 PDF 方法:

// NuGet: Install-Package PSPDFKit.Dotnet
using PSPDFKit.Pdf;
using System.Threading.Tasks;

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

        using var processor = await PdfProcessor.CreateAsync();
        var document = await processor.GeneratePdfFromHtmlStringAsync(htmlContent);
        await document.SaveAsync("output.pdf");
    }
}
// NuGet: Install-Package PSPDFKit.Dotnet
using PSPDFKit.Pdf;
using System.Threading.Tasks;

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

        using var processor = await PdfProcessor.CreateAsync();
        var document = await processor.GeneratePdfFromHtmlStringAsync(htmlContent);
        await document.SaveAsync("output.pdf");
    }
}
Imports PSPDFKit.Pdf
Imports System.Threading.Tasks

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

        Using processor = Await PdfProcessor.CreateAsync()
            Dim document = Await processor.GeneratePdfFromHtmlStringAsync(htmlContent)
            Await document.SaveAsync("output.pdf")
        End Using
    End Function
End Module
$vbLabelText   $csharpLabel

IronPDF HTML 轉 PDF 方法:

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var htmlContent = "<html><body><h1>Hello World</h1></body></html>";

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

class Program
{
    static void Main()
    {
        var htmlContent = "<html><body><h1>Hello World</h1></body></html>";

        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim htmlContent As String = "<html><body><h1>Hello World</h1></body></html>"

        Dim renderer As New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

Nutrient.io 需要使用 await PdfProcessor.CreateAsync() 非同步建立一個處理器,然後呼叫非同步方法進行產生和儲存。 每個操作都使用 async/await 模式,正確的釋放需要 using 語句。

IronPDF預設提供同步方法,從而降低程式碼複雜度。 HTML 到 PDF 轉換工作流程包含實例化 ChromePdfRenderer,呼叫 RenderHtmlAsPdf(),並使用 SaveAs() 儲存。 對於需要非同步操作的應用程序, IronPDF還提供了非同步方法變體,例如 RenderHtmlAsPdfAsync()

Nutrient.io 中的處理器生命週期需要使用 using 語句進行仔細管理,而 IronPDF 的渲染器可以實例化和重複使用,無需複雜的生命週期管理。

合併PDF文檔

文件合併體現了這些庫之間 API 複雜性的差異。

Nutrient.io 合併方案:

// NuGet: Install-Package PSPDFKit.Dotnet
using PSPDFKit.Pdf;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program
{
    static async Task Main()
    {
        using var processor = await PdfProcessor.CreateAsync();

        var document1 = await processor.OpenAsync("document1.pdf");
        var document2 = await processor.OpenAsync("document2.pdf");

        var mergedDocument = await processor.MergeAsync(new List<PdfDocument> { document1, document2 });
        await mergedDocument.SaveAsync("merged.pdf");
    }
}
// NuGet: Install-Package PSPDFKit.Dotnet
using PSPDFKit.Pdf;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program
{
    static async Task Main()
    {
        using var processor = await PdfProcessor.CreateAsync();

        var document1 = await processor.OpenAsync("document1.pdf");
        var document2 = await processor.OpenAsync("document2.pdf");

        var mergedDocument = await processor.MergeAsync(new List<PdfDocument> { document1, document2 });
        await mergedDocument.SaveAsync("merged.pdf");
    }
}
Imports PSPDFKit.Pdf
Imports System.Threading.Tasks
Imports System.Collections.Generic

Class Program
    Shared Async Function Main() As Task
        Using processor = Await PdfProcessor.CreateAsync()

            Dim document1 = Await processor.OpenAsync("document1.pdf")
            Dim document2 = Await processor.OpenAsync("document2.pdf")

            Dim mergedDocument = Await processor.MergeAsync(New List(Of PdfDocument) From {document1, document2})
            Await mergedDocument.SaveAsync("merged.pdf")
        End Using
    End Function
End Class
$vbLabelText   $csharpLabel

IronPDF合併方法:

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

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;
using System.Collections.Generic;

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
Imports System.Collections.Generic

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
$vbLabelText   $csharpLabel

Nutrient.io 需要:

  1. 非同步建立處理器
  2. 使用 await processor.OpenAsync() 非同步開啟每個文檔
  3. 為合併操作建立 List<PdfDocument>
  4. 呼叫非同步方法 MergeAsync()
  5. 非同步保存結果

IronPDF將此簡化為使用 PdfDocument.FromFile() 載入檔案並呼叫靜態 PdfDocument.Merge() 方法。 PDF合併功能可直接接受多個文檔,無需建立清單即可進行簡單合併。

添加浮水印

水印技術揭示了設計理念上的根本差異:Nutrient.io 使用註解對象,而IronPDF使用 HTML 字串。

Nutrient.io 水印方法:

// NuGet: Install-Package PSPDFKit.Dotnet
using PSPDFKit.Pdf;
using PSPDFKit.Pdf.Annotation;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        using var processor = await PdfProcessor.CreateAsync();
        var document = await processor.OpenAsync("document.pdf");

        for (int i = 0; i < document.PageCount; i++)
        {
            var watermark = new TextAnnotation("CONFIDENTIAL")
            {
                Opacity = 0.5,
                FontSize = 48
            };
            await document.AddAnnotationAsync(i, watermark);
        }

        await document.SaveAsync("watermarked.pdf");
    }
}
// NuGet: Install-Package PSPDFKit.Dotnet
using PSPDFKit.Pdf;
using PSPDFKit.Pdf.Annotation;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        using var processor = await PdfProcessor.CreateAsync();
        var document = await processor.OpenAsync("document.pdf");

        for (int i = 0; i < document.PageCount; i++)
        {
            var watermark = new TextAnnotation("CONFIDENTIAL")
            {
                Opacity = 0.5,
                FontSize = 48
            };
            await document.AddAnnotationAsync(i, watermark);
        }

        await document.SaveAsync("watermarked.pdf");
    }
}
Imports PSPDFKit.Pdf
Imports PSPDFKit.Pdf.Annotation
Imports System.Threading.Tasks

Class Program
    Shared Async Function Main() As Task
        Using processor = Await PdfProcessor.CreateAsync()
            Dim document = Await processor.OpenAsync("document.pdf")

            For i As Integer = 0 To document.PageCount - 1
                Dim watermark = New TextAnnotation("CONFIDENTIAL") With {
                    .Opacity = 0.5,
                    .FontSize = 48
                }
                Await document.AddAnnotationAsync(i, watermark)
            Next

            Await document.SaveAsync("watermarked.pdf")
        End Using
    End Function
End Class
$vbLabelText   $csharpLabel

IronPDF水印方法:

// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        pdf.ApplyWatermark("<h1 style='color:gray;opacity:0.5;'>CONFIDENTIAL</h1>",
            50,
            VerticalAlignment.Middle,
            HorizontalAlignment.Center);

        pdf.SaveAs("watermarked.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        pdf.ApplyWatermark("<h1 style='color:gray;opacity:0.5;'>CONFIDENTIAL</h1>",
            50,
            VerticalAlignment.Middle,
            HorizontalAlignment.Center);

        pdf.SaveAs("watermarked.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Editing

Class Program
    Shared Sub Main()
        Dim pdf = PdfDocument.FromFile("document.pdf")

        pdf.ApplyWatermark("<h1 style='color:gray;opacity:0.5;'>CONFIDENTIAL</h1>", 
                           50, 
                           VerticalAlignment.Middle, 
                           HorizontalAlignment.Center)

        pdf.SaveAs("watermarked.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

Nutrient.io 需要遍歷每個頁面,創建具有 TextAnnotationOpacityFontSize 等屬性的 await document.AddAnnotationAsync() 對象,並使用 await document.AddAnnotationAsync() 異步添加每個註釋。 這種方法需要了解註解 API 和手動頁面迭代。

IronPDF 的浮水印功能使用帶有 CSS 樣式的 HTML 字串。 ApplyWatermark() 方法接受 HTML 內容、旋轉角度和對齊參數,自動將浮水印套用至所有頁面。 CSS 屬性如 opacitycolor 可以處理原本需要單獨註解屬性的樣式。

基於HTML的方法有以下優點: 熟悉 Web 開發語法

  • 完整的 CSS 樣式功能
  • 單一方法呼叫適用於所有頁面 無需手動頁面迭代

API對應參考

對於正在評估 Nutrient.io 遷移到IronPDF 的團隊來說,了解 API 映射有助於估算工作量。

核心方法映射

Nutrient.io (PSPDFKit) IronPDF
await PdfProcessor.CreateAsync() new ChromePdfRenderer()
await processor.OpenAsync(path) PdfDocument.FromFile(path)
await processor.GeneratePdfFromHtmlStringAsync(html) renderer.RenderHtmlAsPdf(html)
await processor.MergeAsync(docs) PdfDocument.Merge(pdfs)
await document.SaveAsync(path) pdf.SaveAs(path)
document.ToBytes() pdf.BinaryData
document.ToStream() pdf.Stream

配置映射

Nutrient.io (PSPDFKit) IronPDF
new PdfConfiguration { PageSize = ... } renderer.RenderingOptions.PaperSize = ...
config.Margins = new Margins(t, r, b, l) 個體邊際屬性
config.Orientation = Orientation.Landscape RenderingOptions.PaperOrientation

水印和註釋映射

Nutrient.io (PSPDFKit) IronPDF
new TextAnnotation("text") HTML字串
annotation.Opacity = 0.5 CSS opacity: 0.5
annotation.FontSize = 48 CSS font-size: 48px
await document.AddAnnotationAsync(index, annotation) pdf.ApplyWatermark(html)

頁首/頁尾映射

Nutrient.io (PSPDFKit) IronPDF
(複雜標註法) RenderingOptions.HtmlHeader
(複雜標註法) RenderingOptions.HtmlFooter
(人工頁數統計) {page}佔位符
(手動計算) {total-pages}佔位符

Nutrient.io 需要手動計數頁碼並重複嘗試才能在頁首或頁尾中新增頁碼。 IronPDF提供內建佔位符,可自動插入頁碼和總計。

命名空間和包變更

從 Nutrient.io 遷移到IronPDF 的團隊需要更新命名空間導入:

Nutrient.io (PSPDFKit) IronPDF
using PSPDFKit.Pdf; using IronPdf;
using PSPDFKit.Pdf.Document; using IronPdf;
using PSPDFKit.Pdf.Rendering; using IronPdf.Rendering;
using PSPDFKit.Pdf.Annotation; using IronPdf;
using Nutrient.Pdf; using IronPdf;

NuGet套件遷移:

# Remove Nutrient/PSPDFKit packages
dotnet remove package PSPDFKit.NET
dotnet remove package PSPDFKit.PDF
dotnet remove package Nutrient
dotnet remove package Nutrient.PDF

# Install IronPDF
dotnet add package IronPdf
# Remove Nutrient/PSPDFKit packages
dotnet remove package PSPDFKit.NET
dotnet remove package PSPDFKit.PDF
dotnet remove package Nutrient
dotnet remove package Nutrient.PDF

# Install IronPDF
dotnet add package IronPdf
SHELL

非同步與同步 API 設計

Nutrient.io 採用非同步優先架構,幾乎每個操作都需要 async/await:

// Nutrient.io pattern - async everywhere
using var processor = await PdfProcessor.CreateAsync();
var document = await processor.OpenAsync(path);
await document.SaveAsync(outputPath);
// Nutrient.io pattern - async everywhere
using var processor = await PdfProcessor.CreateAsync();
var document = await processor.OpenAsync(path);
await document.SaveAsync(outputPath);
Imports System

Using processor = Await PdfProcessor.CreateAsync()
    Dim document = Await processor.OpenAsync(path)
    Await document.SaveAsync(outputPath)
End Using
$vbLabelText   $csharpLabel

IronPDF預設提供同步方法,同時也提供非同步替代方案:

// IronPDF sync pattern (simpler)
var pdf = PdfDocument.FromFile(path);
pdf.SaveAs(outputPath);

// IronPDF async pattern (when needed)
var pdf = await renderer.RenderHtmlAsPdfAsync(html);
// IronPDF sync pattern (simpler)
var pdf = PdfDocument.FromFile(path);
pdf.SaveAs(outputPath);

// IronPDF async pattern (when needed)
var pdf = await renderer.RenderHtmlAsPdfAsync(html);
Imports IronPdf

' IronPDF sync pattern (simpler)
Dim pdf = PdfDocument.FromFile(path)
pdf.SaveAs(outputPath)

' IronPDF async pattern (when needed)
Dim pdf = Await renderer.RenderHtmlAsPdfAsync(html)
$vbLabelText   $csharpLabel

對於不需要非同步執行 PDF 操作的應用程式場景(例如背景作業、控制台應用程式或同步服務方法),IronPDF 的預設同步 API 可以降低程式碼的複雜度。 當非同步操作有利時,可以使用相應的方法。

當團隊考慮從 Nutrient.io 遷移到IronPDF時

促使各團隊評估IronPDF作為 Nutrient.io 的替代方案的因素有很多:

平台複雜性:只需要產生和處理 PDF 的團隊可能會發現 Nutrient.io 的文檔智慧平台包含不必要的功能。 人工智慧功能和文件工作流程功能會增加原本需求簡單的專案的複雜性。

價格透明度: Nutrient.io 的企業定價需要聯繫銷售部門以取得報價,這使得預算規劃變得複雜。 預算有限的組織或需要可預測成本的組織可能更喜歡 IronPDF公佈的定價模式

API 簡潔性: Nutrient.io 的非同步優先設計要求在整個程式碼庫中採用非同步/等待模式,即使是簡單的操作也是如此。 喜歡同步程式碼或希望在同步和非同步之間靈活切換的團隊可以從 IronPDF 的方法中受益。

品牌重塑帶來的混亂: PSPDFKit 到 Nutrient.io 的過渡造成了文檔碎片化,一些資源引用了舊名稱和包裝標識符。 遇到這種困惑的團隊可以尋找命名穩定的函式庫。

整合簡易性:建立處理器、管理生命週期和處理非同步模式會增加整合開銷。 IronPDF 簡單易用的實例化和方法呼叫方式,可以縮短新開發人員的上手時間。

水印實作: Nutrient.io 中的基於註解的浮水印需要頁面迭代和註解物件建立。 IronPDF 基於 HTML 的方法利用了使用者熟悉的 Web 開發技能,只需一次呼叫即可套用浮水印。

安裝對比

Nutrient.io 安裝:

Install-Package PSPDFKit.Dotnet
Install-Package PSPDFKit.Dotnet
SHELL

IronPDF安裝:

Install-Package IronPdf
Install-Package IronPdf
SHELL

IronPDF需要在應用程式啟動時配置許可證密鑰:

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

這兩個函式庫都支援.NET Framework和現代.NET版本,因此與面向.NET 10 和 C# 14 的應用程式相容。

做出決定

Nutrient.io 和IronPDF之間的選擇取決於您的特定需求:

如果符合以下條件,請考慮使用 Nutrient.io:您的組織需要具有 AI 功能的完整文件智慧平台,您的企業預算和採購流程與銷售協商定價相匹配,並且您的應用程式架構已經完全採用非同步優先模式。

如果您有以下需求,請考慮使用IronPDF :您需要專注於 PDF 功能而不需要平台開銷;您更喜歡透明的定價和更簡單的採購方式;您希望在同步和非同步 API 模式之間靈活切換;您更重視基於 HTML 的浮水印而不是註釋物件;或者您想要內建的頁眉/頁腳佔位符來顯示頁碼。

對於在 2025 年建立現代.NET應用程式併計劃在 2026 年開發的團隊來說,評估實際需要的 PDF 功能與完整的平台功能有助於確定合適的工具。 許多專案發現,一個專注於特定領域的 PDF 庫就能滿足他們的需求,而無需使用複雜的文檔智慧平台。

IronPDF入門指南

要評估IronPDF是否滿足您的 PDF 處理需求:

  1. 安裝IronPDF NuGet套件Install-Package IronPdf
  2. 查看HTML 轉 PDF 教學課程,了解基本轉換模式
  3. 探索文件品牌浮水印功能
  4. 檢查文件組裝的PDF 合併功能

IronPDF教學提供了一個常見情境的全面範例, API 參考文件則記錄了所有可用的類別和方法。

結論

Nutrient.io 和IronPDF代表了.NET應用程式中 PDF 功能的不同實作方式。 Nutrient.io 已發展成為一個具有人工智慧功能和企業定位的文檔智慧平台,而IronPDF繼續專注於成為一個整合簡單的專用 PDF 庫。

對於需要產生、操作、添加浮水印和合併 PDF 文件而無需其他平台功能的團隊而言,IronPDF 的專注方法提供了更簡單的 API、靈活的同步/非同步模式以及基於 HTML 的浮水印功能。 降低複雜性意味著更快的整合和更容易的維護。

根據您的實際 PDF 需求、團隊對 API 模式的偏好以及預算限制,對兩種方案進行評估。 了解本比較中概述的架構差異將有助於您做出明智的決定,以滿足您的 PDF 處理需求和開發實踐。