PDF工具

IronPDF與EvoPdf:哪個.NET PDF庫在2026年提供更好的價值?

Jacob Mellor,首席技術官 @ Team Iron
Jacob Mellor
Updated: 2026年9月27日

當構建需要 PDF 功能的現代 .NET 應用程式時,選擇合適的庫可以顯著影響您的開發速度、應用程式性能和長期維護成本。IronPDF 和 EvoPdf 代表了 .NET 生態系統中 PDF 生成和操作的兩種不同方法,每種方法都有其獨特的優勢,適合不同的開發場景。

此比較檢查了兩個庫在關鍵維度上的表現,包括渲染準確性、API 設計、性能考量、平台兼容性和總擁有成本。無論您是在構建高容量文檔處理系統、簽署文檔,還是僅僅將 HTML 報告轉換為 PDF,了解這些差異將幫助您做出符合技術需求和預算限制的明智決策。

IronPDF 和 EvoPdf 的快速比較

在深入詳細比較之前,以下是這些庫在 .NET 開發者最關心的關鍵類別中的比較概覽:

產品比較概覽
IronPDF 和 EvoPdf 的 .NET PDF 生成比較
類別功能/方面IronPDFEvoPdf主要優勢
核心架構設計理念簡單優先,直觀的 API對轉換設置的細粒度控制取決於團隊偏好
API 複雜性簡單的方法如 RenderHtmlAsPdf()具有方法如 ConvertHtml() 的轉換器類兩者:單次調用轉換
平台支持跨平台Windows、Linux、macOS 通過平台特定的 NuGet 包EvoPdf Next:Windows、Linux、macOS 通過每個平台的 NuGet 包;EvoPdf Classic:Windows,加上一個調用單獨託管的 EVO PDF 服務器的跨平台客戶端兩者:跨平台本地渲染(EvoPdf Next)
.NET 版本.NET 10、9、8、7、6、5、Core 3.1+、Standard 2.0、Framework 4.6.2+Next:.NET 10、9、8、7、6、Standard 2.0、Framework 4.6.2+;Classic:Framework 2.0+兩者:現代框架支持
操作系統Windows、Linux、macOS、Docker、Azure、AWSWindows、Linux、macOS、Docker、Azure(EvoPdf Next)兩者:Docker 和雲支持
HTML 到 PDF渲染引擎Chromium(標準包中的 CEF 109;IronPdf.UpdatedChrome 中的 CEF 131)Chromium 142(EvoPdf Next);EVO 自己的引擎(EvoPdf Classic)兩者:基於 Chromium
CSS3/HTML5 支持取決於捆綁的 Chromium 版本:在 Windows 上,標準包中的 109 和 IronPdf.UpdatedChrome 中的 131(例如 Tailwind CSS v4 需要 Chrome 111 或更高版本)Next:flexbox、grid、ES2015+、web 字體兩者:取決於引擎版本
JavaScript 執行具有渲染延遲的 JavaScript 支持具有轉換延遲的 JavaScript 支持兩者:動態內容
安全性與加密加密級別RC4-128、AES-128、AES-256RC4-40、RC4-128、AES-128、AES-256兩者:可用 AES-256
權限選項細粒度權限控制細粒度權限(打印、複製、編輯、註釋、填寫表單、組裝)兩者:細粒度控制
數字簽名集成的可視簽名具有圖像和時間戳支持的可見簽名兩者:可視簽名
內容操作編輯方法真正的內容移除,單行 API未記錄的編輯功能IronPDF:內置編輯
水印基於 HTML/CSS,完整樣式用於水印和印章的 HTML 模板兩者:基於 HTML
印章統一的印章類通過模板的 HTML 印章IronPDF:專用印章類
文件轉換DOCX 到 PDF內置 DocxToPdfRenderer包含在 EVO PDF 工具包中(來自 $650),不在 HTML 到 PDF 許可中IronPDF:包含在基本許可中
開發者體驗代碼示例100 多個即用型示例GitHub 上的代碼示例,線上演示IronPDF:豐富的資源
文檔教程、操作指南、視頻、API 參考文檔、API 參考、支持 FAQIronPDF:多種學習路徑
性能並發性異步渲染方法異步方法(EvoPdf Next);持久渲染器用於並行轉換兩者:並發工作負載
許可與定價入門級Lite:$999(1 開發者,1 項目)部署:$450(1 個應用程式在 1 台服務器上,無限開發者,不可重新分發)EvoPdf:較低的初始成本
團隊許可Plus:$1,499(3 開發者,3 項目)兩個層級都不計算開發者;公司:$1,200(無限應用程式和服務器)EvoPdf:價格不依賴於團隊規模
重新分發+$1,999 免版稅(OEM/SaaS);公開 API 需要 SDK 許可僅限公司許可;不能作為獨立轉換服務或 SDKEvoPdf:包含在公司許可中
套件選項Iron Suite Lite:$2,998(10 個產品;1 開發者,1 地點,1 項目)EVO PDF 工具包公司:$1,400不同範圍:Iron Suite 添加了 OCR、條碼和 Office 工具
支持包含支持是:24/5 在線聊天;24/7 支持(試用期間包含)是,第一年(標準或優先,按許可)兩者:包含支持
最佳用途使用案例現代網頁應用程式、複雜的 PDF、編輯HTML、Word 和 Excel 到 PDF,具有公司範圍的許可取決於上下文

注意。 EvoPdf 為大型團隊提供具有競爭力的定價。IronPDF 在其基本許可中包含內置編輯和 DOCX 到 PDF 轉換。

理解 IronPDF 和 EvoPdf:核心優勢和理念

是什麼讓 IronPDF 在 .NET PDF 庫市場中脫穎而出?

IronPDF 是一個以開發者生產力為核心設計的 .NET PDF 庫。基於簡單而不犧牲功能的基礎,IronPDF 使 .NET 開發者能夠使用直觀的 API 創建、編輯和操作 PDF 文檔,這些 API 模仿了熟悉的網頁開發模式。該庫的突出特點是其基於 Chromium 的渲染引擎,能夠運行 JavaScript 並加載網頁字體;它能處理多少現代 CSS 取決於您提供的 Chromium 版本。標準的 IronPdf 包捆綁了 Chromium 109,以兼容較舊的 Windows 服務器;僅限 Windows 的 IronPdf.UpdatedChrome 包捆綁了 Chromium 131,能夠正確處理較新的 CSS 特性如 subgrid,但不支持 32 位進程、Windows Server 2012 或 SingleProcess 模式,因此這兩個包在每個目標上並不可以互換。

該庫針對渲染 HTML 文檔、操作現有 PDF 並通過加密、簽名和編輯保護文檔的應用程式。其廣泛的功能集不僅包括基本的 PDF 生成,還包括數字簽名、表單填寫、通過 IronOCR 的 OCR 集成以及文檔格式轉換如 DOCX 到 PDF 等高級功能。IronPDF 的跨平台兼容性不僅限於簡單的框架支持,還可以在 Windows、Linux、macOS、Docker 容器以及 Azure 和 AWS 等雲平台上運行。

EvoPdf 如何以不同方式處理 PDF 生成?

EvoPdf 專注於 HTML 到 PDF 的轉換,強調自定義和控制。該庫為開發者提供了對轉換過程的細粒度控制,允許對渲染參數、頁面佈局和轉換設置進行微調。EvoPdf 有兩個版本:EvoPdf Next,使用基於 Chromium 的渲染引擎(根據 EVO PDF 是 Chromium 142)並在 Windows、Linux 和 macOS 上運行;EvoPdf Classic,使用 EVO 自己的渲染引擎並在 Windows 上運行。EVO PDF 工具包添加了 Word、Excel、RTF 和 Markdown 到 PDF 的轉換以及 PDF 處理組件。

EvoPdf 的一個顯著優勢是其許可:兩個許可層級都不計算開發者,公司許可涵蓋無限的應用程式和服務器,並包括在您自己的應用程式中重新分發。對於高容量服務器工作負載,EvoPdf Next 記錄了一種持久渲染器模式,該模式在轉換之間保持渲染引擎運行。該庫還支持 ASP.NET 場景,如轉換需要身份驗證 cookie 的頁面。

兩個庫的跨平台能力如何比較?

IronPDF 的現代跨平台架構

IronPDF 可以在多個 .NET 版本、操作系統和雲平台上運行:

  • .NET 版本支持:
    • .NET 10、9、8、7、6、5 和 Core 3.1+
    • .NET Standard 2.0+
    • .NET Framework 4.6.2+
    • 完全支持 C#、VB.NET 和 F#
  • 操作系統兼容性:
    • Windows(x64;僅標準包支持 x86,因為 IronPdf.UpdatedChrome 不支持 32 位進程)
    • Linux(Ubuntu、Debian、CentOS;通過 IronPdfEngine 容器支持 Alpine)
    • macOS(Intel 和 Apple Silicon)
    • 預配置映像的 Docker 容器
  • 雲平台集成:
    • Azure App Service、Functions 和 VMs
    • AWS Lambda 和 EC2
    • Kubernetes 部署

IronPDF 在平台特定的 NuGet 包中提供其 Chromium 二進制文件(IronPdf 用於 Windows,IronPdf.Linux,IronPdf.MacOs 和 IronPdf.MacOs.ARM)。在 Linux 上,IronPDF 默認嘗試自動安裝缺少的系統依賴項;這需要 sudo 權限,否則手動安裝依賴項。這使得大多數環境的部署步驟變得簡短。

EvoPdf 的平台支持

EvoPdf 支持類似範圍的 .NET 版本,平台支持取決於版本:

  • .NET 框架支持:
    • EvoPdf Next:.NET 10、9、8、7 和 6,.NET Standard 2.0,.NET Framework 4.6.2 到 4.8.1
    • EvoPdf Classic:.NET 10 到 6,.NET Standard 2.0,.NET Framework 2.0 及更高版本
  • 平台考量:
    • EvoPdf Next:Windows(x64,ARM64)、Linux(x64,ARM64)和 macOS(ARM64),每個平台一個 NuGet 包
    • EvoPdf Next 在 Azure App Service、Azure Functions 和 Docker 中運行;渲染引擎在應用程式進程中託管,無需安裝瀏覽器
    • EvoPdf Classic:僅在 Windows 上本地渲染
    • EvoPdf Classic 客戶端:在 Windows、Linux 和 macOS 上運行,並將轉換發送到單獨安裝的 EVO PDF 服務器(作為 Azure 雲服務、IIS 應用程式或 Windows 服務安裝)

EvoPdf Next 提供了在 Windows、Linux 和 macOS 上的本地渲染。需要在 Linux 或 macOS 上運行的基於 EvoPdf Classic 的應用程式可以選擇遷移到 EvoPdf Next,EVO PDF 為此發布了 Classic 到 Next 的遷移指南,或者保持 Classic 在單獨的 EVO PDF 服務器上渲染並通過客戶端庫調用它。

哪個庫在常見任務中提供更好的 PDF 功能?

本文中的每個代碼示例都是一個完整的 .NET 8 控制台程序:使用 dotnet new console 創建一個項目,添加示例第一條評論中命名的 NuGet 包,並用示例替換 Program.cs。這些示例聲明了自己的 using 指令,因此它們可以在有或沒有隱式使用的情況下構建。它們是針對 IronPdf 2026.9.2、EvoPdf.HtmlToPdf 14.0.2 和 EvoPdf.PdfSecurity 14.0.2 編譯和運行的。IronPDF 需要一個許可密鑰,例如通過 IronPdf.License.LicenseKey 或 appsettings.json 中的 IronPdf.LicenseKey 條目設置的免費試用密鑰。EvoPdf 無需密鑰運行,並在輸出中添加評估水印。

HTML 到 PDF 轉換:渲染質量和性能

這兩個庫的最基本功能是 HTML 到 PDF 的轉換,它們的 API 採用了不同的方法。

IronPDF HTML 到 PDF 示例

// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Engines.Chrome;
using IronPdf.Rendering;

var renderer = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions
    {
        EnableJavaScript = true,

        // Page margins in millimetres
        MarginTop = 20,
        MarginBottom = 20,
        MarginLeft = 15,
        MarginRight = 15,

        CssMediaType = PdfCssMediaType.Print,
        ViewPortWidth = 1920,
        FitToPaperMode = FitToPaperModes.Automatic
    }
};

// Render only after the page calls window.ironpdf.notifyRender(), or after 10 seconds at most
renderer.RenderingOptions.WaitFor.JavaScript(10000);

// The page loads Chart.js and a Google Font from their CDNs, so the renderer needs network access
var htmlContent = @"
<!DOCTYPE html>
<html>
<head>
    <link href='https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap' rel='stylesheet'>
    <style>
        body { font-family: 'Roboto', sans-serif; }
        .chart-container { width: 100%; height: 400px; }
        @media print {
            .no-print { display: none; }
        }
    </style>
    <script src='https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js'></script>
</head>
<body>
    <h1>Dynamic Sales Report</h1>
    <div class='chart-container'>
        <canvas id='salesChart'></canvas>
    </div>
    <script>
        new Chart(document.getElementById('salesChart'), {
            type: 'line',
            data: {
                labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
                datasets: [{
                    label: 'Sales 2025',
                    data: [65, 78, 90, 81, 96],
                    borderColor: 'rgb(75, 192, 192)',
                    tension: 0.4
                }]
            },
            // No animation, so the chart is fully drawn when the constructor returns
            options: { animation: false }
        });
        window.ironpdf.notifyRender();
    </script>
</body>
</html>";

using var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("sales-report.pdf");

此 IronPDF 示例顯示:

  • JavaScript 執行: 頁面的 JavaScript(此處為 Chart.js)在渲染之前運行
  • 顯式渲染信號: WaitFor.JavaScript() 等待頁面調用 window.ironpdf.notifyRender() 而不是使用固定延遲猜測
  • 網頁字體: 頁面引用的字體被加載並嵌入
  • 打印媒體查詢: CssMediaType.Print 應用頁面的 @media print 規則

EvoPdf HTML 到 PDF 示例

// NuGet: Install-Package EvoPdf.HtmlToPdf  (EvoPdf Classic, Windows)
using System.IO;
using EvoPdf;

HtmlToPdfConverter converter = new HtmlToPdfConverter();

// Production use needs a license key. Leave this line out to evaluate:
// the output then carries an evaluation watermark. An invalid key makes the conversion throw.
// converter.LicenseKey = "<your EvoPdf license key>";

converter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
converter.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Portrait;

// EvoPdf margins are in points (1/72 inch): 57 pt is about 20 mm, 43 pt about 15 mm,
// matching the IronPDF example above, whose margins are in millimetres
converter.PdfDocumentOptions.TopMargin = 57;
converter.PdfDocumentOptions.BottomMargin = 57;
converter.PdfDocumentOptions.LeftMargin = 43;
converter.PdfDocumentOptions.RightMargin = 43;

converter.JavaScriptEnabled = true;
converter.ConversionDelay = 2; // seconds

// For pages behind HTTP authentication, also set
// converter.AuthenticationOptions.Username and .Password

// Convert HTML string
string htmlString = @"
<html>
<head>
    <style>
        body { font-family: Arial, sans-serif; }
        table { border-collapse: collapse; width: 100%; }
        th, td { border: 1px solid #ddd; padding: 8px; }
    </style>
</head>
<body>
    <h1>Invoice</h1>
    <table>
        <tr>
            <th>Item</th>
            <th>Quantity</th>
            <th>Price</th>
        </tr>
        <tr>
            <td>Product A</td>
            <td>5</td>
            <td>$50.00</td>
        </tr>
    </table>
</body>
</html>";

// Perform conversion
byte[] pdfBytes = converter.ConvertHtml(htmlString, "");

// Save to file
File.WriteAllBytes("invoice.pdf", pdfBytes);

EvoPdf 的轉換器遵循配置然後轉換的模式:設置 PdfDocumentOptions,然後調用 ConvertHtml() 或 ConvertUrl()。本文中的每個 EvoPdf 示例都使用 EvoPdf Classic API(EvoPdf.HtmlToPdf 包),該 API 在 Windows 上渲染。EvoPdf Next,基於 Chromium 的版本,是一組單獨的 NuGet 包,具有自己的 API:例如,其許可密鑰在每個進程中設置一次在靜態 Licensing.LicenseKey 屬性上。EVO 在 Next 中記錄了對 flexbox、grid、ES2015+ JavaScript 和網頁字體的支持。

PDF 安全性和加密:保護敏感文檔

在處理敏感文檔時,安全性至關重要。兩個庫都提供密碼保護、權限控制和加密。

IronPDF 高級安全實現

// NuGet: Install-Package IronPdf
using System;
using IronPdf;
using IronPdf.Editing;
using IronPdf.Security;
using IronPdf.Signing;
using IronSoftware.Drawing;

using var pdf = PdfDocument.FromFile("confidential-report.pdf");

// Finish every content change before signing
pdf.ApplyWatermark("<h2 style='color:red; opacity:0.5;'>CONFIDENTIAL</h2>",
    45, VerticalAlignment.Middle, HorizontalAlignment.Center);

// Descriptive document properties (these do not restrict access)
pdf.MetaData.Author = "Finance Team";
pdf.MetaData.Title = "Quarterly Report (Internal)";
pdf.MetaData.ModifiedDate = DateTime.UtcNow;

// Owner password: required to change the permissions below
pdf.SecuritySettings.OwnerPassword = "owner-password";

// User password: required to open the document
pdf.SecuritySettings.UserPassword = "user-password";

pdf.SecuritySettings.AllowUserCopyPasteContentForAccessibility = false;
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = true;
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.PrintLowQuality;
pdf.SecuritySettings.EncryptionType = PdfEncryptionType.Aes_256;

// Visible digital signature: image file, page index, and position/size on the page
var signature = new PdfSignature("certificate.pfx", "cert-password")
{
    SigningReason = "Document Approval",
    SigningLocation = "Head Office",
    SigningContact = "security@example.com",
    SignatureImage = new PdfSignatureImage("signature.png", 0, new Rectangle(100, 100, 200, 50))
};
pdf.Sign(signature);

// The signature is applied when the file is saved
pdf.SaveAs("secured-document.pdf");

IronPDF 的安全功能顯示如下:

  • 細粒度權限: 控制打印質量、複製、註釋、表單填寫和編輯
  • 可見數字簽名: 帶有原因、位置和簽名圖像的簽名
  • 文檔屬性: 設置作者、標題和日期(僅描述性)
  • 分層保護: 在一個文檔上結合水印、加密和簽名

EvoPdf 安全配置

// NuGet: Install-Package EvoPdf.PdfSecurity
// (licensed with the EVO PDF Toolkit; not included in the standalone HTML to PDF license)
using EvoPdf.PdfSecurity;

PdfSecurityOptions securityOptions = new PdfSecurityOptions();

// Set basic security parameters
securityOptions.UserPassword = "user123";
securityOptions.OwnerPassword = "owner456";
securityOptions.EncryptionAlgorithm = EncryptionAlgorithm.AES;
securityOptions.KeySize = EncryptionKeySize.EncryptKey256Bit;

// Configure permissions
securityOptions.CanPrint = true;
securityOptions.CanCopyContent = false;
securityOptions.CanEditContent = false;
securityOptions.CanEditAnnotations = false;
securityOptions.CanFillFormFields = true;
securityOptions.CanAssembleDocument = false;

// Apply security to existing PDF
PdfSecurityManager securityManager = new PdfSecurityManager(securityOptions);
securityManager.SaveSecuredPdfToFile("input.pdf", "secured-output.pdf");

EvoPdf涵蓋相同的核心控制:用戶和擁有者密碼、加密以及列印、複製、編輯、註釋、表單填寫和文件組裝的權限。EVO將算法(RC4或AES)和密鑰大小(40、128或256位)記錄為單獨的設置;在我們使用版本14.0.2的測試中,RC4使用40或128位密鑰和AES使用128或256位密鑰產生了預期的加密,因此使用AES-128或AES-256;RC4是一種遺留算法。使用獨立的HTML到PDF許可證,轉換器自己的PdfSecurityOptions在生成PDF時應用相同的保護,而不需要單獨的PDF安全組件。

內容刪除:移除敏感信息

在共享文件之前永久移除敏感文本是處理個人數據的應用程序中的常見要求。刪除是這項工作的基礎之一;單靠它並不能使應用程序符合GDPR、HIPAA或CCPA等法規。

IronPDF刪除範例

// NuGet: Install-Package IronPdf
using IronPdf;
using IronSoftware.Drawing;

// This example expects a PDF with at least three pages
using var pdf = PdfDocument.FromFile("customer-records.pdf");

// 1. Redact a specific value on every page
pdf.RedactTextOnAllPages("123-45-6789");

// 2. Redact a word on specific pages (zero-based page indexes)
pdf.RedactTextOnPages(new[] { 0, 1, 2 }, "Confidential", CaseSensitive: false);

// 3. Redact a rectangular region on the first page
pdf.RedactRegionOnPage(0, new RectangleF(100, 200, 300, 50));

// 4. Replace a complete sensitive value with a label instead of drawing a black box
pdf.RedactTextOnAllPages("ACCT-0042-7781", DrawRectangles: false, ReplacementText: "[REDACTED]");

pdf.SaveAs("redacted-records.pdf");

IronPDF的刪除功能包括:

  • 內容移除: 匹配的文本從頁面內容中移除,因此不僅僅是被覆蓋,無法再提取
  • 匹配選項: 區分大小寫和整字匹配
  • 刪除外觀: 繪製黑色框或插入替換文本
  • 選擇性刪除: 針對特定頁面或區域

文本刪除匹配頁面內容中的文本。圖像內的文本,例如掃描頁面,不會匹配;區域刪除覆蓋固定區域,無論其中有什麼。EvoPdf未記錄刪除功能。

表單處理:創建互動式PDF

兩個庫都支持PDF表單,但創建和操作的方法不同。

IronPDF表單範例

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

// Create a new PDF with an HTML form
var html = @"
<html>
<body>
    <h2>Employee Information Form</h2>
    <form>
        <label>Full Name:</label>
        <input type='text' name='fullName' required />
        
        <label>Email:</label>
        <input type='email' name='email' required />
        
        <label>Department:</label>
        <select name='department'>
            <option value=''>Select Department</option>
            <option value='IT'>Information Technology</option>
            <option value='HR'>Human Resources</option>
            <option value='Sales'>Sales</option>
        </select>
        
        <label>Start Date:</label>
        <input type='text' name='startDate' placeholder='YYYY-MM-DD' />
        
        <label>
            <input type='checkbox' name='agreement' />
            I agree to the terms and conditions
        </label>
        
        <button type='submit'>Submit</button>
    </form>
</body>
</html>";

var renderer = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions
    {
        CreatePdfFormsFromHtml = true // Enable form field creation
    }
};

using var pdf = renderer.RenderHtmlAsPdf(html);

// Programmatically fill form fields
pdf.Form.FindFormField("fullName").Value = "John Doe";
pdf.Form.FindFormField("email").Value = "john.doe@example.com";
// A dropdown takes one of its displayed choices, not the HTML option value ("IT")
pdf.Form.FindFormField("department").Value = "Information Technology";
pdf.Form.FindFormField("startDate").Value = DateTime.Now.ToString("yyyy-MM-dd");
// "Yes" is the checkbox's checked state
pdf.Form.FindFormField("agreement").Value = "Yes";

// Make specific fields read-only
pdf.Form.FindFormField("email").ReadOnly = true;

// Save as fillable form
pdf.SaveAs("fillable-form.pdf");

// Or flatten the form (convert to static content)
pdf.Flatten();
pdf.SaveAs("completed-form.pdf");

IronPDF的表單處理功能:

  • 自動表單生成: 將HTML表單轉換為PDF表單
  • 程序化操作: 通過API填寫、讀取和修改表單字段
  • 字段類型: 文本輸入(包括電子郵件、數字和電話輸入)和文本區域成為文本字段;複選框、單選按鈕和下拉列表保持其類型。HTML日期輸入不會轉換為表單字段,這就是為什麼上面的開始日期使用文本輸入。
  • 字段屬性: 設置值和只讀標誌
  • 表單平面化: 將填寫的表單轉換為靜態PDF

性能考量

性能特徵根據文件的複雜性和使用情況顯著不同:

計時一批文件

// NuGet: Install-Package IronPdf
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using IronPdf;

// Timing harness for a batch of documents. Replace the generated HTML with your own templates.
const int documentCount = 100;
const int maxConcurrency = 4;

var htmlDocuments = Enumerable.Range(1, documentCount)
    .Select(i => $"<html><body><h1>Invoice {i}</h1><p>Amount due: {i * 10} USD</p></body></html>")
    .ToList();

var renderer = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions
    {
        EnableJavaScript = false // static content only
    }
};

// Cap how many renders run at once instead of starting every render immediately
using var gate = new SemaphoreSlim(maxConcurrency);
var stopwatch = Stopwatch.StartNew();

var tasks = htmlDocuments.Select(async (html, index) =>
{
    await gate.WaitAsync();
    try
    {
        using var pdf = await renderer.RenderHtmlAsPdfAsync(html);
        pdf.SaveAs($"invoice-{index + 1}.pdf");
    }
    finally
    {
        gate.Release();
    }
});
await Task.WhenAll(tasks);

stopwatch.Stop();
Console.WriteLine($"Documents: {documentCount}, at most {maxConcurrency} at a time");
Console.WriteLine($"Total elapsed: {stopwatch.ElapsedMilliseconds} ms");
// Elapsed time divided by the document count: an amortized figure, not the latency of one request
Console.WriteLine($"Amortized time per document: {stopwatch.ElapsedMilliseconds / (double)documentCount:F1} ms");
// Resident memory of this process only, sampled once at the end; the Chromium helper
// processes are not included, and this is not the peak
Console.WriteLine($"Working set of this process at end: {Process.GetCurrentProcess().WorkingSet64 / 1024 / 1024} MB");

本文未提供比較基準:結果取決於模板、硬件和部署,因此請自行測量。每個庫的記錄槓桿:

  • IronPDF引擎版本: 對於現代、JavaScript繁重或深度嵌套頁面的慢速渲染,包括基於Bootstrap或Tailwind構建的頁面,IronPDF建議使用IronPdf.UpdatedChrome package,該包捆綁了Chromium 131,而不是標準包的Chromium 109
  • IronPDF並發性: 異步渲染方法如RenderHtmlAsPdfAsync,自行限制同時運行的渲染數量
  • EvoPdf Next渲染模式: GlobalSettings.HtmlRendererMode設置為PersistentProcess(默認)在轉換之間保持一個渲染引擎進程運行,ProcessPerConversion為每次轉換啟動一個;轉換可以並行運行,每個都有自己的轉換器,GlobalSettings.MaxParallelConversions限制同時運行的數量
  • EvoPdf Next異步方法: ConvertHtmlAsync和ConvertUrlAsync用於async/await代碼

不同團隊規模的定價模型如何比較?

IronPDF許可結構

IronPDF提供多種定價選項,包括Lite、Plus和Professional許可證,並可選擇免版稅再分發。許可模式旨在根據您的團隊和項目需求進行擴展(截至2026年9月的定價):

  • Lite許可證:$999
    • 1位開發者
    • 1個地點
    • 1個項目
    • 電子郵件支持
    • 理想對象:個人開發者,小型項目
  • Plus許可證:$1,499
    • 3位開發者
    • 3個地點
    • 3個項目
    • 電子郵件(48小時SLA)和在線聊天支持
    • 理想對象:小型團隊,多個項目
  • Professional許可證:$2,999
    • 10位開發者
    • 10個地點
    • 10個項目
    • 電子郵件(24小時SLA)、在線聊天、電話和屏幕共享支持
    • 理想對象:中型到大型團隊
  • 其他選項:
    • 免版稅再分發(OEM/SaaS):+$1,999,適用於商業軟件和SaaS,最終用戶不直接調用IronPDF的API
    • SDK許可證:當產品通過公共API向其他開發者公開IronPDF的功能時需要
    • 支持和更新擴展:1、3或5年,按許可級別定價
    • Iron Suite:所有10個Iron Software產品,按相同級別許可;Iron Suite Lite(1位開發者,1個地點,1個項目)為$2,998

EvoPdf許可選項

EVO PDF Toolkit和獨立的HTML到PDF轉換器各提供兩個許可級別,部署和公司(截至2026年9月的定價;請在evopdf.com/buy驗證當前定價)。HTML到PDF許可證涵蓋Next和Classic轉換器;其他組件,如PDF安全性,僅包含在Toolkit中。

  • 部署許可證:
    • EVO HTML到PDF:$450
    • EVO PDF Toolkit:$650
    • 一個應用程序部署在一台服務器上,由您自己的公司使用
    • 無限開發者在該應用程序上工作
    • 負載均衡、容器化或自動擴展部署需要公司許可證
    • 無再分發
    • 第一年的標準支持
  • 公司許可證:
    • EVO HTML到PDF:$1,200
    • EVO PDF Toolkit:$1,400
    • 無限開發者、應用程序和服務器
    • 在您的應用程序內向您自己的客戶再分發;許可協議不允許將轉換功能作為獨立服務、託管API或SDK提供,除非得到EVO的書面許可
    • 第一年的優先支持

總擁有成本分析

以下每個場景都陳述其部署假設,因為兩個供應商都按範圍和團隊規模定價:

場景1:兩位開發者,一個內部應用程序在一台服務器上

  • IronPDF Plus:$1,499(Lite涵蓋1位開發者,因此2人團隊需要Plus,涵蓋最多3位)
  • EvoPdf部署:$450(一個應用程序在一台服務器上;不計算開發者)
  • 如果應用程序在多台服務器上運行,位於負載均衡器後面或在自動擴展容器中,EvoPdf需要公司許可證($1,200)
  • 較低的許可成本: EvoPdf

場景2:五位開發者,多個內部應用程序

  • IronPDF Professional:$2,999(最多10位開發者,10個地點,10個項目;Plus僅涵蓋3位開發者)
  • EvoPdf公司:$1,200(多於一個應用程序需要公司許可證)
  • 較低的許可成本: EvoPdf

場景3:需要PDF和其他文檔工具的十位開發者

  • Iron Suite Professional:10位開發者,10個地點,10個項目,所有10個Iron Software產品(請參閱Iron Suite許可頁面以獲取當前價格)
  • EVO PDF Toolkit公司:$1,400(無限開發者、應用程序和服務器;專注於PDF,無OCR或條碼工具)
  • 不同範圍: 如果您只需要PDF工具,EVO PDF Toolkit成本較低。Iron Suite增加了OCR、條碼、Excel、Word和其他庫,Toolkit無法替代。僅在匹配的開發者和部署範圍內比較兩者。

場景4:為其客戶生成PDF的商業SaaS產品

  • IronPDF Professional + OEM再分發:$2,999 + $1,999(涵蓋SaaS,最終用戶不直接調用IronPDF的API)
  • EvoPdf公司:$1,200(包括再分發;PDF生成必須是您產品的一個功能,而不是通用轉換服務)
  • 較低的許可成本: EvoPdf,前提是產品不將轉換功能作為服務或公共API公開;兩個供應商都單獨許可這種情況

現代CSS框架如何影響您的選擇?

在選擇PDF庫時,經常被低估的因素是對現代CSS框架的支持。隨著Bootstrap、Tailwind CSS和Foundation在Web開發中的廣泛使用,您的庫處理這些框架的能力直接影響開發效率和輸出質量。

IronPDF:框架支持取決於Chromium版本

IronPDF的Chromium引擎渲染CSS框架與捆綁的Chromium版本一樣,因此檢查框架的瀏覽器要求與您發佈的包:

  • Bootstrap 5: 支持Flexbox和CSS Grid佈局
  • Tailwind CSS: Tailwind CSS v4需要Chrome 111或更高版本,這比標準Windows包的Chromium 109更新,因此在Windows上v4佈局需要IronPdf.UpdatedChrome package(Chromium 131)。Tailwind建議在必須支持舊瀏覽器的情況下保持在v3.4。使用您部署的包測試自己的模板。
  • 現代CSS3: 支持變換和自定義屬性
  • 引擎版本很重要: 一些較新的CSS,如subgrid、overflow: hidden邊緣情況和自定義行高,僅在IronPdf.UpdatedChrome中正確渲染,IronPDF也建議在Bootstrap或Tailwind頁面渲染緩慢時使用。IronPdf.UpdatedChrome不支持32位進程、Windows Server 2012或SingleProcess模式,因此在切換之前確認您的部署目標。

代碼範例:Bootstrap時間軸組件

// NuGet: Install-Package IronPdf
using IronPdf;

var renderer = new ChromePdfRenderer();

string bootstrapTimeline = @"
<!DOCTYPE html>
<html>
<head>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
    <style>
        .timeline { position: relative; padding: 20px 0; }
        .timeline::before {
            content: '';
            position: absolute;
            left: 50%;
            width: 2px;
            height: 100%;
            background: #dee2e6;
        }
        .timeline-item { position: relative; margin: 20px 0; }
    </style>
</head>
<body>
    <div class='container py-5'>
        <h2 class='text-center mb-5'>Project Timeline</h2>
        <div class='timeline'>
            <div class='timeline-item'>
                <div class='row'>
                    <div class='col-md-6'>
                        <div class='card shadow-sm'>
                            <div class='card-body'>
                                <h5 class='card-title'>Phase 1: Planning</h5>
                                <p class='text-muted'>Q1 2025</p>
                                <p class='card-text'>Initial project scope and requirements gathering completed.</p>
                                <span class='badge bg-success'>Completed</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Additional timeline items... -->
        </div>
    </div>
</body>
</html>";

// The page loads Bootstrap from a CDN, so the renderer needs network access
using var pdf = renderer.RenderHtmlAsPdf(bootstrapTimeline);
pdf.SaveAs("project-timeline.pdf");

EvoPdf:Next中的Chromium,Classic中的EVO引擎

EvoPdf的兩個版本以不同方式處理現代CSS:

  • EvoPdf Next: 基於Chromium的引擎(根據EVO PDF,Chromium 142)具有記錄的支持Flexbox、Grid、ES2015+ JavaScript和Web字體
  • EvoPdf Classic: EVO自己的渲染引擎,EVO描述為支持CSS3、SVG、Web字體和JavaScript;新版本增加了ECMAScript 6、WOFF 2、HTTP/2和TLS 1.3

開發影響: 如果您的應用程序廣泛使用Bootstrap或Tailwind,並且您需要與Web界面匹配的PDF,請使用每個庫的試用版測試您的真實模板。由於雙方都使用基於Chromium的引擎(IronPDF和EvoPdf Next),差異更可能來自引擎版本和配置,而不是框架支持。

有關CSS框架兼容性的更多信息,請參閱Bootstrap & Flexbox CSS指南。

哪些文檔和支持選項更好地服務於開發者?

IronPDF的開發者資源

IronPDF提供文檔、24/5在線聊天、24/7工程支持(使用高級支持)、視頻教程和定期更新。支持生態系統包括:

  • 文檔質量:
  • 支持渠道:
    • 24/7工程支持(使用高級支持),適用於付費許可證;試用用戶在試用期間獲得高級支持
    • 電子郵件響應SLA:48小時(Plus)、24小時(Professional)、12小時(Unlimited)
    • 所有許可級別的在線聊天,24/5
    • Professional和Unlimited許可證的電話支持
    • Professional和Unlimited許可證的屏幕共享
  • 學習資源:
    • 入門指南
    • 性能優化指南
    • 安全最佳實踐
    • 雲部署指南

EvoPdf的支持結構

EvoPdf通過以下方式提供文檔和支持:

  • 文檔:
    • API參考文檔
    • 常見場景的代碼範例,以及GitHub上的代碼樣本
    • 在線演示應用程序
    • 涵蓋許可、部署和轉換的支持FAQ
  • 支持選項:
    • 包括第一年的技術支持,並在評估期間免費
    • 標準支持(部署許可證)或優先支持(公司許可證)
    • 第一年的維護續約可用

主要區別在於IronPDF的教育內容廣度(教程、操作指南和視頻)以及24/5在線聊天和24/7支持(使用高級支持)。

每個庫的最佳使用案例是什麼?

何時選擇IronPDF

IronPDF在需要以下情況下表現出色:

1. 現代Web應用程序集成

  • 生成動態報告的SaaS平台
  • 創建帶有圖表的發票的電子商務網站
  • 作為PDF導出的商業智能儀表板
  • 使用React、Angular或Vue.js的應用程序

2. 含有敏感內容的文件

  • 在共享文件之前移除個人數據
  • 加密和密碼保護生成的報告
  • 簽署文件以便檢測後續更改
  • 含有刪除功能的法律文件管理

3. 複雜的文件處理

  • 多格式文件轉換(DOCX、HTML、圖像)
  • 通過IronOCR對掃描文件進行OCR
  • 使用並行執行進行批量處理
  • 含有數字簽名的文件

4. 跨平台部署

  • Docker容器化應用程序
  • 基於Linux的雲部署
  • 微服務架構
  • 無服務器功能(AWS Lambda、Azure Functions)

範例:保護生成的報告

// NuGet: Install-Package IronPdf
using System.Net;
using IronPdf;
using IronPdf.Security;
using IronPdf.Signing;

var patient = new PatientRecord("P-10442", "Jane <Q.> Doe & Family", "123-45-6789", "open-sesame");

// HTML-encode text values, so characters such as & and < print as text instead of changing the markup
var html = $@"
<html>
<body>
    <h1>Patient Summary</h1>
    <p>Patient ID: {WebUtility.HtmlEncode(patient.PatientId)}</p>
    <p>Name: {WebUtility.HtmlEncode(patient.Name)}</p>
    <p>SSN: {WebUtility.HtmlEncode(patient.Ssn)}</p>
</body>
</html>";

var renderer = new ChromePdfRenderer();
using var pdf = renderer.RenderHtmlAsPdf(html);

// Remove the SSN from the page content wherever it appears
pdf.RedactTextOnAllPages(patient.Ssn);

// Descriptive document properties
pdf.MetaData.Author = "Records System";
pdf.MetaData.Title = $"Patient Summary {patient.PatientId}";

// Require a password to open the file, restrict copying, and encrypt with AES-256
pdf.SecuritySettings.UserPassword = patient.AccessCode;
pdf.SecuritySettings.OwnerPassword = "records-owner-password";
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SecuritySettings.EncryptionType = PdfEncryptionType.Aes_256;

// Sign last, so changes made to the file after signing can be detected
pdf.Sign(new PdfSignature("records-cert.pfx", "password")
{
    SigningReason = "Record export",
    SigningLocation = "Records Department"
});

pdf.SaveAs("patient-summary.pdf");

record PatientRecord(string PatientId, string Name, string Ssn, string AccessCode);

這些是文件處理的基礎。應用程序是否符合HIPAA等法規還取決於它如何存儲、傳輸和控制對數據的訪問,這不是任何PDF設置本身能夠確立的。

何時選擇EvoPdf

EvoPdf適合以下情況:

1. HTML到PDF轉換

  • 從HTML模板構建的報告
  • 使用基於Chromium的EvoPdf Next的現代HTML、CSS和JavaScript
  • 發票和收據
  • 使用一致模板的大量文件生成

2. 預算有限的團隊

  • 單一許可證上的無限開發者
  • 較低的入門成本($450部署許可證)
  • 不需要內置刪除的項目

3. 特定服務器環境

  • 遺留.NET Framework應用程序(EvoPdf Classic支持.NET Framework 2.0及更高版本)
  • 單一應用程序的每服務器許可
  • 遺留系統集成

4. 高容量轉換

  • 靜態報告生成
  • 文檔系統
  • 可打印文件創建

真實範例:發票生成系統

// NuGet: Install-Package EvoPdf.HtmlToPdf  (EvoPdf Classic, Windows)
using System;
using System.Globalization;
using System.IO;
using System.Net;
using EvoPdf;

var invoice = new InvoiceData("INV-2026-0042", new DateTime(2026, 9, 1), "Smith & Sons <Ltd>", 1250.00m);

var converter = new HtmlToPdfConverter
{
    // LicenseKey = "<your EvoPdf license key>",
    JavaScriptEnabled = false, // not needed for static invoices
    ConversionDelay = 0
};
converter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
converter.PdfDocumentOptions.TopMargin = 30;    // points
converter.PdfDocumentOptions.BottomMargin = 30; // points

string template =
    "<html><body><h1>Invoice {{InvoiceNumber}}</h1>" +
    "<p>Date: {{Date}}</p><p>Customer: {{CustomerName}}</p><p>Total: {{Total}}</p></body></html>";

// HTML-encode text values, so characters such as & and < print as text instead of changing the markup
string html = template
    .Replace("{{InvoiceNumber}}", WebUtility.HtmlEncode(invoice.InvoiceNumber))
    .Replace("{{Date}}", invoice.Date.ToString("yyyy-MM-dd"))
    .Replace("{{CustomerName}}", WebUtility.HtmlEncode(invoice.CustomerName))
    .Replace("{{Total}}", invoice.Total.ToString("C", CultureInfo.GetCultureInfo("en-US")));

File.WriteAllBytes($"invoice-{invoice.InvoiceNumber}.pdf", converter.ConvertHtml(html, ""));

record InvoiceData(string InvoiceNumber, DateTime Date, string CustomerName, decimal Total);

高級實施模式和最佳實踐

在生產中優化性能

兩個庫都受益於適當的配置和使用模式:

IronPDF性能優化

// NuGet: Install-Package IronPdf
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using IronPdf;
using IronPdf.Engines.Chrome;
using IronPdf.Rendering;

// Global engine settings: set once at startup, before the first render
Installation.ChromeGpuMode = ChromeGpuModes.Disabled; // servers usually have no GPU
// Set to false only if the Linux dependencies are already installed in your image
Installation.LinuxAndDockerDependenciesAutoConfig = false;

var service = new PdfService(maxConcurrency: 4);
var pages = Enumerable.Range(1, 8).Select(i => $"<h1>Report {i}</h1>");
byte[][] results = await Task.WhenAll(pages.Select(service.GeneratePdfAsync));

for (int i = 0; i < results.Length; i++)
    File.WriteAllBytes($"report-{i + 1}.pdf", results[i]);
Console.WriteLine($"Generated {results.Length} PDFs");

public class PdfService
{
    private readonly ChromePdfRenderer _renderer;
    private readonly SemaphoreSlim _gate;

    public PdfService(int maxConcurrency)
    {
        // Caps how many renders run at once
        _gate = new SemaphoreSlim(maxConcurrency);

        _renderer = new ChromePdfRenderer
        {
            RenderingOptions = new ChromePdfRenderOptions
            {
                EnableJavaScript = false, // only if the pages need no JavaScript
                CssMediaType = PdfCssMediaType.Screen,
                Timeout = 30 // seconds
            }
        };
    }

    public async Task<byte[]> GeneratePdfAsync(string html)
    {
        await _gate.WaitAsync();
        try
        {
            using var pdf = await _renderer.RenderHtmlAsPdfAsync(html);
            return pdf.BinaryData;
        }
        finally
        {
            _gate.Release();
        }
    }
}

EvoPdf性能模式

// NuGet: Install-Package EvoPdf.HtmlToPdf  (EvoPdf Classic, Windows)
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EvoPdf;

var service = new EvoPdfService(maxConcurrency: 4);
var pages = Enumerable.Range(1, 8).Select(i => $"<h1>Report {i}</h1>");
byte[][] results = await Task.WhenAll(pages.Select(service.GeneratePdfAsync));

for (int i = 0; i < results.Length; i++)
    File.WriteAllBytes($"evopdf-report-{i + 1}.pdf", results[i]);
Console.WriteLine($"Generated {results.Length} PDFs");

public class EvoPdfService
{
    private readonly SemaphoreSlim _gate;

    // Caps how many conversions run at once
    public EvoPdfService(int maxConcurrency) => _gate = new SemaphoreSlim(maxConcurrency);

    public async Task<byte[]> GeneratePdfAsync(string html)
    {
        await _gate.WaitAsync();
        try
        {
            // A new converter for each conversion, as EVO documents for parallel conversions
            var converter = new HtmlToPdfConverter
            {
                // LicenseKey = "<your EvoPdf license key>",
                JavaScriptEnabled = false,
                ConversionDelay = 0
            };

            // The Classic API is synchronous, so run it on a thread-pool thread
            return await Task.Run(() => converter.ConvertHtml(html, ""));
        }
        finally
        {
            _gate.Release();
        }
    }
}

信號量是限制並發性的原因。在EvoPdf Next中,GlobalSettings.MaxParallelConversions在庫內設置相同類型的限制,持久渲染器在轉換之間保持渲染引擎進程運行。

錯誤處理和調試

生產代碼需要處理渲染失敗,例如無法加載的頁面:

IronPDF錯誤處理

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

// Write IronPDF's own diagnostics to a log file
IronPdf.Logging.Logger.LogFilePath = "ironpdf.log";
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.Timeout = 60; // seconds

byte[] page = await TryRenderUrlAsync(renderer, "https://example.com/");
if (page != null)
{
    File.WriteAllBytes("example.pdf", page);
    Console.WriteLine($"Rendered {page.Length} bytes");
}

// A host that does not resolve makes the render throw, which exercises the error path
byte[] missing = await TryRenderUrlAsync(renderer, "https://nonexistent.invalid/");
Console.WriteLine(missing == null ? "Second render failed and was handled" : "Second render succeeded");

// Returns the PDF bytes, or null if the page could not be rendered
static async Task<byte[]> TryRenderUrlAsync(ChromePdfRenderer renderer, string url)
{
    try
    {
        using var pdf = await renderer.RenderUrlAsPdfAsync(url);
        if (pdf.PageCount == 0)
        {
            Console.Error.WriteLine($"No pages rendered for {url}");
            return null;
        }
        return pdf.BinaryData;
    }
    catch (IronPdfNativeException ex)
    {
        // Raised by the rendering engine, for example when the page cannot be loaded
        Console.Error.WriteLine($"Rendering failed for {url}: {ex.Message}");
        return null;
    }
}

行業特定實施範例

財務報告:簽署的只讀報表

應在批准後不應更改的報表可以結合水印、受限權限和簽名:

// NuGet: Install-Package IronPdf
using System;
using IronPdf;
using IronPdf.Editing;
using IronPdf.Security;
using IronPdf.Signing;
using IronSoftware.Drawing;

var renderer = new ChromePdfRenderer();
using var pdf = renderer.RenderHtmlAsPdf(
    "<h1>Quarterly Statement: Q3 2026</h1>" +
    "<table><tr><td>Revenue</td><td>1,250,000</td></tr><tr><td>Expenses</td><td>980,000</td></tr></table>");

// Mark the document as a draft
pdf.ApplyWatermark(@"
    <div style='color: rgba(0,0,0,0.1); font-size: 120px; transform: rotate(-45deg); font-family: Arial;'>
        DRAFT
    </div>", 30, VerticalAlignment.Middle, HorizontalAlignment.Center);

// Descriptive document properties: useful for search and filing, not a record of who changed what
pdf.MetaData.Author = "Financial Reporting System";
pdf.MetaData.Keywords = "Quarterly Statement, Q3 2026";
pdf.MetaData.CustomProperties.Add("ReportPeriod", "2026-Q3");
pdf.MetaData.CustomProperties.Add("GeneratedAt", DateTime.UtcNow.ToString("O"));

// Restrict editing; the owner password is needed to change these permissions
pdf.SecuritySettings.OwnerPassword = "finance-owner-password";
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;
pdf.SecuritySettings.AllowUserCopyPasteContent = true;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SecuritySettings.EncryptionType = PdfEncryptionType.Aes_256;

// Sign last: readers can then detect changes made after signing
pdf.Sign(new PdfSignature("financial-cert.pfx", "password")
{
    SigningReason = "Statement approval",
    SigningLocation = "Finance Department",
    // Visible signature image on the first page
    SignatureImage = new PdfSignatureImage("cfo-signature.png", 0, new Rectangle(50, 50, 200, 60))
});

pdf.SaveAs("quarterly-statement.pdf");

簽名使後續更改可檢測,權限阻止編輯;兩者都不是合規控制或誰做了什麼的審計跟蹤。

電子商務:動態發票生成

電子商務平台需要快速、可靠的發票生成:

// NuGet: Install-Package IronPdf
using System;
using System.Globalization;
using System.Linq;
using System.Net;
using IronPdf;
using IronPdf.Rendering;

var order = new Order("INV-1001", new DateTime(2026, 9, 1), new[]
{
    new OrderItem("Widget <Deluxe> & Co. edition", 2, 19.99m),
    new OrderItem("Gift wrap", 1, 4.50m)
});

var renderer = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions
    {
        MarginTop = 10,    // millimetres
        MarginBottom = 10,
        PaperSize = PdfPaperSize.A4
    }
};

var usd = CultureInfo.GetCultureInfo("en-US");

// HTML-encode text values, so characters such as & and < print as text instead of changing the markup
string rows = string.Concat(order.Items.Select(item => $@"
        <tr>
            <td>{WebUtility.HtmlEncode(item.Name)}</td>
            <td>{item.Quantity}</td>
            <td>{item.Price.ToString("C", usd)}</td>
            <td>{item.Total.ToString("C", usd)}</td>
        </tr>"));

var html = $@"
<html>
<head>
    <style>
        body {{ font-family: Arial, sans-serif; }}
        .invoice-header {{ background: #f0f0f0; padding: 20px; }}
        table {{ width: 100%; border-collapse: collapse; }}
        th, td {{ padding: 10px; border-bottom: 1px solid #ddd; text-align: left; }}
    </style>
</head>
<body>
    <div class='invoice-header'>
        <h1>Invoice #{WebUtility.HtmlEncode(order.InvoiceNumber)}</h1>
        <p>Date: {order.Date:yyyy-MM-dd}</p>
    </div>
    <table>
        <tr><th>Item</th><th>Quantity</th><th>Price</th><th>Total</th></tr>
        {rows}
        <tr><td colspan='3'><strong>Total</strong></td><td><strong>{order.Total.ToString("C", usd)}</strong></td></tr>
    </table>
    <p>Thank you for your business!</p>
</body>
</html>";

using var pdf = await renderer.RenderHtmlAsPdfAsync(html);
pdf.SaveAs($"invoice-{order.InvoiceNumber}.pdf");

record OrderItem(string Name, int Quantity, decimal Price)
{
    public decimal Total => Price * Quantity;
}

record Order(string InvoiceNumber, DateTime Date, OrderItem[] Items)
{
    public decimal Total => Items.Sum(item => item.Total);
}

遷移策略:在庫之間移動

如果您考慮在庫之間切換,這是遷移方法:

從EvoPdf遷移到IronPDF

// NuGet: Install-Package EvoPdf.HtmlToPdf  (EvoPdf Classic, Windows)
// NuGet: Install-Package IronPdf
using System.IO;
using EvoPdf;
using IronPdf;
using IronPdf.Rendering;

string url = "https://example.com/";

// EvoPdf pattern
HtmlToPdfConverter evoPdfConverter = new HtmlToPdfConverter();
evoPdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
File.WriteAllBytes("evopdf.pdf", evoPdfConverter.ConvertUrl(url));

// Equivalent IronPDF pattern
var ironPdfRenderer = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions
    {
        PaperSize = PdfPaperSize.A4
    }
};
using (var pdf = ironPdfRenderer.RenderUrlAsPdf(url))
{
    File.WriteAllBytes("ironpdf.pdf", pdf.BinaryData);
}

// During a gradual migration, both libraries can sit behind one interface
IPdfConverter converter = new IronPdfAdapter();
File.WriteAllBytes("adapter.pdf", converter.ConvertUrlToPdf(url));

public interface IPdfConverter
{
    byte[] ConvertHtmlToPdf(string html);
    byte[] ConvertUrlToPdf(string url);
}

public class IronPdfAdapter : IPdfConverter
{
    private readonly ChromePdfRenderer _renderer = new ChromePdfRenderer();

    public byte[] ConvertHtmlToPdf(string html)
    {
        using var pdf = _renderer.RenderHtmlAsPdf(html);
        return pdf.BinaryData;
    }

    public byte[] ConvertUrlToPdf(string url)
    {
        using var pdf = _renderer.RenderUrlAsPdf(url);
        return pdf.BinaryData;
    }
}

public class EvoPdfAdapter : IPdfConverter
{
    private readonly HtmlToPdfConverter _converter = new HtmlToPdfConverter();
    
    public byte[] ConvertHtmlToPdf(string html)
    {
        return _converter.ConvertHtml(html, "");
    }
    
    public byte[] ConvertUrlToPdf(string url)
    {
        return _converter.ConvertUrl(url);
    }
}

結論:為您的項目做出正確選擇

IronPDF和EvoPdf在.NET PDF庫生態系統中扮演著重要角色,但它們針對不同的使用案例和開發哲學。

當您需要以下情況時選擇IronPDF:

  • 現代Web標準支持(CSS3、JavaScript框架)
  • 超越生成的PDF操作,如合併、表單、刪除和簽名
  • 安全功能,如加密、簽名和刪除
  • 跨平台部署靈活性
  • 廣泛的文檔和直接的工程支持
  • 與其他文件處理工具的集成

當您需要以下情況時選擇EvoPdf:

  • 以較低許可成本進行HTML到PDF轉換
  • 每應用程序許可(部署)或公司範圍許可(公司),包括在您自己的應用程序中再分發
  • 不計算開發者的許可
  • 在Chromium基於引擎(EvoPdf Next)和支持.NET Framework 2.0及更高版本的Windows引擎(EvoPdf Classic)之間選擇

最終決定取決於您的具體需求、預算限制和長期可擴展性需求。對於需要超越生成的PDF操作的現代應用程序,如內置刪除和DOCX轉換,IronPDF的功能集和文檔使其成為一項強大的投資。EvoPdf也是一個可行的選擇,特別是對於重視其公司範圍許可和包含再分發的團隊。

考慮從IronPDF的30天免費試用開始,以評估其在您的具體使用案例中的能力。試用提供對IronPDF功能的訪問,允許您根據實際性能在您的環境中做出明智的決定。

請記住,PDF庫的真正成本超出了許可價格,考慮開發時間、維護開銷以及隨著應用程序增長可能需要的額外功能。選擇不僅滿足您當前需求的庫,還能隨著您的未來需求擴展。

請注意: EvoPdf是其各自所有者的商標。本網站與EvoPdf無關,未經EvoPdf認可或贊助。所有產品名稱、徽標和品牌均為其各自所有者的財產。比較僅供信息參考,反映撰寫時的公開信息。

Jacob Mellor是Iron Software的首席技術官,一位在C# PDF技術上開創先河的遠見工程師。作為Iron Software核心程式碼庫的原開發者,他從創立以來就一直在塑造公司的產品架構,與首席執行官Cameron Rimington一起將公司轉變為服務於NASA、特斯拉和全球政府公司的50多名人員的公司。

閱讀更多

相關文章