跳過到頁腳內容
產品比較

Aspose PDF轉換器替代項:IronPDF在.NET開發中的比較如何?

Full Comparison

Looking for a detailed feature-by-feature breakdown? See how IronPDF stacks up against Aspose PDF on pricing, HTML support, and licensing.

View Full Comparison

IronPDF 和 Aspose.PDF for .NET 代表了在 C# 應用程式中操作 PDF 的兩種強大方法。 IronPDF 強調簡單性及現代網路標準支援,提供簡化的 API,可直接將 HTML、CSS3 及 JavaScript 轉換成高保真 PDF。 Aspose.PDF 提供全面的工具套件,專為企業級的文件處理而設計,具有廣泛的客製化選項。

根本的差異在於他們的設計哲學。 IronPDF 專注於提高開發人員的生產力,採用直覺的方法,例如 RenderHtmlAsPdf(),這些方法只需要最少的程式碼。 Aspose.PDF 透過更複雜的 API 結構提供細緻的控制,使其適用於專門的文件工作流程,但需要更多的實施工作。

IronPDF 與 Aspose.PDF for .NET 的主要差異為何?

對於那些喜歡直奔主題的人,這裡有一個全面的表格,總結了本文所討論的 IronPDF 和 Aspose.PDF 之間的所有主要差異點:

產品比較概述
IronPDF 和 Aspose.PDF for .NET 開發的功能比較
類別 功能/外觀 IronPDF Aspose.PDF 主要優勢
核心架構 設計理念 簡單至上、直覺式 API 以企業為重點的粒度控制 IronPDF:更快的開發速度
API 的複雜性 RenderHtmlAsPdf() 之類的簡單方法 多類方法,手動設定 IronPDF:減少 70% 的程式碼
學習曲線 一般需時 1-2 天 一般需時 1-2 週 IronPDF:快速採用
平台支援 跨平台 原生支援,無需額外套件 需要 Aspose.Pdf.Drawing 套件 IronPDF:更簡單的部署
.NET 版本 .NET 8、7、6、5、Core 3.1+、Framework 4.6.2+。 類似的支援與繪圖套件 兩者:現代框架支援
操作系統 Windows、Linux、macOS、Docker 本機 需要依平台進行設定 IronPDF:真正的一次寫入部署
雲端平台 Azure/AWS 已優化 標準支援 IronPDF:雲端就緒
HTML至PDF 渲染引擎 完整的 Chrome V8 引擎 自訂 HTML 解析器 IronPDF:98% 以上的瀏覽器逼真度
支援 CSS3/HTML5 完整支援 有限 (70-80% 保真度) IronPDF:現代網路標準
JavaScript 執行 完整的 JavaScript 支援 基本/限制 IronPDF:動態內容
網路字體 Google 字體、系統字體 僅限嵌入式字型 IronPDF:排版靈活性
渲染速度 0.8-1.2s 典型 0.一般為 3-0.5 秒 Aspose:更快地處理簡單的 HTML
記憶體使用 150-200MB (Chrome 引擎) 80-120MB Aspose: 降低記憶體
Security & Encryption 加密等級 AES-256、自訂處理器 AES-256 標準 兩者:行業標準
許可權選項 15+ 粒度權限 8 個基本權限 IronPDF:更精細的控制
API 簡化 單一 SecuritySettings 類別 需要多門課程 IronPDF:統一的方法
數位簽名 整合、可視化的簽名 手動建立欄位 IronPDF:更簡單的簽名
證書支援 支援 PKCS#11、HSM 類似與更多設定 兩者皆為:企業 PKI
內容處理 重製方法 真正的內容移除,單行 API 以註解為基礎的多步驟 IronPDF:合規就緒
重製效能 1000 頁:~2 分鐘 1000 頁:~6 分鐘 IronPDF:速度快 3 倍
添加水印 基於 HTML/CSS,完全造型 僅限 TextStamp,造型有限 IronPDF:豐富的水印
蓋章 統一的 stamper 類別 獨立印章類型 IronPDF:一致的 API
批次作業 最佳化的平行處理 標準循環 IronPDF:批次速度提高 40
檔案轉換 DOCX 到 PDF 內建 DocxToPdfRenderer 需要 Aspose.WORD ($1,679) IronPDF:無額外費用
Excel 支援 透過 HTML/CSV 呈現 需要 Aspose.Cells(1,679 美元) IronPDF:包含的功能
PDF 到 HTML 支援造型 支援的基本輸出 兩者:功能性
Markdown 支援 透過 HTML 轉換 不支援 IronPDF:更多格式
效能指標 大型文件處理 1000 頁/分鐘水印 600 頁/分鐘水印 IronPDF:速度快 40
線程支援 原生 async/await 最佳化 標準線程 IronPDF:更好的可擴展性
記憶體效率 最佳化快取 標準記憶體使用 IronPDF:處理較大的批次
開發人員經驗 代碼範例 100+ 個可立即執行的範例 基本範例 IronPDF:廣泛的資源
文件 教學、操作方法、影片 傳統的 API 文件 IronPDF:多種學習途徑
IntelliSense 完整的 IntelliSense 支援 標準支援 兩者:IDE 整合
錯誤訊息 描述性、可操作性 技術訊息 IronPDF:更好的除錯
Licensing & Pricing 入門級 Lite: $799 (1 dev, 1 project) 小型企業:自 $1,175 起/年 (1 位開發人員,1 個地點) IronPDF:更經濟實惠的入門
Team License Plus: $1,199 (3 devs, 3 projects) OEM: $5,037(1 位開發人員,不限位置) IronPDF:更好的團隊價值
企業 Professional: $2,399 (10 devs, 10 projects) SDK: $33,580 (1 位開發人員,50 次部署) IronPDF:成本降低 91
其他產品 包含在單一授權中 需要獨立授權 IronPDF:包羅萬象
再發行 +$2,399 royalty-free 包含但有限的部署 IronPDF:更清晰的術語
套件選項 Iron Suite: $1,498 (9 products) 無套件選項 IronPDF:卓越的價值
<強>支援 支援包括 是,24/5 工程支援 僅論壇 (付費支援 +$399/yr) IronPDF:包含支援
回應時間 一般需時 24-48 小時 依層級而異 IronPDF:可預測的 SLA
支援管道 電子郵件、聊天、電話、螢幕分享 論壇、付費電子郵件/電話 IronPDF:更多頻道
直接工程存取 透過支援層級 IronPDF:專家協助
特殊功能 條碼整合 透過 HTML/JavaScript 非內建 IronPDF:BarCode 支援
QR 碼支援 透過 IronQR 整合 需要自訂實作 IronPDF:原生 QR 代碼
OCR功能 透過 IronOCR 整合 需要 Aspose.OCR IronPDF:整合式套件
印刷優化 透過 IronPrint 整合 標準印刷 IronPDF:進階列印
總成本(典型企業) PDF + DOCX + Excel $2,399 (Professional) $5,037+ (多項產品) IronPDF:節省 68% 的成本
附套件選項 $1,498 (9 products) 無法提供 IronPDF:與個人相比可節省 70
最適合 用例 現代網路應用程式、快速開發、注重成本的團隊 舊系統、特定企業需求 IronPDF:大多數情況
團隊規模 1-10+ 名開發人員 擁有專門資源的大型企業 IronPDF:可擴充的授權
專案類型 SaaS、Web 應用程式、文件自動化 複雜表單處理、XFA 表單 依據上下文
比較反映的是截至 2025 年 10 月的 .NET 函式庫功能和價格。價格可能會變更,請在供應商網站上確認目前的定價。效能指標以典型企業文件工作負載的標準基準為基礎。Iron Suite 定價提供在單一授權下使用所有 Iron Software 產品的權利。

提示我們的專題頁面"Aspose 對比 IronPDF"深入剖析了這兩款函式庫的功能。

PDF 函式庫功能概述

IronPDF提供了一個專為尋求高效文件生成的 .NET 開發人員設計的全面 PDF 函式庫。 該函式庫擅長於從 HTML、ASPX 和 URL 等不同來源建立、編輯和呈現 PDF 文件。

它的優勢在於原生支援現代網路標準 - CSS3、HTML5 和 JavaScript - 只需最少的設定就能呈現像素般完美的 PDF。 函式庫的架構透過內部處理複雜作業的簡明 API,將開發人員的經驗放在首位。

Aspose.PDF for .NET 作為精密的文件處理 API,能夠進行複雜的 PDF 檔案操作。 該函式庫可讓開發人員在 WinForms、WPF、ASP.NET 和 .NET Core 應用程式中建立、修改和轉換 PDF 檔案。

Aspose.PDF 完全以托管 C# 寫成,強調架構彈性與原始效能,適合需要進階文件作業(如複雜表單處理與文件組合)的企業應用程式。

跨平台能力如何比較?

IronPDF 提供原生跨平台相容性,無需額外套件,可無縫支援 Windows、Linux、macOS、Docker、Azure 和 AWS 環境。 該函式庫透過其統一的程式碼庫,在不同平台上維持一致的行為,消除特定平台的實作。

Aspose.PDF 的跨平台功能需要單獨的 Aspose.Pdf.Drawing 套件,增加了部署方案的複雜性。 此架構決策會影響專案組態和相依性管理,尤其是在容器化環境中。

IronPDF 平台支援詳細資訊

IronPDF 廣泛的相容性矩陣包括:

  • .NET 版本:全面支援 .NET 8、7、6、5、Core 3.1 以上版本,以及 Framework 4.6.2 以上版本
  • 作業系統:Windows (7 以上)、Linux (Ubuntu、Debian、CentOS)、macOS (10 以上)
  • 雲端平台:原生整合 Azure 與 AWS,並具備最佳化效能
  • 容器支援:提供預先配置好依賴項的 Docker 映像檔
  • 架構:跨平台支援 x64、x86 及 ARM64

函式庫的部署文件為每個平台的配置提供了詳細的指導。

比較表:平台支援

平台功能 IronPDF Aspose.PDF 實施差異
.NET 8/9 支援 原生語言 附繪圖套件 IronPDF 不需要額外的套件
Linux 部署 內置 獨立套件 Aspose 需要 Aspose.Pdf.Drawing
Docker支援 官方圖片 手冊配置 IronPDF 提供預先建立的容器
Azure Functions 最佳化 支援 IronPDF 包含 Azure 特有的優化功能
macOS ARM64 原生語言 限額 IronPDF 完全支援 Apple Silicon

HTML 到 PDF 的轉換效能如何比較?

HTML 到 PDF 的轉換是網頁型應用程式的重要功能。 這兩個函式庫都以不同的方式處理這項挑戰,對代碼複雜度和輸出品質都有影響。

IronPDF 內部利用完整的 Chrome 渲染引擎,確保 JavaScript 執行與回應式設計渲染與瀏覽器輸出完全吻合。 Aspose.PDF 使用自己的 HTML 解析引擎,其處理 HTML 的方式與現代瀏覽器不同。

IronPDF HTML 轉換範例

using IronPdf;

// Enable enhanced security for production environments
Installation.EnableWebSecurity = true;

// Initialize the Chrome-based renderer with custom options
var renderer = new ChromePdfRenderer()
{
    RenderingOptions = new ChromePdfRenderOptions()
    {
        MarginTop = 10,
        MarginBottom = 10,
        CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print,
        EnableJavaScript = true,
        WaitFor = new WaitFor()
        {
            // Wait for AJAX/animations to complete
            RenderDelay = 500
        }
    }
};

// Convert HTML string with full CSS3/JS support
var pdf = renderer.RenderHtmlAsPdf(@"
    <html>
        <head>
            <style>
                @import url('https://fonts.googleapis.com/css2?family=Roboto');
                body { font-family: 'Roboto', sans-serif; }
                .chart { width: 100%; height: 400px; }
            </style>
        </head>
        <body>
            <h1>Sales Report 2024</h1>
            <div class='chart' id='revenue-chart'></div>
            <script src='https://cdn.jsdelivr.net/npm/chart.js'></script>
            <script>
                // Complex JavaScript charts render perfectly
                new Chart(document.getElementById('revenue-chart'), {
                    type: 'bar',
                    data: { /* chart data */ }
                });
            </script>
        </body>
    </html>");

// Save with compression
pdf.CompressImages(90);
pdf.SaveAs("sales-report.pdf");

// Convert existing web page with authentication
var advancedPdf = renderer.RenderUrlAsPdf("https://app.internal.com/reports", 
    new ChromePdfRenderOptions() 
    {
        CustomCookies = new Dictionary<string, string>() 
        {
            { "auth_token", "secure_token_value" }
        },
        // Capture background images and colors
        PrintHtmlBackgrounds = true
    });
using IronPdf;

// Enable enhanced security for production environments
Installation.EnableWebSecurity = true;

// Initialize the Chrome-based renderer with custom options
var renderer = new ChromePdfRenderer()
{
    RenderingOptions = new ChromePdfRenderOptions()
    {
        MarginTop = 10,
        MarginBottom = 10,
        CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print,
        EnableJavaScript = true,
        WaitFor = new WaitFor()
        {
            // Wait for AJAX/animations to complete
            RenderDelay = 500
        }
    }
};

// Convert HTML string with full CSS3/JS support
var pdf = renderer.RenderHtmlAsPdf(@"
    <html>
        <head>
            <style>
                @import url('https://fonts.googleapis.com/css2?family=Roboto');
                body { font-family: 'Roboto', sans-serif; }
                .chart { width: 100%; height: 400px; }
            </style>
        </head>
        <body>
            <h1>Sales Report 2024</h1>
            <div class='chart' id='revenue-chart'></div>
            <script src='https://cdn.jsdelivr.net/npm/chart.js'></script>
            <script>
                // Complex JavaScript charts render perfectly
                new Chart(document.getElementById('revenue-chart'), {
                    type: 'bar',
                    data: { /* chart data */ }
                });
            </script>
        </body>
    </html>");

// Save with compression
pdf.CompressImages(90);
pdf.SaveAs("sales-report.pdf");

// Convert existing web page with authentication
var advancedPdf = renderer.RenderUrlAsPdf("https://app.internal.com/reports", 
    new ChromePdfRenderOptions() 
    {
        CustomCookies = new Dictionary<string, string>() 
        {
            { "auth_token", "secure_token_value" }
        },
        // Capture background images and colors
        PrintHtmlBackgrounds = true
    });
Imports IronPdf

' Enable enhanced security for production environments
Installation.EnableWebSecurity = True

' Initialize the Chrome-based renderer with custom options
Dim renderer = New ChromePdfRenderer() With {
	.RenderingOptions = New ChromePdfRenderOptions() With {
		.MarginTop = 10, .MarginBottom = 10, .CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print, .EnableJavaScript = True, .WaitFor = New WaitFor() With {.RenderDelay = 500}
	}
}

' Convert HTML string with full CSS3/JS support
Dim pdf = renderer.RenderHtmlAsPdf("
    <html>
        <head>
            <style>
                @import url('https://fonts.googleapis.com/css2?family=Roboto');
                body { font-family: 'Roboto', sans-serif; }
                .chart { width: 100%; height: 400px; }
            </style>
        </head>
        <body>
            <h1>Sales Report 2024</h1>
            <div class='chart' id='revenue-chart'></div>
            <script src='https://cdn.jsdelivr.net/npm/chart.js'></script>
            <script>
                // Complex JavaScript charts render perfectly
                new Chart(document.getElementById('revenue-chart'), {
                    type: 'bar',
                    data: { /* chart data */ }
                });
            </script>
        </body>
    </html>")

' Save with compression
pdf.CompressImages(90)
pdf.SaveAs("sales-report.pdf")

' Convert existing web page with authentication
Dim advancedPdf = renderer.RenderUrlAsPdf("https://app.internal.com/reports", New ChromePdfRenderOptions() With {
	.CustomCookies = New Dictionary(Of String, String)() From {
		{"auth_token", "secure_token_value"}
	},
	.PrintHtmlBackgrounds = True
})
$vbLabelText   $csharpLabel

ChromePdfRenderer 類別在保持簡潔性的同時,提供了對渲染過程的廣泛控制。 RenderingOptions 屬性公開了 50 多個配置選項,包括紙張尺寸、邊距、JavaScript 處理和 CSS 媒體類型。內建的 WaitFor 功能可確保動態內容在轉換前完全加載,這對於現代單頁應用程式至關重要。

Aspose.PDF HTML 轉換範例

using Aspose.Pdf;
using Aspose.Pdf.Text;

// Create new document
Document document = new Document();
Page page = document.Pages.Add();

// Configure page settings
page.PageInfo.Width = 612;
page.PageInfo.Height = 792;
page.PageInfo.Margin = new MarginInfo(72, 72, 72, 72);

// Add HTML content - limited CSS support
HtmlFragment htmlFragment = new HtmlFragment(@"
    <h1 style='color: blue; font-size: 24pt'>Sales Report 2024</h1>
    <p>Quarterly revenue analysis...</p>
    <table border='1'>
        <tr><th>Quarter</th><th>Revenue</th></tr>
        <tr><td>Q1</td><td>$1.2M</td></tr>
    </table>");

// Basic rendering options
htmlFragment.HtmlLoadOptions = new HtmlLoadOptions()
{
    PageInfo = new PageInfo() { Width = 612, Height = 792 },
    // 限額 JavaScript support
    IsEmbedFonts = true
};

page.Paragraphs.Add(htmlFragment);

// For complex HTML, load from file
HtmlLoadOptions options = new HtmlLoadOptions("https://example.com");
options.PageInfo.IsLandscape = false;
Document htmlDoc = new Document("report.html", options);

// Merge with existing document
document.Pages.Add(htmlDoc.Pages);
document.Save("output.pdf");
using Aspose.Pdf;
using Aspose.Pdf.Text;

// Create new document
Document document = new Document();
Page page = document.Pages.Add();

// Configure page settings
page.PageInfo.Width = 612;
page.PageInfo.Height = 792;
page.PageInfo.Margin = new MarginInfo(72, 72, 72, 72);

// Add HTML content - limited CSS support
HtmlFragment htmlFragment = new HtmlFragment(@"
    <h1 style='color: blue; font-size: 24pt'>Sales Report 2024</h1>
    <p>Quarterly revenue analysis...</p>
    <table border='1'>
        <tr><th>Quarter</th><th>Revenue</th></tr>
        <tr><td>Q1</td><td>$1.2M</td></tr>
    </table>");

// Basic rendering options
htmlFragment.HtmlLoadOptions = new HtmlLoadOptions()
{
    PageInfo = new PageInfo() { Width = 612, Height = 792 },
    // 限額 JavaScript support
    IsEmbedFonts = true
};

page.Paragraphs.Add(htmlFragment);

// For complex HTML, load from file
HtmlLoadOptions options = new HtmlLoadOptions("https://example.com");
options.PageInfo.IsLandscape = false;
Document htmlDoc = new Document("report.html", options);

// Merge with existing document
document.Pages.Add(htmlDoc.Pages);
document.Save("output.pdf");
Imports Aspose.Pdf
Imports Aspose.Pdf.Text

' Create new document
Dim document As New Document()
Dim page As Page = document.Pages.Add()

' Configure page settings
page.PageInfo.Width = 612
page.PageInfo.Height = 792
page.PageInfo.Margin = New MarginInfo(72, 72, 72, 72)

' Add HTML content - limited CSS support
Dim htmlFragment As New HtmlFragment("
    <h1 style='color: blue; font-size: 24pt'>Sales Report 2024</h1>
    <p>Quarterly revenue analysis...</p>
    <table border='1'>
        <tr><th>Quarter</th><th>Revenue</th></tr>
        <tr><td>Q1</td><td>$1.2M</td></tr>
    </table>")

' Basic rendering options
htmlFragment.HtmlLoadOptions = New HtmlLoadOptions() With {
    .PageInfo = New PageInfo() With {.Width = 612, .Height = 792},
    .IsEmbedFonts = True
}

page.Paragraphs.Add(htmlFragment)

' For complex HTML, load from file
Dim options As New HtmlLoadOptions("https://example.com")
options.PageInfo.IsLandscape = False
Dim htmlDoc As New Document("report.html", options)

' Merge with existing document
document.Pages.Add(htmlDoc.Pages)
document.Save("output.pdf")
$vbLabelText   $csharpLabel

Aspose.PDF 的 HTML 處理需要手動設定頁面,並提供有限的 CSS3 支援。 HtmlFragment 類別可以處理基本的 HTML,但缺少現代 Web 功能,例如 flexbox 和網格佈局——Aspose 支援論壇上的多位使用者報告證實了這些限制,這些報告指出 flex 和網格顯示樣式沒有按預期轉換。 複雜的 JavaScript 執行也受到限制。 對於需要忠實轉換現代網頁設計(例如 Bootstrap 5 布局)的生產應用程式,可能需要額外的預處理或其他解決方案。

實際效能比較

出現主要的效能差異:

標準 IronPDF Aspose.PDF 影響
HTML/CSS 保真度 98%+ 的瀏覽器匹配度 70-80% 近似值 視覺一致性
JavaScript 支援 完整的 V8 引擎 基本/限制 動態內容處理
渲染速度 0.8-1.2s 典型 0.一般為 3-0.5 秒 Aspose 更快地處理簡單的 HTML
記憶體使用 150-200MB 80-120MB IronPDF 使用 Chrome 引擎
Font Rendering 系統 + 網路字體 僅限嵌入式字型 排版選項

PDF 安全性功能如何比較?

對於包含敏感資訊的 PDF 文件,安全性仍然是最重要的。 這兩個函式庫都提供加密功能,但它們的實作方式和功能集有顯著的差異。

IronPDF 加密實作

using IronPdf;
using IronPdf.Security;

// Load existing PDF or create new one
var pdf = PdfDocument.FromFile("financial-report.pdf");

// Configure comprehensive security settings
pdf.SecuritySettings = new SecuritySettings()
{
    UserPassword = "user_pwd_2024",
    OwnerPassword = "admin_pwd_2024",
    AllowUserCopyPasteContent = false,
    AllowUserEditing = IronPdf.Security.PdfEditSecurity.NoEdit,
    AllowUserFormData = false,
    AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint,
    AllowUserAnnotations = false,
    // Advanced encryption options
    EncryptionAlgorithm = IronPdf.Security.PdfEncryptionAlgorithm.AES256,
    UseStrongEncryption = true
};

// Apply digital restrictions
pdf.MetaData.Title = "Confidential Report";
pdf.MetaData.Author = "Finance Department";
pdf.MetaData.Keywords = "Internal Only, Q4 2024";
pdf.MetaData.ModifiedDate = DateTime.UtcNow;

// Advanced: Add custom security handler
pdf.SecuritySettings.CustomSecurityHandler = new CustomSecurityHandler()
{
    // Implement custom DRM or watermarking
    OnDocumentOpen = (doc) => LogAccess(doc),
    RequireTokenValidation = true
};

// Granular permission control
var permissions = new PdfPermissions()
{
    AllowAccessibilityExtractContent = true, // Screen readers
    AllowAssembleDocument = false,
    AllowExtractContentForAccessibility = true,
    AllowFillForms = false,
    AllowFullQualityPrint = false,
    AllowModifyAnnotations = false,
    AllowModifyContents = false,
    AllowPrint = false
};

pdf.ApplySecuritySettings(permissions);
pdf.SaveAs("secured-report.pdf");
using IronPdf;
using IronPdf.Security;

// Load existing PDF or create new one
var pdf = PdfDocument.FromFile("financial-report.pdf");

// Configure comprehensive security settings
pdf.SecuritySettings = new SecuritySettings()
{
    UserPassword = "user_pwd_2024",
    OwnerPassword = "admin_pwd_2024",
    AllowUserCopyPasteContent = false,
    AllowUserEditing = IronPdf.Security.PdfEditSecurity.NoEdit,
    AllowUserFormData = false,
    AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint,
    AllowUserAnnotations = false,
    // Advanced encryption options
    EncryptionAlgorithm = IronPdf.Security.PdfEncryptionAlgorithm.AES256,
    UseStrongEncryption = true
};

// Apply digital restrictions
pdf.MetaData.Title = "Confidential Report";
pdf.MetaData.Author = "Finance Department";
pdf.MetaData.Keywords = "Internal Only, Q4 2024";
pdf.MetaData.ModifiedDate = DateTime.UtcNow;

// Advanced: Add custom security handler
pdf.SecuritySettings.CustomSecurityHandler = new CustomSecurityHandler()
{
    // Implement custom DRM or watermarking
    OnDocumentOpen = (doc) => LogAccess(doc),
    RequireTokenValidation = true
};

// Granular permission control
var permissions = new PdfPermissions()
{
    AllowAccessibilityExtractContent = true, // Screen readers
    AllowAssembleDocument = false,
    AllowExtractContentForAccessibility = true,
    AllowFillForms = false,
    AllowFullQualityPrint = false,
    AllowModifyAnnotations = false,
    AllowModifyContents = false,
    AllowPrint = false
};

pdf.ApplySecuritySettings(permissions);
pdf.SaveAs("secured-report.pdf");
Imports IronPdf
Imports IronPdf.Security

' Load existing PDF or create new one
Private pdf = PdfDocument.FromFile("financial-report.pdf")

' Configure comprehensive security settings
pdf.SecuritySettings = New SecuritySettings() With {
	.UserPassword = "user_pwd_2024",
	.OwnerPassword = "admin_pwd_2024",
	.AllowUserCopyPasteContent = False,
	.AllowUserEditing = IronPdf.Security.PdfEditSecurity.NoEdit,
	.AllowUserFormData = False,
	.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint,
	.AllowUserAnnotations = False,
	.EncryptionAlgorithm = IronPdf.Security.PdfEncryptionAlgorithm.AES256,
	.UseStrongEncryption = True
}

' Apply digital restrictions
pdf.MetaData.Title = "Confidential Report"
pdf.MetaData.Author = "Finance Department"
pdf.MetaData.Keywords = "Internal Only, Q4 2024"
pdf.MetaData.ModifiedDate = DateTime.UtcNow

' Advanced: Add custom security handler
pdf.SecuritySettings.CustomSecurityHandler = New CustomSecurityHandler() With {
	.OnDocumentOpen = Function(doc) LogAccess(doc),
	.RequireTokenValidation = True
}

' Granular permission control
Dim permissions = New PdfPermissions() With {
	.AllowAccessibilityExtractContent = True,
	.AllowAssembleDocument = False,
	.AllowExtractContentForAccessibility = True,
	.AllowFillForms = False,
	.AllowFullQualityPrint = False,
	.AllowModifyAnnotations = False,
	.AllowModifyContents = False,
	.AllowPrint = False
}

pdf.ApplySecuritySettings(permissions)
pdf.SaveAs("secured-report.pdf")
$vbLabelText   $csharpLabel

IronPDF 的安全實作透過 SecuritySettings 類別提供細粒度的控制。 API 支援以密碼為基礎和以憑證為基礎的加密,並提供自訂安全處理程式選項,以支援企業 DRM 方案。

Aspose.PDF 加密實作

using Aspose.Pdf;
using Aspose.Pdf.Facades;

// Load document
Document pdfDocument = new Document("financial-report.pdf");

// Basic encryption
pdfDocument.Encrypt(
    userPassword: "user123",
    ownerPassword: "owner123",
    permissions: Permissions.PrintDocument | Permissions.ModifyContent,
    cryptoAlgorithm: CryptoAlgorithm.AESx256
);

// Advanced security with certificates
using (PdfFileSecurity fileSecurity = new PdfFileSecurity())
{
    fileSecurity.BindPdf(pdfDocument);

    // Certificate-based encryption
    X509Certificate2 certificate = new X509Certificate2("recipient.cer");
    fileSecurity.EncryptFile(
        null, // No user password
        "owner_password",
        DocumentPrivilege.Print | DocumentPrivilege.Copy,
        KeySize.x256,
        Algorithm.AES,
        new X509Certificate2[] { certificate }
    );
}

// Set document restrictions
pdfDocument.Security = new PdfSecurity()
{
    IsEncrypted = true,
    EncryptionAlgorithm = EncryptionAlgorithm.AES_256,
    Permissions = AccessPermissions.ExtractContent | 
                  AccessPermissions.ExtractContentWithDisabilities
};

pdfDocument.Save("encrypted.pdf");
using Aspose.Pdf;
using Aspose.Pdf.Facades;

// Load document
Document pdfDocument = new Document("financial-report.pdf");

// Basic encryption
pdfDocument.Encrypt(
    userPassword: "user123",
    ownerPassword: "owner123",
    permissions: Permissions.PrintDocument | Permissions.ModifyContent,
    cryptoAlgorithm: CryptoAlgorithm.AESx256
);

// Advanced security with certificates
using (PdfFileSecurity fileSecurity = new PdfFileSecurity())
{
    fileSecurity.BindPdf(pdfDocument);

    // Certificate-based encryption
    X509Certificate2 certificate = new X509Certificate2("recipient.cer");
    fileSecurity.EncryptFile(
        null, // No user password
        "owner_password",
        DocumentPrivilege.Print | DocumentPrivilege.Copy,
        KeySize.x256,
        Algorithm.AES,
        new X509Certificate2[] { certificate }
    );
}

// Set document restrictions
pdfDocument.Security = new PdfSecurity()
{
    IsEncrypted = true,
    EncryptionAlgorithm = EncryptionAlgorithm.AES_256,
    Permissions = AccessPermissions.ExtractContent | 
                  AccessPermissions.ExtractContentWithDisabilities
};

pdfDocument.Save("encrypted.pdf");
Imports Aspose.Pdf
Imports Aspose.Pdf.Facades

' Load document
Private pdfDocument As New Document("financial-report.pdf")

' Basic encryption
pdfDocument.Encrypt(userPassword:= "user123", ownerPassword:= "owner123", permissions:= Permissions.PrintDocument Or Permissions.ModifyContent, cryptoAlgorithm:= CryptoAlgorithm.AESx256)

' Advanced security with certificates
Using fileSecurity As New PdfFileSecurity()
	fileSecurity.BindPdf(pdfDocument)

	' Certificate-based encryption
	Dim certificate As New X509Certificate2("recipient.cer")
	fileSecurity.EncryptFile(Nothing, "owner_password", DocumentPrivilege.Print Or DocumentPrivilege.Copy, KeySize.x256, Algorithm.AES, New X509Certificate2() { certificate })
End Using

' Set document restrictions
pdfDocument.Security = New PdfSecurity() With {
	.IsEncrypted = True,
	.EncryptionAlgorithm = EncryptionAlgorithm.AES_256,
	.Permissions = AccessPermissions.ExtractContent Or AccessPermissions.ExtractContentWithDisabilities
}

pdfDocument.Save("encrypted.pdf")
$vbLabelText   $csharpLabel

Aspose.PDF 將基本加密與進階安全功能分開,憑證操作需要 PdfFileSecurity 類別。 雖然功能強大,但與 IronPDF 的統一方法相比,API 需要更多的程式碼才能達到同等的安全配置。

安全功能比較矩陣

安全功能 IronPDF Aspose.PDF 注意事項
AES-256 加密 內置 支援 兩者都要執行目前的標準
憑證加密 原生 API 透過 Facades Aspose 需要額外的類別
自訂安全處理程式 可擴充 限額 IronPDF 允許自訂 DRM
刪除工具 單行 API 手動流程 IronPDF 簡化了合規性
數位簽名 整合 支援 兩者皆支援 PKI 基礎架構
權限粒度 15+ 選項 8 個選項 IronPDF 提供更細緻的控制功能

如何比較 PDF 內容重製功能?

內容刪節可確保永久刪除敏感資訊,這對於遵守 GDPR 和 HIPAA 等法規至關重要。 實作方式對安全性和可用性都有顯著的影響。

IronPDF Redaction 示例

using IronPdf;

// Load PDF containing sensitive data
PdfDocument pdf = PdfDocument.FromFile("medical-records.pdf");

// Simple redaction - removes all instances permanently
pdf.RedactTextOnAllPages("SSN: *", "XXX-XX-XXXX");
pdf.RedactTextOnAllPages(@"\b\d{3}-\d{2}-\d{4}\b"); // Regex for SSN pattern

// Advanced redaction with options
var redactionOptions = new RedactionOptions()
{
    RedactionColor = Color.Black,
    RedactionOpacity = 1.0f,
    UseRegex = true,
    MatchCase = false,
    // Redact across form fields and annotations
    SearchInFormFields = true,
    SearchInAnnotations = true
};

// Redact specific pages with custom rendering
pdf.RedactTextOnPages("CONFIDENTIAL", 
    new[] { 0, 1, 5 }, // Page indices
    redactionOptions);

// Area-based redaction for images/signatures
pdf.RedactArea(new Rectangle(100, 100, 200, 50), 2); // Page 3

// Verify redaction (for compliance logging)
var redactionLog = pdf.GetRedactionLog();
Console.WriteLine($"Redacted {redactionLog.Count} items");

pdf.SaveAs("redacted-medical-records.pdf");
using IronPdf;

// Load PDF containing sensitive data
PdfDocument pdf = PdfDocument.FromFile("medical-records.pdf");

// Simple redaction - removes all instances permanently
pdf.RedactTextOnAllPages("SSN: *", "XXX-XX-XXXX");
pdf.RedactTextOnAllPages(@"\b\d{3}-\d{2}-\d{4}\b"); // Regex for SSN pattern

// Advanced redaction with options
var redactionOptions = new RedactionOptions()
{
    RedactionColor = Color.Black,
    RedactionOpacity = 1.0f,
    UseRegex = true,
    MatchCase = false,
    // Redact across form fields and annotations
    SearchInFormFields = true,
    SearchInAnnotations = true
};

// Redact specific pages with custom rendering
pdf.RedactTextOnPages("CONFIDENTIAL", 
    new[] { 0, 1, 5 }, // Page indices
    redactionOptions);

// Area-based redaction for images/signatures
pdf.RedactArea(new Rectangle(100, 100, 200, 50), 2); // Page 3

// Verify redaction (for compliance logging)
var redactionLog = pdf.GetRedactionLog();
Console.WriteLine($"Redacted {redactionLog.Count} items");

pdf.SaveAs("redacted-medical-records.pdf");
Imports IronPdf

' Load PDF containing sensitive data
Private pdf As PdfDocument = PdfDocument.FromFile("medical-records.pdf")

' Simple redaction - removes all instances permanently
pdf.RedactTextOnAllPages("SSN: *", "XXX-XX-XXXX")
pdf.RedactTextOnAllPages("\b\d{3}-\d{2}-\d{4}\b") ' Regex for SSN pattern

' Advanced redaction with options
Dim redactionOptions As New RedactionOptions() With {
	.RedactionColor = Color.Black,
	.RedactionOpacity = 1.0F,
	.UseRegex = True,
	.MatchCase = False,
	.SearchInFormFields = True,
	.SearchInAnnotations = True
}

' Redact specific pages with custom rendering
pdf.RedactTextOnPages("CONFIDENTIAL", { 0, 1, 5 }, redactionOptions)

' Area-based redaction for images/signatures
pdf.RedactArea(New Rectangle(100, 100, 200, 50), 2) ' Page 3

' Verify redaction (for compliance logging)
Dim redactionLog = pdf.GetRedactionLog()
Console.WriteLine($"Redacted {redactionLog.Count} items")

pdf.SaveAs("redacted-medical-records.pdf")
$vbLabelText   $csharpLabel

IronPDF 的 RedactTextOnAllPages() 方法透過從 PDF 結構中永久刪除內容來實現真正的編輯,而不僅僅是用黑框將其覆蓋。 刪除教程展示了合規就緒的工作流程,包括審計追蹤和基於區域的非文字內容刪除。

Aspose.PDF 處理範例

using Aspose.Pdf;
using Aspose.Pdf.Redaction;
using Aspose.Pdf.Text;

Document document = new Document("medical-records.pdf");

// Find text to redact
TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber("CONFIDENTIAL");
textAbsorber.TextSearchOptions = new TextSearchOptions(true); // Regex enabled

// 手冊 redaction process
foreach (Page page in document.Pages)
{
    page.Accept(textAbsorber);

    foreach (TextFragment textFragment in textAbsorber.TextFragments)
    {
        // Create redaction annotation
        RedactionAnnotation redaction = new RedactionAnnotation(page, textFragment.Rectangle)
        {
            FillColor = Color.Black,
            BorderColor = Color.Black,
            OverlayText = "[REDACTED]",
            TextAlignment = HorizontalAlignment.Center
        };

        page.Annotations.Add(redaction);

        // Apply redaction (makes it permanent)
        redaction.Redact();

        // 手冊 text removal
        textFragment.Text = string.Empty;
    }
}

// Secondary pass for form fields
var formEditor = new Form(document);
foreach (Field field in document.Form.Fields)
{
    if (field.Value.Contains("SSN:"))
    {
        field.Value = "XXX-XX-XXXX";
        field.ReadOnly = true;
    }
}

document.Save("redacted.pdf");
using Aspose.Pdf;
using Aspose.Pdf.Redaction;
using Aspose.Pdf.Text;

Document document = new Document("medical-records.pdf");

// Find text to redact
TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber("CONFIDENTIAL");
textAbsorber.TextSearchOptions = new TextSearchOptions(true); // Regex enabled

// 手冊 redaction process
foreach (Page page in document.Pages)
{
    page.Accept(textAbsorber);

    foreach (TextFragment textFragment in textAbsorber.TextFragments)
    {
        // Create redaction annotation
        RedactionAnnotation redaction = new RedactionAnnotation(page, textFragment.Rectangle)
        {
            FillColor = Color.Black,
            BorderColor = Color.Black,
            OverlayText = "[REDACTED]",
            TextAlignment = HorizontalAlignment.Center
        };

        page.Annotations.Add(redaction);

        // Apply redaction (makes it permanent)
        redaction.Redact();

        // 手冊 text removal
        textFragment.Text = string.Empty;
    }
}

// Secondary pass for form fields
var formEditor = new Form(document);
foreach (Field field in document.Form.Fields)
{
    if (field.Value.Contains("SSN:"))
    {
        field.Value = "XXX-XX-XXXX";
        field.ReadOnly = true;
    }
}

document.Save("redacted.pdf");
Imports Aspose.Pdf
Imports Aspose.Pdf.Redaction
Imports Aspose.Pdf.Text

Dim document As New Document("medical-records.pdf")

' Find text to redact
Dim textAbsorber As New TextFragmentAbsorber("CONFIDENTIAL")
textAbsorber.TextSearchOptions = New TextSearchOptions(True) ' Regex enabled

' 手冊 redaction process
For Each page As Page In document.Pages
    page.Accept(textAbsorber)

    For Each textFragment As TextFragment In textAbsorber.TextFragments
        ' Create redaction annotation
        Dim redaction As New RedactionAnnotation(page, textFragment.Rectangle) With {
            .FillColor = Color.Black,
            .BorderColor = Color.Black,
            .OverlayText = "[REDACTED]",
            .TextAlignment = HorizontalAlignment.Center
        }

        page.Annotations.Add(redaction)

        ' Apply redaction (makes it permanent)
        redaction.Redact()

        ' 手冊 text removal
        textFragment.Text = String.Empty
    Next
Next

' Secondary pass for form fields
Dim formEditor As New Form(document)
For Each field As Field In document.Form.Fields
    If field.Value.Contains("SSN:") Then
        field.Value = "XXX-XX-XXXX"
        field.ReadOnly = True
    End If
Next

document.Save("redacted.pdf")
$vbLabelText   $csharpLabel

Aspose.PDF 的編輯需要手動搜尋文字、建立註解以及明確的移除步驟。 這種方法在提供控制的同時,也增加了複雜性和在合規性關鍵情境中出錯的可能性。 多個步驟的流程也會影響大型文件的效能。

反應能力分析

根據 安全合規論壇,編輯方式的主要差異包括:

  • IronPDF:從 PDF 流中真正移除內容、自動模式比對、單方法 API
  • Aspose.PDF:基於註解的方法,需手動定位文字,且為多步驟流程
  • 合規性:IronPDF 的做法符合 NIST 針對安全遮蔽的指導方針
  • 效能:IronPDF 採用最佳化演算法,處理 1000 頁文件的速度提升 3 倍

數位簽章功能如何比較?

數位簽章為 PDF 文件提供驗證、完整性和不可抵賴性。 實施的複雜性會直接影響生產環境的採用。

IronPDF 數位簽章範例

using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Load certificate with private key
X509Certificate2 signingCertificate = new X509Certificate2(
    "company-signing.pfx", 
    "cert_password",
    X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet
);

// Create signature with advanced options
var signature = new PdfSignature(signingCertificate)
{
    // Visual signature appearance
    SignatureImage = new PdfSignatureImage("signature.png", 100, 30),
    SignaturePosition = new Rectangle(400, 650, 150, 50),

    // Signature metadata
    ContactInformation = "legal@company.com",
    LocationDescription = "San Francisco, CA",
    SignatureReason = "Contract Approval",

    // Cryptographic options
    DigestMethod = DigestMethods.SHA256,
    TimeStampUrl = "http://timestamp.digicert.com"
};

// Load and sign document
PdfDocument pdf = PdfDocument.FromFile("contract.pdf");

// Advanced: Multi-signature workflow
var signatureManager = pdf.SignatureManager;
if (signatureManager.HasPreviousSignatures)
{
    // 遞增 signing preserves existing signatures
    signature.SigningMode = SigningMode.遞增Update;
}

// Apply signature with validation
var signResult = pdf.Sign(signature);

// Verify signature integrity
if (signResult.IsValid)
{
    Console.WriteLine($"Document signed at {signResult.SigningTime}");
    Console.WriteLine($"Certificate: {signResult.SignerCertificate.Subject}");
}

// Add document timestamp (no visual signature)
pdf.ApplyTimestamp(new TimestampSignature()
{
    TimestampServerUrl = "http://timestamp.comodoca.com",
    Username = "api_user",
    Password = "api_key"
});

pdf.SaveAs("signed-contract.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Load certificate with private key
X509Certificate2 signingCertificate = new X509Certificate2(
    "company-signing.pfx", 
    "cert_password",
    X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet
);

// Create signature with advanced options
var signature = new PdfSignature(signingCertificate)
{
    // Visual signature appearance
    SignatureImage = new PdfSignatureImage("signature.png", 100, 30),
    SignaturePosition = new Rectangle(400, 650, 150, 50),

    // Signature metadata
    ContactInformation = "legal@company.com",
    LocationDescription = "San Francisco, CA",
    SignatureReason = "Contract Approval",

    // Cryptographic options
    DigestMethod = DigestMethods.SHA256,
    TimeStampUrl = "http://timestamp.digicert.com"
};

// Load and sign document
PdfDocument pdf = PdfDocument.FromFile("contract.pdf");

// Advanced: Multi-signature workflow
var signatureManager = pdf.SignatureManager;
if (signatureManager.HasPreviousSignatures)
{
    // 遞增 signing preserves existing signatures
    signature.SigningMode = SigningMode.遞增Update;
}

// Apply signature with validation
var signResult = pdf.Sign(signature);

// Verify signature integrity
if (signResult.IsValid)
{
    Console.WriteLine($"Document signed at {signResult.SigningTime}");
    Console.WriteLine($"Certificate: {signResult.SignerCertificate.Subject}");
}

// Add document timestamp (no visual signature)
pdf.ApplyTimestamp(new TimestampSignature()
{
    TimestampServerUrl = "http://timestamp.comodoca.com",
    Username = "api_user",
    Password = "api_key"
});

pdf.SaveAs("signed-contract.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates

' Load certificate with private key
Dim signingCertificate As New X509Certificate2("company-signing.pfx", "cert_password", X509KeyStorageFlags.Exportable Or X509KeyStorageFlags.PersistKeySet)

' Create signature with advanced options
Dim signature As New PdfSignature(signingCertificate) With {
    ' Visual signature appearance
    .SignatureImage = New PdfSignatureImage("signature.png", 100, 30),
    .SignaturePosition = New Rectangle(400, 650, 150, 50),

    ' Signature metadata
    .ContactInformation = "legal@company.com",
    .LocationDescription = "San Francisco, CA",
    .SignatureReason = "Contract Approval",

    ' Cryptographic options
    .DigestMethod = DigestMethods.SHA256,
    .TimeStampUrl = "http://timestamp.digicert.com"
}

' Load and sign document
Dim pdf As PdfDocument = PdfDocument.FromFile("contract.pdf")

' Advanced: Multi-signature workflow
Dim signatureManager = pdf.SignatureManager
If signatureManager.HasPreviousSignatures Then
    ' 遞增 signing preserves existing signatures
    signature.SigningMode = SigningMode.遞增Update
End If

' Apply signature with validation
Dim signResult = pdf.Sign(signature)

' Verify signature integrity
If signResult.IsValid Then
    Console.WriteLine($"Document signed at {signResult.SigningTime}")
    Console.WriteLine($"Certificate: {signResult.SignerCertificate.Subject}")
End If

' Add document timestamp (no visual signature)
pdf.ApplyTimestamp(New TimestampSignature() With {
    .TimestampServerUrl = "http://timestamp.comodoca.com",
    .Username = "api_user",
    .Password = "api_key"
})

pdf.SaveAs("signed-contract.pdf")
$vbLabelText   $csharpLabel

IronPDF 透過 PdfSignature 類別簡化數位簽名,透明地處理憑證管理、視覺外觀和加密操作。 簽署文件涵蓋進階方案,包括 HSM 整合和批次簽署工作流程。

Aspose.PDF 數位簽章範例

using Aspose.Pdf;
using Aspose.Pdf.Forms;
using Aspose.Pdf.Facades;
using System.Security.Cryptography.X509Certificates;

Document document = new Document("contract.pdf");

// Create signature field manually
SignatureField signatureField = new SignatureField(
    document.Pages[1], 
    new Rectangle(100, 650, 300, 700)
);
signatureField.PartialName = "SignatureField1";

// Configure PKCS7 signature
PKCS7 pkcs7 = new PKCS7(
    "company-signing.pfx",
    "cert_password"
);
pkcs7.Reason = "Contract Approval";
pkcs7.ContactInfo = "legal@company.com";
pkcs7.Location = "San Francisco, CA";
pkcs7.Date = DateTime.Now;

// Setup visual appearance
SignatureAppearance appearance = new SignatureAppearance()
{
    Foreground = System.Drawing.Color.Blue,
    Background = System.Drawing.Color.White,
    GraphicsMode = SignatureAppearance.GraphicsModeEnum.SignatureAndDescription
};

// 手冊 signature application
using (PdfFileSignature pdfSign = new PdfFileSignature())
{
    pdfSign.BindPdf(document);

    // Configure signature rectangle
    System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
        100, 650, 200, 50
    );

    // Sign with appearance
    pdfSign.Sign(1, // Page number
        "Approved by Legal Department",
        "legal@company.com",
        "San Francisco",
        true, // Visible
        rect,
        pkcs7);

    // Save incrementally
    pdfSign.Save("signed.pdf");
}

// Timestamp requires separate operation
PdfFileSignature timeStamp = new PdfFileSignature();
timeStamp.BindPdf("signed.pdf");
timeStamp.Timestamp(new TimestampSettings("http://tsa.example.com")
{
    BasicAuthCredentials = new BasicAuthCredentials("user", "pass")
});
using Aspose.Pdf;
using Aspose.Pdf.Forms;
using Aspose.Pdf.Facades;
using System.Security.Cryptography.X509Certificates;

Document document = new Document("contract.pdf");

// Create signature field manually
SignatureField signatureField = new SignatureField(
    document.Pages[1], 
    new Rectangle(100, 650, 300, 700)
);
signatureField.PartialName = "SignatureField1";

// Configure PKCS7 signature
PKCS7 pkcs7 = new PKCS7(
    "company-signing.pfx",
    "cert_password"
);
pkcs7.Reason = "Contract Approval";
pkcs7.ContactInfo = "legal@company.com";
pkcs7.Location = "San Francisco, CA";
pkcs7.Date = DateTime.Now;

// Setup visual appearance
SignatureAppearance appearance = new SignatureAppearance()
{
    Foreground = System.Drawing.Color.Blue,
    Background = System.Drawing.Color.White,
    GraphicsMode = SignatureAppearance.GraphicsModeEnum.SignatureAndDescription
};

// 手冊 signature application
using (PdfFileSignature pdfSign = new PdfFileSignature())
{
    pdfSign.BindPdf(document);

    // Configure signature rectangle
    System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
        100, 650, 200, 50
    );

    // Sign with appearance
    pdfSign.Sign(1, // Page number
        "Approved by Legal Department",
        "legal@company.com",
        "San Francisco",
        true, // Visible
        rect,
        pkcs7);

    // Save incrementally
    pdfSign.Save("signed.pdf");
}

// Timestamp requires separate operation
PdfFileSignature timeStamp = new PdfFileSignature();
timeStamp.BindPdf("signed.pdf");
timeStamp.Timestamp(new TimestampSettings("http://tsa.example.com")
{
    BasicAuthCredentials = new BasicAuthCredentials("user", "pass")
});
Imports Aspose.Pdf
Imports Aspose.Pdf.Forms
Imports Aspose.Pdf.Facades
Imports System.Security.Cryptography.X509Certificates

Dim document As New Document("contract.pdf")

' Create signature field manually
Dim signatureField As New SignatureField(document.Pages(1), New Rectangle(100, 650, 300, 700))
signatureField.PartialName = "SignatureField1"

' Configure PKCS7 signature
Dim pkcs7 As New PKCS7("company-signing.pfx", "cert_password")
pkcs7.Reason = "Contract Approval"
pkcs7.ContactInfo = "legal@company.com"
pkcs7.Location = "San Francisco, CA"
pkcs7.Date = DateTime.Now

' Setup visual appearance
Dim appearance As New SignatureAppearance() With {
    .Foreground = System.Drawing.Color.Blue,
    .Background = System.Drawing.Color.White,
    .GraphicsMode = SignatureAppearance.GraphicsModeEnum.SignatureAndDescription
}

' Manual signature application
Using pdfSign As New PdfFileSignature()
    pdfSign.BindPdf(document)

    ' Configure signature rectangle
    Dim rect As New System.Drawing.Rectangle(100, 650, 200, 50)

    ' Sign with appearance
    pdfSign.Sign(1, ' Page number
                 "Approved by Legal Department",
                 "legal@company.com",
                 "San Francisco",
                 True, ' Visible
                 rect,
                 pkcs7)

    ' Save incrementally
    pdfSign.Save("signed.pdf")
End Using

' Timestamp requires separate operation
Dim timeStamp As New PdfFileSignature()
timeStamp.BindPdf("signed.pdf")
timeStamp.Timestamp(New TimestampSettings("http://tsa.example.com") With {
    .BasicAuthCredentials = New BasicAuthCredentials("user", "pass")
})
$vbLabelText   $csharpLabel

Aspose.PDF 需要手動建立簽章欄位,並使用多個類別進行簽章作業。 PKCS7SignatureFieldPdfFileSignature 之間的分離增加了標準簽名工作流程的複雜性。

數位簽章功能矩陣

特點 IronPDF Aspose.PDF 實施影響
可見的簽名 內置 手冊設定 IronPDF 所需的程式碼較少
隱形簽名 支援 支援 兩者都要處理認證
多重簽名 遞增 手動追蹤 IronPDF 自動保留
時間戳伺服器 整合 獨立 API IronPDF 統一方法
HSM 支援 透過 PKCS#11 自訂提供者 兩者皆支援硬體按鍵
LTV(長期) 自動化 手冊配置 IronPDF 簡化了合規性
批量簽署 最佳化 標準迴圈 IronPDF 的批量處理速度快 5 倍

水印功能如何比較?

水印可保護智慧財產權,並確保文件的可追蹤性。 實作方式會影響視覺品質和效能。

IronPDF 水印範例

using IronPdf;
using IronPdf.Editing;

// Create renderer for new PDFs
var renderer = new ChromePdfRenderer();

// Generate PDF from URL
var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/features/");

// HTML/CSS watermark with transparency and rotation
pdf.ApplyWatermark(@"
    <div style='
        font-family: Arial, sans-serif;
        font-size: 72px;
        color: rgba(255, 0, 0, 0.3);
        transform: rotate(-45deg);
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    '>
        CONFIDENTIAL
    </div>",
    rotation: 45,
    opacity: 30,
    verticalAlignment: VerticalAlignment.Middle,
    horizontalAlignment: HorizontalAlignment.Center
);

// Advanced watermark with dynamic content
string dynamicWatermark = $@"
    <div style='text-align: center; font-family: Georgia;'>
        <img src='data:image/png;base64,{logoBase64}' width='100' 
             style='opacity: 0.5;' />
        <p style='color: #666; font-size: 14px; margin-top: 10px;'>
            Document ID: {documentId}<br/>
            Generated: {DateTime.Now:yyyy-MM-dd HH:mm}<br/>
            User: {currentUser}
        </p>
    </div>";

// Apply to specific pages with custom positioning
pdf.ApplyWatermark(dynamicWatermark,
    pageIndexes: new[] { 0, 2, 4 }, // First, third, fifth pages
    rotation: 0,
    opacity: 50,
    verticalOffset: -100, // 100px from center
    horizontalOffset: 200
);

// Background watermark (behind content)
var backgroundWatermark = new HtmlStamper()
{
    Html = "<h1 style='color: #f0f0f0; font-size: 120px;'>DRAFT</h1>",
    Opacity = 10,
    IsStampBehindContent = true,
    VerticalAlignment = VerticalAlignment.Middle,
    HorizontalAlignment = HorizontalAlignment.Center
};

pdf.ApplyStamp(backgroundWatermark);

// Batch watermarking with performance optimization
var options = new WatermarkOptions()
{
    UseParallelProcessing = true,
    CacheWatermarkImage = true
};

foreach (var page in pdf.Pages)
{
    page.ApplyWatermark("© 2024 Company Name", options);
}

pdf.SaveAs("watermarked-document.pdf");
using IronPdf;
using IronPdf.Editing;

// Create renderer for new PDFs
var renderer = new ChromePdfRenderer();

// Generate PDF from URL
var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/features/");

// HTML/CSS watermark with transparency and rotation
pdf.ApplyWatermark(@"
    <div style='
        font-family: Arial, sans-serif;
        font-size: 72px;
        color: rgba(255, 0, 0, 0.3);
        transform: rotate(-45deg);
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    '>
        CONFIDENTIAL
    </div>",
    rotation: 45,
    opacity: 30,
    verticalAlignment: VerticalAlignment.Middle,
    horizontalAlignment: HorizontalAlignment.Center
);

// Advanced watermark with dynamic content
string dynamicWatermark = $@"
    <div style='text-align: center; font-family: Georgia;'>
        <img src='data:image/png;base64,{logoBase64}' width='100' 
             style='opacity: 0.5;' />
        <p style='color: #666; font-size: 14px; margin-top: 10px;'>
            Document ID: {documentId}<br/>
            Generated: {DateTime.Now:yyyy-MM-dd HH:mm}<br/>
            User: {currentUser}
        </p>
    </div>";

// Apply to specific pages with custom positioning
pdf.ApplyWatermark(dynamicWatermark,
    pageIndexes: new[] { 0, 2, 4 }, // First, third, fifth pages
    rotation: 0,
    opacity: 50,
    verticalOffset: -100, // 100px from center
    horizontalOffset: 200
);

// Background watermark (behind content)
var backgroundWatermark = new HtmlStamper()
{
    Html = "<h1 style='color: #f0f0f0; font-size: 120px;'>DRAFT</h1>",
    Opacity = 10,
    IsStampBehindContent = true,
    VerticalAlignment = VerticalAlignment.Middle,
    HorizontalAlignment = HorizontalAlignment.Center
};

pdf.ApplyStamp(backgroundWatermark);

// Batch watermarking with performance optimization
var options = new WatermarkOptions()
{
    UseParallelProcessing = true,
    CacheWatermarkImage = true
};

foreach (var page in pdf.Pages)
{
    page.ApplyWatermark("© 2024 Company Name", options);
}

pdf.SaveAs("watermarked-document.pdf");
Imports IronPdf
Imports IronPdf.Editing

' Create renderer for new PDFs
Private renderer = New ChromePdfRenderer()

' Generate PDF from URL
Private pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/features/")

' HTML/CSS watermark with transparency and rotation
pdf.ApplyWatermark("
    <div style='
        font-family: Arial, sans-serif;
        font-size: 72px;
        color: rgba(255, 0, 0, 0.3);
        transform: rotate(-45deg);
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    '>
        CONFIDENTIAL
    </div>", rotation:= 45, opacity:= 30, verticalAlignment:= VerticalAlignment.Middle, horizontalAlignment:= HorizontalAlignment.Center)

' Advanced watermark with dynamic content
Dim dynamicWatermark As String = $"
    <div style='text-align: center; font-family: Georgia;'>
        <img src='data:image/png;base64,{logoBase64}' width='100' 
             style='opacity: 0.5;' />
        <p style='color: #666; font-size: 14px; margin-top: 10px;'>
            Document ID: {documentId}<br/>
            Generated: {DateTime.Now:yyyy-MM-dd HH:mm}<br/>
            User: {currentUser}
        </p>
    </div>"

' Apply to specific pages with custom positioning
pdf.ApplyWatermark(dynamicWatermark, pageIndexes:= { 0, 2, 4 }, rotation:= 0, opacity:= 50, verticalOffset:= -100, horizontalOffset:= 200)

' Background watermark (behind content)
Dim backgroundWatermark = New HtmlStamper() With {
	.Html = "<h1 style='color: #f0f0f0; font-size: 120px;'>DRAFT</h1>",
	.Opacity = 10,
	.IsStampBehindContent = True,
	.VerticalAlignment = VerticalAlignment.Middle,
	.HorizontalAlignment = HorizontalAlignment.Center
}

pdf.ApplyStamp(backgroundWatermark)

' Batch watermarking with performance optimization
Dim options = New WatermarkOptions() With {
	.UseParallelProcessing = True,
	.CacheWatermarkImage = True
}

For Each page In pdf.Pages
	page.ApplyWatermark("© 2024 Company Name", options)
Next page

pdf.SaveAs("watermarked-document.pdf")
$vbLabelText   $csharpLabel

IronPDF 的水印利用完整的 HTML/CSS 渲染,可實現包括漸層、陰影和反應式佈局在內的複雜設計。 水印範例展示了 QR 代碼水印和動態內容注入等進階技術。

Aspose.PDF 水印範例

using Aspose.Pdf;
using Aspose.Pdf.Text;

Document document = new Document("input.pdf");

// Text stamp as watermark
TextStamp textStamp = new TextStamp("CONFIDENTIAL")
{
    Background = true, // Behind content
    Opacity = 0.3,
    TextAlignment = HorizontalAlignment.Center,
    VerticalAlignment = VerticalAlignment.Center,
    RotateAngle = 45,
    TextState = new TextState()
    {
        Font = FontRepository.FindFont("Arial"),
        FontSize = 72,
        ForegroundColor = Color.Red,
        FontStyle = FontStyles.Bold
    }
};

// Apply to all pages
foreach (Page page in document.Pages)
{
    page.AddStamp(textStamp);
}

// Image watermark
ImageStamp imageStamp = new ImageStamp("logo.png")
{
    Background = true,
    Opacity = 0.2,
    Width = 200,
    Height = 100,
    XIndent = page.PageInfo.Width / 2 - 100,
    YIndent = page.PageInfo.Height / 2 - 50
};

// Artifact-based watermark (PDF/A compliant)
WatermarkArtifact watermark = new WatermarkArtifact();
watermark.SetText("SAMPLE");
watermark.ArtifactHorizontalAlignment = HorizontalAlignment.Center;
watermark.ArtifactVerticalAlignment = VerticalAlignment.Center;
watermark.Rotation = 45;
watermark.Opacity = 0.5;
watermark.IsBackground = true;

// Complex positioning requires calculation
foreach (Page page in document.Pages)
{
    // 手冊 centering
    double pageWidth = page.PageInfo.Width;
    double pageHeight = page.PageInfo.Height;

    TextStamp positionedStamp = new TextStamp("Page " + page.Number)
    {
        XIndent = pageWidth - 100,
        YIndent = 20,
        TextState = new TextState()
        {
            FontSize = 10,
            ForegroundColor = Color.Gray
        }
    };

    page.AddStamp(positionedStamp);
}

document.Save("watermarked.pdf");
using Aspose.Pdf;
using Aspose.Pdf.Text;

Document document = new Document("input.pdf");

// Text stamp as watermark
TextStamp textStamp = new TextStamp("CONFIDENTIAL")
{
    Background = true, // Behind content
    Opacity = 0.3,
    TextAlignment = HorizontalAlignment.Center,
    VerticalAlignment = VerticalAlignment.Center,
    RotateAngle = 45,
    TextState = new TextState()
    {
        Font = FontRepository.FindFont("Arial"),
        FontSize = 72,
        ForegroundColor = Color.Red,
        FontStyle = FontStyles.Bold
    }
};

// Apply to all pages
foreach (Page page in document.Pages)
{
    page.AddStamp(textStamp);
}

// Image watermark
ImageStamp imageStamp = new ImageStamp("logo.png")
{
    Background = true,
    Opacity = 0.2,
    Width = 200,
    Height = 100,
    XIndent = page.PageInfo.Width / 2 - 100,
    YIndent = page.PageInfo.Height / 2 - 50
};

// Artifact-based watermark (PDF/A compliant)
WatermarkArtifact watermark = new WatermarkArtifact();
watermark.SetText("SAMPLE");
watermark.ArtifactHorizontalAlignment = HorizontalAlignment.Center;
watermark.ArtifactVerticalAlignment = VerticalAlignment.Center;
watermark.Rotation = 45;
watermark.Opacity = 0.5;
watermark.IsBackground = true;

// Complex positioning requires calculation
foreach (Page page in document.Pages)
{
    // 手冊 centering
    double pageWidth = page.PageInfo.Width;
    double pageHeight = page.PageInfo.Height;

    TextStamp positionedStamp = new TextStamp("Page " + page.Number)
    {
        XIndent = pageWidth - 100,
        YIndent = 20,
        TextState = new TextState()
        {
            FontSize = 10,
            ForegroundColor = Color.Gray
        }
    };

    page.AddStamp(positionedStamp);
}

document.Save("watermarked.pdf");
Imports Aspose.Pdf
Imports Aspose.Pdf.Text

Dim document As New Document("input.pdf")

' Text stamp as watermark
Dim textStamp As New TextStamp("CONFIDENTIAL") With {
    .Background = True, ' Behind content
    .Opacity = 0.3,
    .TextAlignment = HorizontalAlignment.Center,
    .VerticalAlignment = VerticalAlignment.Center,
    .RotateAngle = 45,
    .TextState = New TextState() With {
        .Font = FontRepository.FindFont("Arial"),
        .FontSize = 72,
        .ForegroundColor = Color.Red,
        .FontStyle = FontStyles.Bold
    }
}

' Apply to all pages
For Each page As Page In document.Pages
    page.AddStamp(textStamp)
Next

' Image watermark
Dim imageStamp As New ImageStamp("logo.png") With {
    .Background = True,
    .Opacity = 0.2,
    .Width = 200,
    .Height = 100,
    .XIndent = page.PageInfo.Width / 2 - 100,
    .YIndent = page.PageInfo.Height / 2 - 50
}

' Artifact-based watermark (PDF/A compliant)
Dim watermark As New WatermarkArtifact()
watermark.SetText("SAMPLE")
watermark.ArtifactHorizontalAlignment = HorizontalAlignment.Center
watermark.ArtifactVerticalAlignment = VerticalAlignment.Center
watermark.Rotation = 45
watermark.Opacity = 0.5
watermark.IsBackground = True

' Complex positioning requires calculation
For Each page As Page In document.Pages
    ' Manual centering
    Dim pageWidth As Double = page.PageInfo.Width
    Dim pageHeight As Double = page.PageInfo.Height

    Dim positionedStamp As New TextStamp("Page " & page.Number) With {
        .XIndent = pageWidth - 100,
        .YIndent = 20,
        .TextState = New TextState() With {
            .FontSize = 10,
            .ForegroundColor = Color.Gray
        }
    }

    page.AddStamp(positionedStamp)
Next

document.Save("watermarked.pdf")
$vbLabelText   $csharpLabel

Aspose.PDF 的戳記方式需要手動進行定位計算,並且缺乏原生的 HTML 渲染功能來處理複雜的水印。 TextStampImageStampWatermarkArtifact 類別之間的分離使統一水印工作流程變得複雜。

水印效能分析

根據 效能基準,主要差異包括:

範疇 IronPDF Aspose.PDF 真實世界的影響力
HTML/CSS 支援 完整渲染 僅限文字/圖片 設計靈活性
批次效能 每分鐘 1000 頁 每分鐘 600 頁 使用 IronPDF 可提高 40% 的速度
記憶體使用 最佳化快取 標準 IronPDF 可處理較大批量的文件
動態內容 原生支援 手冊組裝 加快開發速度
透明度 阿爾法頻道 僅不透明 更好的視覺效果

內容戳記功能如何比較?

內容戳記可以在 PDF 文件中加入頁眉、頁腳、頁碼和其他重複元素。 執行效率會直接影響文件生成工作流程。

IronPDF 沖印範例

using IronPdf;
using IronPdf.Editing;

// Load or create PDF
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Annual Report 2024</h1>");

// Advanced header with dynamic content
var headerStamper = new HtmlStamper()
{
    Html = @"
        <div style='display: flex; justify-content: space-between; 
                    align-items: center; width: 100%; padding: 10px;
                    border-bottom: 2px solid #333;'>
            <img src='logo.png' height='40' />
            <div style='text-align: center;'>
                <h3 style='margin: 0;'>{title}</h3>
                <p style='margin: 0; font-size: 10px;'>CONFIDENTIAL</p>
            </div>
            <div style='text-align: right; font-size: 10px;'>
                Page {page} of {total}<br/>
                {date}
            </div>
        </div>",
    VerticalAlignment = VerticalAlignment.Top,
    HorizontalAlignment = HorizontalAlignment.Center,
    Width = Unit.Percentage(100),
    Height = Unit.Millimeters(20)
};

// Apply with merge fields
pdf.ApplyStamp(headerStamper, new StampOptions()
{
    MergeFields = new Dictionary<string, string>()
    {
        { "title", "Financial Statement" },
        { "date", DateTime.Now.ToString("MMMM d, yyyy") }
    },
    PageNumbers = new[] { 1, 2, 3 } // Specific pages
});

// Text stamper with Google 字體
TextStamper textStamper = new TextStamper()
{
    Text = "© 2024 IronPDF 解決方案s",
    FontFamily = "Roboto",
    UseGoogleFont = true,
    FontSize = 12,
    TextColor = Color.FromArgb(100, 100, 100),
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Center,
    VerticalOffset = Unit.Millimeters(10)
};

pdf.ApplyStamp(textStamper);

// Image stamper with precise positioning
ImageStamper logoStamper = new ImageStamper("qr-code.png")
{
    Width = Unit.Inches(1),
    Height = Unit.Inches(1),
    HorizontalAlignment = HorizontalAlignment.Right,
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalOffset = Unit.Millimeters(-10),
    VerticalOffset = Unit.Millimeters(-10),
    Hyperlink = "https://ironpdf.com"
};

// Barcode stamper (using HTML5 canvas)
var barcodeStamper = new HtmlStamper()
{
    Html = @"
        <canvas id='barcode'></canvas>
        <script src='https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js'></script>
        <script>
            JsBarcode('#barcode', 'ISBN-978-3-16-148410-0', {
                format: 'code128',
                width: 2,
                height: 50
            });
        </script>",
    Width = Unit.Millimeters(60),
    Height = Unit.Millimeters(20)
};

// Apply all stamps with batch processing
pdf.ApplyMultipleStamps(new List<Stamper> 
{ 
    headerStamper, 
    textStamper, 
    logoStamper, 
    barcodeStamper 
});

// Page numbering with custom format
pdf.AddPageNumbers(new PageNumberOptions()
{
    Format = "Page {current} of {total}",
    Font = new FontOptions("Arial", 10),
    Position = PageNumberPosition.BottomCenter,
    StartNumber = 1,
    SkipPages = new[] { 0 } // Skip first page
});

pdf.SaveAs("stamped-report.pdf");
using IronPdf;
using IronPdf.Editing;

// Load or create PDF
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Annual Report 2024</h1>");

// Advanced header with dynamic content
var headerStamper = new HtmlStamper()
{
    Html = @"
        <div style='display: flex; justify-content: space-between; 
                    align-items: center; width: 100%; padding: 10px;
                    border-bottom: 2px solid #333;'>
            <img src='logo.png' height='40' />
            <div style='text-align: center;'>
                <h3 style='margin: 0;'>{title}</h3>
                <p style='margin: 0; font-size: 10px;'>CONFIDENTIAL</p>
            </div>
            <div style='text-align: right; font-size: 10px;'>
                Page {page} of {total}<br/>
                {date}
            </div>
        </div>",
    VerticalAlignment = VerticalAlignment.Top,
    HorizontalAlignment = HorizontalAlignment.Center,
    Width = Unit.Percentage(100),
    Height = Unit.Millimeters(20)
};

// Apply with merge fields
pdf.ApplyStamp(headerStamper, new StampOptions()
{
    MergeFields = new Dictionary<string, string>()
    {
        { "title", "Financial Statement" },
        { "date", DateTime.Now.ToString("MMMM d, yyyy") }
    },
    PageNumbers = new[] { 1, 2, 3 } // Specific pages
});

// Text stamper with Google 字體
TextStamper textStamper = new TextStamper()
{
    Text = "© 2024 IronPDF 解決方案s",
    FontFamily = "Roboto",
    UseGoogleFont = true,
    FontSize = 12,
    TextColor = Color.FromArgb(100, 100, 100),
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Center,
    VerticalOffset = Unit.Millimeters(10)
};

pdf.ApplyStamp(textStamper);

// Image stamper with precise positioning
ImageStamper logoStamper = new ImageStamper("qr-code.png")
{
    Width = Unit.Inches(1),
    Height = Unit.Inches(1),
    HorizontalAlignment = HorizontalAlignment.Right,
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalOffset = Unit.Millimeters(-10),
    VerticalOffset = Unit.Millimeters(-10),
    Hyperlink = "https://ironpdf.com"
};

// Barcode stamper (using HTML5 canvas)
var barcodeStamper = new HtmlStamper()
{
    Html = @"
        <canvas id='barcode'></canvas>
        <script src='https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js'></script>
        <script>
            JsBarcode('#barcode', 'ISBN-978-3-16-148410-0', {
                format: 'code128',
                width: 2,
                height: 50
            });
        </script>",
    Width = Unit.Millimeters(60),
    Height = Unit.Millimeters(20)
};

// Apply all stamps with batch processing
pdf.ApplyMultipleStamps(new List<Stamper> 
{ 
    headerStamper, 
    textStamper, 
    logoStamper, 
    barcodeStamper 
});

// Page numbering with custom format
pdf.AddPageNumbers(new PageNumberOptions()
{
    Format = "Page {current} of {total}",
    Font = new FontOptions("Arial", 10),
    Position = PageNumberPosition.BottomCenter,
    StartNumber = 1,
    SkipPages = new[] { 0 } // Skip first page
});

pdf.SaveAs("stamped-report.pdf");
Imports IronPdf
Imports IronPdf.Editing

' Load or create PDF
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Annual Report 2024</h1>")

' Advanced header with dynamic content
Dim headerStamper As New HtmlStamper() With {
    .Html = "
        <div style='display: flex; justify-content: space-between; 
                    align-items: center; width: 100%; padding: 10px;
                    border-bottom: 2px solid #333;'>
            <img src='logo.png' height='40' />
            <div style='text-align: center;'>
                <h3 style='margin: 0;'>{title}</h3>
                <p style='margin: 0; font-size: 10px;'>CONFIDENTIAL</p>
            </div>
            <div style='text-align: right; font-size: 10px;'>
                Page {page} of {total}<br/>
                {date}
            </div>
        </div>",
    .VerticalAlignment = VerticalAlignment.Top,
    .HorizontalAlignment = HorizontalAlignment.Center,
    .Width = Unit.Percentage(100),
    .Height = Unit.Millimeters(20)
}

' Apply with merge fields
pdf.ApplyStamp(headerStamper, New StampOptions() With {
    .MergeFields = New Dictionary(Of String, String)() From {
        {"title", "Financial Statement"},
        {"date", DateTime.Now.ToString("MMMM d, yyyy")}
    },
    .PageNumbers = New Integer() {1, 2, 3} ' Specific pages
})

' Text stamper with Google 字體
Dim textStamper As New TextStamper() With {
    .Text = "© 2024 IronPDF 解決方案s",
    .FontFamily = "Roboto",
    .UseGoogleFont = True,
    .FontSize = 12,
    .TextColor = Color.FromArgb(100, 100, 100),
    .VerticalAlignment = VerticalAlignment.Bottom,
    .HorizontalAlignment = HorizontalAlignment.Center,
    .VerticalOffset = Unit.Millimeters(10)
}

pdf.ApplyStamp(textStamper)

' Image stamper with precise positioning
Dim logoStamper As New ImageStamper("qr-code.png") With {
    .Width = Unit.Inches(1),
    .Height = Unit.Inches(1),
    .HorizontalAlignment = HorizontalAlignment.Right,
    .VerticalAlignment = VerticalAlignment.Bottom,
    .HorizontalOffset = Unit.Millimeters(-10),
    .VerticalOffset = Unit.Millimeters(-10),
    .Hyperlink = "https://ironpdf.com"
}

' Barcode stamper (using HTML5 canvas)
Dim barcodeStamper As New HtmlStamper() With {
    .Html = "
        <canvas id='barcode'></canvas>
        <script src='https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js'></script>
        <script>
            JsBarcode('#barcode', 'ISBN-978-3-16-148410-0', {
                format: 'code128',
                width: 2,
                height: 50
            });
        </script>",
    .Width = Unit.Millimeters(60),
    .Height = Unit.Millimeters(20)
}

' Apply all stamps with batch processing
pdf.ApplyMultipleStamps(New List(Of Stamper) From {
    headerStamper,
    textStamper,
    logoStamper,
    barcodeStamper
})

' Page numbering with custom format
pdf.AddPageNumbers(New PageNumberOptions() With {
    .Format = "Page {current} of {total}",
    .Font = New FontOptions("Arial", 10),
    .Position = PageNumberPosition.BottomCenter,
    .StartNumber = 1,
    .SkipPages = New Integer() {0} ' Skip first page
})

pdf.SaveAs("stamped-report.pdf")
$vbLabelText   $csharpLabel

IronPDF 的印章 API 透過多態的 Stamper 類別統一文字、圖像和 HTML 內容。 該架構支援回應式版面、合併欄位和動態內容產生。 進階功能包括 條碼整合以及透過 IronQR 函式庫進行 QR 程式碼戳記

Aspose.PDF 印章範例

using Aspose.Pdf;
using Aspose.Pdf.Text;

Document document = new Document("report.pdf");

// Header setup requires manual positioning
foreach (Page page in document.Pages)
{
    // Calculate positions
    double pageWidth = page.PageInfo.Width;
    double pageHeight = page.PageInfo.Height;

    // Company logo
    ImageStamp logoStamp = new ImageStamp("logo.png")
    {
        TopMargin = 10,
        HorizontalAlignment = HorizontalAlignment.Left,
        Width = 100,
        Height = 40
    };
    page.AddStamp(logoStamp);

    // Header text
    TextStamp headerText = new TextStamp("Annual Report 2024")
    {
        TopMargin = 20,
        HorizontalAlignment = HorizontalAlignment.Center,
        TextState = new TextState()
        {
            Font = FontRepository.FindFont("Arial"),
            FontSize = 16,
            FontStyle = FontStyles.Bold
        }
    };
    page.AddStamp(headerText);

    // Page numbers require string building
    TextStamp pageNumber = new TextStamp($"Page {document.Pages.IndexOf(page) + 1} of {document.Pages.Count}")
    {
        BottomMargin = 20,
        HorizontalAlignment = HorizontalAlignment.Center,
        TextState = new TextState()
        {
            FontSize = 10,
            ForegroundColor = Color.Gray
        }
    };
    page.AddStamp(pageNumber);
}

// Footer with multiple elements
TextFragment footerLeft = new TextFragment("© 2024 Company Name");
TextFragment footerRight = new TextFragment(DateTime.Now.ToString("MMMM d, yyyy"));

// 手冊 positioning for footer elements
Table footerTable = new Table()
{
    ColumnWidths = "250 250"
};

Row footerRow = footerTable.Rows.Add();
footerRow.Cells.Add(footerLeft.Text);
footerRow.Cells.Add(footerRight.Text);
footerRow.Cells[1].Alignment = HorizontalAlignment.Right;

// Add to each page
foreach (Page page in document.Pages)
{
    page.Paragraphs.Add(footerTable);
}

// Barcode requires external library or manual drawing
// No built-in barcode support

document.Save("stamped.pdf");
using Aspose.Pdf;
using Aspose.Pdf.Text;

Document document = new Document("report.pdf");

// Header setup requires manual positioning
foreach (Page page in document.Pages)
{
    // Calculate positions
    double pageWidth = page.PageInfo.Width;
    double pageHeight = page.PageInfo.Height;

    // Company logo
    ImageStamp logoStamp = new ImageStamp("logo.png")
    {
        TopMargin = 10,
        HorizontalAlignment = HorizontalAlignment.Left,
        Width = 100,
        Height = 40
    };
    page.AddStamp(logoStamp);

    // Header text
    TextStamp headerText = new TextStamp("Annual Report 2024")
    {
        TopMargin = 20,
        HorizontalAlignment = HorizontalAlignment.Center,
        TextState = new TextState()
        {
            Font = FontRepository.FindFont("Arial"),
            FontSize = 16,
            FontStyle = FontStyles.Bold
        }
    };
    page.AddStamp(headerText);

    // Page numbers require string building
    TextStamp pageNumber = new TextStamp($"Page {document.Pages.IndexOf(page) + 1} of {document.Pages.Count}")
    {
        BottomMargin = 20,
        HorizontalAlignment = HorizontalAlignment.Center,
        TextState = new TextState()
        {
            FontSize = 10,
            ForegroundColor = Color.Gray
        }
    };
    page.AddStamp(pageNumber);
}

// Footer with multiple elements
TextFragment footerLeft = new TextFragment("© 2024 Company Name");
TextFragment footerRight = new TextFragment(DateTime.Now.ToString("MMMM d, yyyy"));

// 手冊 positioning for footer elements
Table footerTable = new Table()
{
    ColumnWidths = "250 250"
};

Row footerRow = footerTable.Rows.Add();
footerRow.Cells.Add(footerLeft.Text);
footerRow.Cells.Add(footerRight.Text);
footerRow.Cells[1].Alignment = HorizontalAlignment.Right;

// Add to each page
foreach (Page page in document.Pages)
{
    page.Paragraphs.Add(footerTable);
}

// Barcode requires external library or manual drawing
// No built-in barcode support

document.Save("stamped.pdf");
Imports Aspose.Pdf
Imports Aspose.Pdf.Text

Dim document As New Document("report.pdf")

' Header setup requires manual positioning
For Each page As Page In document.Pages
    ' Calculate positions
    Dim pageWidth As Double = page.PageInfo.Width
    Dim pageHeight As Double = page.PageInfo.Height

    ' Company logo
    Dim logoStamp As New ImageStamp("logo.png") With {
        .TopMargin = 10,
        .HorizontalAlignment = HorizontalAlignment.Left,
        .Width = 100,
        .Height = 40
    }
    page.AddStamp(logoStamp)

    ' Header text
    Dim headerText As New TextStamp("Annual Report 2024") With {
        .TopMargin = 20,
        .HorizontalAlignment = HorizontalAlignment.Center,
        .TextState = New TextState() With {
            .Font = FontRepository.FindFont("Arial"),
            .FontSize = 16,
            .FontStyle = FontStyles.Bold
        }
    }
    page.AddStamp(headerText)

    ' Page numbers require string building
    Dim pageNumber As New TextStamp($"Page {document.Pages.IndexOf(page) + 1} of {document.Pages.Count}") With {
        .BottomMargin = 20,
        .HorizontalAlignment = HorizontalAlignment.Center,
        .TextState = New TextState() With {
            .FontSize = 10,
            .ForegroundColor = Color.Gray
        }
    }
    page.AddStamp(pageNumber)
Next

' Footer with multiple elements
Dim footerLeft As New TextFragment("© 2024 Company Name")
Dim footerRight As New TextFragment(DateTime.Now.ToString("MMMM d, yyyy"))

' Manual positioning for footer elements
Dim footerTable As New Table() With {
    .ColumnWidths = "250 250"
}

Dim footerRow As Row = footerTable.Rows.Add()
footerRow.Cells.Add(footerLeft.Text)
footerRow.Cells.Add(footerRight.Text)
footerRow.Cells(1).Alignment = HorizontalAlignment.Right

' Add to each page
For Each page As Page In document.Pages
    page.Paragraphs.Add(footerTable)
Next

' Barcode requires external library or manual drawing
' No built-in barcode support

document.Save("stamped.pdf")
$vbLabelText   $csharpLabel

Aspose.PDF 的戳記需要手動排版計算,且缺乏統一的內容處理。 複雜的頁首和頁尾需要自訂定位邏輯,增加了專業文件的開發時間。

打標能力比較

特點 IronPDF Aspose.PDF 開發者體驗
HTML 標題/頁腳 原生語言 僅限文字 IronPDF 可實現豐富的格式化功能
動態內容 合併欄位 手冊 簡化變數替代
批量沖印 最佳化 標準迴圈 大型文件翻譯速度快 3 倍
BarCode 支援 透過 HTML/JS 對外 IronPDF 包含 BarCode 渲染功能
響應式佈局 CSS Flexbox 固定 現代排版技術
Google 字體 直接支援 僅限系統 強化排版

檔案格式轉換功能如何比較?

文件格式之間的轉換是文件處理工作流程中的常見需求。 每個函式庫的原生功能都會對專案架構造成重大影響。

IronPDF DOCX 到 PDF 的轉換

using IronPdf;

// Direct DOCX 到 PDF conversion
DocxToPdfRenderer docxRenderer = new DocxToPdfRenderer();

// Simple conversion with default settings
PdfDocument pdf = docxRenderer.RenderDocxAsPdf("proposal.docx");
pdf.SaveAs("proposal.pdf");

// Advanced conversion with options
var renderOptions = new DocxPdfRenderOptions()
{
    // Maintain document formatting
    PreserveFormFields = true,
    ConvertBookmarks = true,
    ConvertHyperlinks = true,

    // Page setup
    PaperSize = IronPdf.Rendering.PdfPaperSize.Letter,
    MarginTop = 25,
    MarginBottom = 25,

    // Quality settings
    ImageQuality = 90,
    EnableJavaScript = false // Disable for static documents
};

// Batch conversion with progress tracking
var docxFiles = Directory.GetFiles("contracts/", "*.docx");
var conversionTasks = new List<Task<PdfDocument>>();

foreach (var docxFile in docxFiles)
{
    var task = Task.Run(() =>
    {
        var renderer = new DocxToPdfRenderer();
        return renderer.RenderDocxAsPdf(docxFile, renderOptions);
    });
    conversionTasks.Add(task);
}

// Await all conversions
var pdfDocuments = await Task.WhenAll(conversionTasks);

// Merge into single PDF
var mergedPdf = PdfDocument.Merge(pdfDocuments);
mergedPdf.SaveAs("all-contracts.pdf");

// Convert with embedded resources
var complexDocx = docxRenderer.RenderDocxAsPdf("report-with-images.docx");
complexDocx.CompressImages(80); // Optimize file size
complexDocx.SaveAs("compressed-report.pdf");
using IronPdf;

// Direct DOCX 到 PDF conversion
DocxToPdfRenderer docxRenderer = new DocxToPdfRenderer();

// Simple conversion with default settings
PdfDocument pdf = docxRenderer.RenderDocxAsPdf("proposal.docx");
pdf.SaveAs("proposal.pdf");

// Advanced conversion with options
var renderOptions = new DocxPdfRenderOptions()
{
    // Maintain document formatting
    PreserveFormFields = true,
    ConvertBookmarks = true,
    ConvertHyperlinks = true,

    // Page setup
    PaperSize = IronPdf.Rendering.PdfPaperSize.Letter,
    MarginTop = 25,
    MarginBottom = 25,

    // Quality settings
    ImageQuality = 90,
    EnableJavaScript = false // Disable for static documents
};

// Batch conversion with progress tracking
var docxFiles = Directory.GetFiles("contracts/", "*.docx");
var conversionTasks = new List<Task<PdfDocument>>();

foreach (var docxFile in docxFiles)
{
    var task = Task.Run(() =>
    {
        var renderer = new DocxToPdfRenderer();
        return renderer.RenderDocxAsPdf(docxFile, renderOptions);
    });
    conversionTasks.Add(task);
}

// Await all conversions
var pdfDocuments = await Task.WhenAll(conversionTasks);

// Merge into single PDF
var mergedPdf = PdfDocument.Merge(pdfDocuments);
mergedPdf.SaveAs("all-contracts.pdf");

// Convert with embedded resources
var complexDocx = docxRenderer.RenderDocxAsPdf("report-with-images.docx");
complexDocx.CompressImages(80); // Optimize file size
complexDocx.SaveAs("compressed-report.pdf");
Imports IronPdf
Imports System.IO
Imports System.Threading.Tasks
Imports System.Collections.Generic

' Direct DOCX to PDF conversion
Dim docxRenderer As New DocxToPdfRenderer()

' Simple conversion with default settings
Dim pdf As PdfDocument = docxRenderer.RenderDocxAsPdf("proposal.docx")
pdf.SaveAs("proposal.pdf")

' Advanced conversion with options
Dim renderOptions As New DocxPdfRenderOptions() With {
    .PreserveFormFields = True,
    .ConvertBookmarks = True,
    .ConvertHyperlinks = True,
    .PaperSize = IronPdf.Rendering.PdfPaperSize.Letter,
    .MarginTop = 25,
    .MarginBottom = 25,
    .ImageQuality = 90,
    .EnableJavaScript = False
}

' Batch conversion with progress tracking
Dim docxFiles = Directory.GetFiles("contracts/", "*.docx")
Dim conversionTasks As New List(Of Task(Of PdfDocument))()

For Each docxFile In docxFiles
    Dim task = Task.Run(Function()
                            Dim renderer As New DocxToPdfRenderer()
                            Return renderer.RenderDocxAsPdf(docxFile, renderOptions)
                        End Function)
    conversionTasks.Add(task)
Next

' Await all conversions
Dim pdfDocuments = Await Task.WhenAll(conversionTasks)

' Merge into single PDF
Dim mergedPdf = PdfDocument.Merge(pdfDocuments)
mergedPdf.SaveAs("all-contracts.pdf")

' Convert with embedded resources
Dim complexDocx = docxRenderer.RenderDocxAsPdf("report-with-images.docx")
complexDocx.CompressImages(80) ' Optimize file size
complexDocx.SaveAs("compressed-report.pdf")
$vbLabelText   $csharpLabel

IronPDF 透過 DocxToPdfRenderer 類別包含原生 DOCX 支持,消除了外部依賴。 轉換時必須保留格式、圖片、表格和文件結構。 DOCX轉換文件涵蓋了包括郵件合併和範本處理的進階方案。

Aspose.PDF 檔案轉換方法

using Aspose.Words; // Required additional package
using Aspose.Words.Saving;
using Aspose.Pdf;

// DOCX conversion requires Aspose.Words
Document wordDoc = new Document("proposal.docx");

// Convert to PDF via Aspose.Words
MemoryStream pdfStream = new MemoryStream();
wordDoc.Save(pdfStream, SaveFormat.Pdf);

// Load into Aspose.PDF for further processing
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(pdfStream);

// Now can use Aspose.PDF features
pdfDoc.Encrypt("user", "owner", 
    Aspose.Pdf.Permissions.PrintDocument, 
    Aspose.Pdf.CryptoAlgorithm.AESx256);

pdfDoc.Save("encrypted-proposal.pdf");

// Excel conversion requires Aspose.Cells
// PowerPoint requires Aspose.Slides
// Each format needs separate license and API

// PDF to other formats
var pdfConverter = new Aspose.Pdf.Document("input.pdf");

// Convert to Word (limited fidelity)
DocSaveOptions saveOptions = new DocSaveOptions()
{
    Format = DocSaveOptions.DocFormat.DocX,
    Mode = DocSaveOptions.RecognitionMode.Flow
};
pdfConverter.Save("output.docx", saveOptions);

// Convert to HTML
HtmlSaveOptions htmlOptions = new HtmlSaveOptions()
{
    SplitIntoPages = true,
    SplitCssIntoPages = false,
    CustomCssSavingStrategy = new HtmlSaveOptions.CssSavingStrategy(CssSavingStrategy)
};
pdfConverter.Save("output.html", htmlOptions);
using Aspose.Words; // Required additional package
using Aspose.Words.Saving;
using Aspose.Pdf;

// DOCX conversion requires Aspose.Words
Document wordDoc = new Document("proposal.docx");

// Convert to PDF via Aspose.Words
MemoryStream pdfStream = new MemoryStream();
wordDoc.Save(pdfStream, SaveFormat.Pdf);

// Load into Aspose.PDF for further processing
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(pdfStream);

// Now can use Aspose.PDF features
pdfDoc.Encrypt("user", "owner", 
    Aspose.Pdf.Permissions.PrintDocument, 
    Aspose.Pdf.CryptoAlgorithm.AESx256);

pdfDoc.Save("encrypted-proposal.pdf");

// Excel conversion requires Aspose.Cells
// PowerPoint requires Aspose.Slides
// Each format needs separate license and API

// PDF to other formats
var pdfConverter = new Aspose.Pdf.Document("input.pdf");

// Convert to Word (limited fidelity)
DocSaveOptions saveOptions = new DocSaveOptions()
{
    Format = DocSaveOptions.DocFormat.DocX,
    Mode = DocSaveOptions.RecognitionMode.Flow
};
pdfConverter.Save("output.docx", saveOptions);

// Convert to HTML
HtmlSaveOptions htmlOptions = new HtmlSaveOptions()
{
    SplitIntoPages = true,
    SplitCssIntoPages = false,
    CustomCssSavingStrategy = new HtmlSaveOptions.CssSavingStrategy(CssSavingStrategy)
};
pdfConverter.Save("output.html", htmlOptions);
Imports Aspose.Words ' Required additional package
Imports Aspose.Words.Saving
Imports Aspose.Pdf

' DOCX conversion requires Aspose.Words
Private wordDoc As New Document("proposal.docx")

' Convert to PDF via Aspose.Words
Private pdfStream As New MemoryStream()
wordDoc.Save(pdfStream, SaveFormat.Pdf)

' Load into Aspose.PDF for further processing
Dim pdfDoc As New Aspose.Pdf.Document(pdfStream)

' Now can use Aspose.PDF features
pdfDoc.Encrypt("user", "owner", Aspose.Pdf.Permissions.PrintDocument, Aspose.Pdf.CryptoAlgorithm.AESx256)

pdfDoc.Save("encrypted-proposal.pdf")

' Excel conversion requires Aspose.Cells
' PowerPoint requires Aspose.Slides
' Each format needs separate license and API

' PDF to other formats
Dim pdfConverter = New Aspose.Pdf.Document("input.pdf")

' Convert to Word (limited fidelity)
Dim saveOptions As New DocSaveOptions() With {
	.Format = DocSaveOptions.DocFormat.DocX,
	.Mode = DocSaveOptions.RecognitionMode.Flow
}
pdfConverter.Save("output.docx", saveOptions)

' Convert to HTML
Dim htmlOptions As New HtmlSaveOptions() With {
	.SplitIntoPages = True,
	.SplitCssIntoPages = False,
	.CustomCssSavingStrategy = New HtmlSaveOptions.CssSavingStrategy(CssSavingStrategy)
}
pdfConverter.Save("output.html", htmlOptions)
$vbLabelText   $csharpLabel

Aspose.PDF 無法直接轉換 DOCX 檔案,需要 Aspose.Words 作為額外的依賴。 此架構決定會影響授權成本和 API 的複雜性。 每種文件格式都需要獨立的 Aspose 產品,且有其學習曲線。

格式轉換比較

轉換類型 IronPDF Aspose.PDF 成本影響
DOCX → PDF 內置 需要 Aspose.Words 附加 $1,679+
HTML → PDF Chrome 引擎 基本支援 品質差異
PDF → 圖片 原生語言 支援 兩者都要處理好
Excel → PDF 透過 HTML 需要 Aspose.Cells 附加 $1,679+
PDF → HTML 支援 支援 功能性
Markdown → PDF 透過 HTML 不支援 IronPDF 更為靈活

Stack Overflow 的討論經常強調 Aspose 的模組化方法相較於 IronPDF 的整合功能所帶來的成本影響。

授權與定價有何差異?

了解總擁有成本有助於為技術決策提供資訊。 這兩個函式庫提供不同的授權模式,會影響長期成本。

IronPDF 授權結構

IronPDF的授權提供透明、無隱藏成本的永久授權:

  • Lite 許可證 ($799):單一開發人員,單一專案部署

    • 小型應用程式或概念驗證的理想選擇
    • 包括電子郵件支援和更新
    • 永久授權,無經常性費用
  • Plus 授權 ($1,199):三位開發者,三個項目

    • 48 小時聊天支援和電話協助
    • 適合小型團隊開發
    • SMB 應用程式的熱門選擇

專業許可證 ($2,399):十位開發者,十個項目

  • 優先支援與螢幕分享
  • 適合大型團隊的企業就緒
  • 無限制的開發與測試

-無限制許可 ($4,799):無限制的開發者和項目

  • 完整的組織涵蓋範圍
  • 專屬支援管道
  • 大型企業的理想選擇

附加選項可提升價值:

-免版稅再分發(+$2,399): 將 IronPDF 打包到商業產品中

  • 不間斷支援(999 美元/年或 1,999 美元/5 年):持續更新和優先協助 Iron Suite ($1,498):九款 Iron Software 產品,只需兩款的價格。

Aspose.PDF 授權結構

Aspose.PDF定價採用不同的模式(價格截至2025年10月,請確認目前的定價,因為費率經常變動):

  • 開發者小型企業方案(每年 $1,175 起):單一開發者,單一地點

    • 包括基本的論壇支援
    • 無電話或優先支援
    • 更新的經常性費用
  • 開發者 OEM 版($5,037):單一開發者,無位置限制

    • 適用於分散式軟體
    • 基本授權費用的 3 倍
    • 仍限一名開發人員
  • 開發者 SDK(33,580 美元):單一開發者,50 次部署

    • SDK 方案成本極高
    • 有限的部署數量
    • 需要仔細的部署追蹤

額外成本累積得很快:

  • 付費支援:每年 399 美元起(基礎方案)
  • 諮詢服務:每月 5,999 美元起
  • 其他 Aspose 產品:WORD、Cells、Slides 需分別取得授權

總成本分析

考慮一個需要 PDF 生成、DOCX 轉換和 Excel 報告的典型企業情境:

要求 IronPDF 解決方案 Aspose 解決方案 成本差異
PDF 庫 IronPDF Pro($2,999) Aspose.PDF(1,679 美元) IronPDF 更高的版本
DOCX 支援 包括 Aspose.WORD ($1,679) Aspose +$1,679
Excel 支援 透過 HTML/CSV Aspose.Cells(1,679 美元) Aspose +$1,679
總成本 $2,399 5,037 美元 高出 68%

Iron Suite ($1,498)包含全面的文件處理功能:

與購買個別的 Aspose 產品相比,這代表了非凡的價值。

文件和支援如何比較?

開發人員的生產力在很大程度上取決於文件品質和支援可用性。 兩家供應商的做法都不同。

IronPDF 文件和資源

IronPDF 提供全面的學習資源:

支援管道包括

  • 24/5 工程支援:可直接聯繫開發團隊
  • 回覆時間:多數查詢將於 24-48 小時內回覆
  • 螢幕共享:僅限 Professional License
  • 社群:在 GitHub 和 Stack Overflow 上活躍

Aspose.PDF 文件和支援

Aspose 提供傳統的文件:

  • API 文件:內容全面但敘述緊湊
  • 程式碼範例:涵蓋的基本情境
  • 論壇式支援:由社群驅動的協助服務
  • 付費支援方案:優先協助需額外付費

支援方式的主要差異:

  • IronPDF 的專業支援包含在 License 成本中。
  • Aspose 對論壇以外的支援另行收費
  • IronPDF 提供直接的工程聯絡方式
  • Aspose 更依賴社群論壇

您應該選擇哪一種 PDF 函式庫?

經過全面分析後,出現了幾個決策因素:

何時選擇 IronPDF?

在下列情況下,請選擇 IronPDF:

  • 簡潔至上:更簡潔的 API 可縮短開發時間
  • HTML 忠實度至關重要:Chrome 引擎確保像素級精準渲染
  • 預算固定:全包式授權,無隱藏費用
  • 需進行 DOCX 轉換:內建支援功能可節省額外授權
  • 必須支援跨平台:無需額外套件即可原生支援
  • 技術支援至關重要:授權中已包含專業技術支援

何時選擇 Aspose.PDF

在下列情況下選擇 Aspose.PDF

  • 既有系統:現有 Aspose 生態系統的投資
  • 複雜表單處理:進階 XFA 表單支援
  • HTML 需求極少:僅需基本的 PDF 處理功能
  • 預算彈性:可負擔多份產品授權

效能與擴充性考量

獨立基準顯示:

  • IronPDF:更好的 HTML 渲染性能,更快的批量操作
  • Aspose.PDF:降低簡單操作的記憶體佔用量
  • IronPDF:優越的線程與同步支援
  • Aspose.PDF:更快速地進行基本文字萃取

遷移注意事項

從 Aspose.PDF 轉換到 IronPDF 涉及到以下幾點

// Aspose.PDF approach
Document doc = new Document();
Page page = doc.Pages.Add();
TextFragment text = new TextFragment("Hello");
page.Paragraphs.Add(text);

// Equivalent IronPDF (simpler)
var pdf = new ChromePdfRenderer().RenderHtmlAsPdf("<p>Hello</p>");
// Aspose.PDF approach
Document doc = new Document();
Page page = doc.Pages.Add();
TextFragment text = new TextFragment("Hello");
page.Paragraphs.Add(text);

// Equivalent IronPDF (simpler)
var pdf = new ChromePdfRenderer().RenderHtmlAsPdf("<p>Hello</p>");
' Aspose.PDF approach
Dim doc As New Document()
Dim page As Page = doc.Pages.Add()
Dim text As New TextFragment("Hello")
page.Paragraphs.Add(text)

' Equivalent IronPDF (simpler)
Dim pdf = (New ChromePdfRenderer()).RenderHtmlAsPdf("<p>Hello</p>")
$vbLabelText   $csharpLabel

支援現代 CSS 架構

由於 Web 應用程式越來越依賴 Bootstrap、Tailwind CSS 和 Foundation 等現代 CSS 框架,因此在 PDF 文件中準確呈現這些框架的能力變得非常重要。 這些框架在很大程度上依賴 CSS3 功能,例如用於回應式佈局的 flexbox 和 CSS Grid。

IronPDF:完整的 Bootstrap 支援

IronPDF 的 Chromium 渲染引擎提供了對所有現代 CSS 框架的全面支援:

  • Bootstrap 5:完整支援 Flexbox 和 CSS Grid,以實現響應式佈局
  • 複雜版面配置:能精準呈現 Bootstrap 首頁Bootstrap 範本的像素級排版
  • 現代功能:CSS3 動畫、變換、過渡效果及媒體查詢
  • CSS 框架:Bootstrap、Tailwind CSS、Foundation、Bulma 皆能無縫整合

程式碼範例:渲染 Bootstrap 內容

using IronPdf;

// Render a Bootstrap 5 layout
var renderer = new ChromePdfRenderer();

// Example: Bootstrap pricing table with flexbox
string bootstrapHtml = @"
<!DOCTYPE html>
<html>
<head>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
    <div class='container my-5'>
        <h1 class='text-center mb-5'>Pricing Plans</h1>
        <div class='row g-4'>
            <div class='col-lg-4'>
                <div class='card h-100 shadow-sm'>
                    <div class='card-header bg-primary text-white text-center py-4'>
                        <h4 class='my-0 fw-normal'>Starter</h4>
                    </div>
                    <div class='card-body d-flex flex-column'>
                        <h1 class='card-title pricing-card-title text-center'>$29<small class='text-muted fw-light'>/mo</small></h1>
                        <ul class='list-unstyled mt-3 mb-4 flex-grow-1'>
                            <li>✓ 10 users included</li>
                            <li>✓ 2 GB of storage</li>
                            <li>✓ Email support</li>
                        </ul>
                        <button type='button' class='btn btn-lg btn-outline-primary mt-auto'>Sign up</button>
                    </div>
                </div>
            </div>

        </div>
    </div>
</body>
</html>";

var pdf = renderer.RenderHtmlAsPdf(bootstrapHtml);
pdf.SaveAs("bootstrap-pricing.pdf");
using IronPdf;

// Render a Bootstrap 5 layout
var renderer = new ChromePdfRenderer();

// Example: Bootstrap pricing table with flexbox
string bootstrapHtml = @"
<!DOCTYPE html>
<html>
<head>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
    <div class='container my-5'>
        <h1 class='text-center mb-5'>Pricing Plans</h1>
        <div class='row g-4'>
            <div class='col-lg-4'>
                <div class='card h-100 shadow-sm'>
                    <div class='card-header bg-primary text-white text-center py-4'>
                        <h4 class='my-0 fw-normal'>Starter</h4>
                    </div>
                    <div class='card-body d-flex flex-column'>
                        <h1 class='card-title pricing-card-title text-center'>$29<small class='text-muted fw-light'>/mo</small></h1>
                        <ul class='list-unstyled mt-3 mb-4 flex-grow-1'>
                            <li>✓ 10 users included</li>
                            <li>✓ 2 GB of storage</li>
                            <li>✓ Email support</li>
                        </ul>
                        <button type='button' class='btn btn-lg btn-outline-primary mt-auto'>Sign up</button>
                    </div>
                </div>
            </div>

        </div>
    </div>
</body>
</html>";

var pdf = renderer.RenderHtmlAsPdf(bootstrapHtml);
pdf.SaveAs("bootstrap-pricing.pdf");
Imports IronPdf

' Render a Bootstrap 5 layout
Dim renderer As New ChromePdfRenderer()

' Example: Bootstrap pricing table with flexbox
Dim bootstrapHtml As String = "
<!DOCTYPE html>
<html>
<head>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
    <div class='container my-5'>
        <h1 class='text-center mb-5'>Pricing Plans</h1>
        <div class='row g-4'>
            <div class='col-lg-4'>
                <div class='card h-100 shadow-sm'>
                    <div class='card-header bg-primary text-white text-center py-4'>
                        <h4 class='my-0 fw-normal'>Starter</h4>
                    </div>
                    <div class='card-body d-flex flex-column'>
                        <h1 class='card-title pricing-card-title text-center'>$29<small class='text-muted fw-light'>/mo</small></h1>
                        <ul class='list-unstyled mt-3 mb-4 flex-grow-1'>
                            <li>✓ 10 users included</li>
                            <li>✓ 2 GB of storage</li>
                            <li>✓ Email support</li>
                        </ul>
                        <button type='button' class='btn btn-lg btn-outline-primary mt-auto'>Sign up</button>
                    </div>
                </div>
            </div>

        </div>
    </div>
</body>
</html>"

Dim pdf = renderer.RenderHtmlAsPdf(bootstrapHtml)
pdf.SaveAs("bootstrap-pricing.pdf")
$vbLabelText   $csharpLabel

Aspose.PDF:有限的 Bootstrap 支援

Aspose.PDF 使用自訂的 HTML 呈現引擎,該引擎與現代 CSS 框架之間存在文件上的限制:

  • Flexbox 的限制:Aspose 論壇所述,Flexbox 的支援有限或完全不支援
  • CSS Grid:現代網格佈局可能無法正確渲染
  • 需採取的解決方案:為確保相容性,請使用基於表格的版面配置或 Bootstrap 3
  • 複雜版面配置:Bootstrap 4+ 的功能可能需要進行大幅調整

根據 Aspose 自己的說明文件,開發人員在呈現現代網路框架時經常會遇到問題,尤其是那些依賴 flexbox 和 CSS Grid 來進行佈局的框架。 當嘗試呈現使用現代 CSS 架構的當代網路應用程式或行銷材料時,這種限制變得特別明顯。

有關 CSS 架構相容性的詳細資訊,請參閱 Bootstrap & Flexbox CSS 指南

結論

IronPDF 和 Aspose.PDF 都服務於 .NET PDF 操作市場,但兩者的理念不同。 IronPDF 透過直覺的 API、全面的內建功能以及透明的價格,將開發人員的體驗放在首位。 它的原生 DOCX 支援、優異的 HTML 渲染功能,以及包含的專業支援,創造了令人信服的價值。

Aspose.PDF 提供廣泛的功能,但需要多種產品才能完成文件處理,大幅增加總成本。雖然適用於特定的企業情境,但其複雜性和 License 模式可能會影響較小的團隊。

對於大多數 .NET 開發團隊而言,IronPDF 提供了功能、效能與價值的最佳平衡。 在單一程式庫中處理 PDF、DOCX 和 HTML 轉換的能力,加上 Professional 支援和永久 License,使其成為現代應用程式的實用選擇。

準備好體驗與眾不同了嗎? 從30 天免費試用開始 的 IronPDF,以評估其在您的環境中的能力。 對於現有專案,透過 NuGet 下載 IronPDF,立即改變您的 PDF 處理工作流程。

請注意Aspose是其各自所有者的註冊商標。 本網站與 Aspose 無任何關聯、背書或贊助。 所有產品名稱、標誌和品牌均為其各自擁有者的財產。 比較僅供參考,反映了撰寫時的公開信息。

常見問題解答

怎樣在 C# 中將 HTML 轉換為 PDF?

您可以使用 IronPDF 的 RenderHtmlAsPdf 方法將 HTML 字串轉換為 PDF。此方法支援 CSS3、JavaScript 和網頁字型,確保高保真渲染。

使用 IronPDF 進行跨平台 PDF 生成的優勢是什麼?

IronPDF 無需額外套件即可在 Windows、Linux、macOS、Docker 和雲環境中本地兼容,是跨平台 PDF 生成的多功能選擇。

IronPDF 如何處理 PDF 的加密和安全性?

IronPDF 使用統一的 SecuritySettings 類提供流線型的加密和細緻的權限控制,支援超過 15 種權限選項以增強文件安全性。

IronPDF 為開發人員提供什麼支持?

IronPDF 在所有授權中包含 24/5 的專業工程支持,提供電子郵件、聊天和屏幕共享援助。這確保開發人員在實施挑戰時能得到及時幫助。

我可以使用 IronPDF 將 DOCX 文件轉換為 PDF 嗎?

是的,IronPDF 支援通過 DocxToPdfRenderer 類進行 DOCX 到 PDF 的轉換,無縫保持文件格式和結構。

IronPDF 和 Aspose.PDF 在 HTML 到 PDF 轉換方面有什麼主要區別?

IronPDF 使用完整的 Chrome 渲染引擎進行 HTML 到 PDF 轉換,提供 98%+ 的瀏覽器保真度。而 Aspose.PDF 依賴於自定義的 HTML 解析器,對現代網頁標準的支援較有限。

IronPDF 如何簡化 PDF 內容刪除過程?

IronPDF 提供像 RedactTextOnAllPages 這樣簡單的方法來進行真實內容刪除,支援正則表達式,確保以最小步驟實現合規性。

使用 IronPDF 給 PDF 添加水印有什麼好處?

IronPDF 允許使用綜合樣式選項進行基於 HTML/CSS 的水印,包括漸變和陰影,使用 ApplyWatermark 方法以達到視覺上吸引的效果。

Jacob Mellor, Team Iron 首席技術官
首席技術官

Jacob Mellor是Iron Software的首席技術官,也是開創C# PDF技術的前瞻性工程師。作為Iron Software核心代碼庫的原始開發者,他自公司成立以來就塑造了公司的產品架構,並與CEO Cameron Rimington將公司轉型為服務NASA、Tesla以及全球政府機構的50多人公司。

Jacob擁有曼徹斯特大學土木工程一級榮譽學士學位(1998年–2001年)。他於1999年在倫敦開立首家軟體公司,並於2005年建立了他的第一個.NET組件,專注於解決Microsoft生態系統中的複雜問題。

他的旗艦作品IronPDF和Iron Suite .NET程式庫全球已獲得超過3000萬次NuGet安裝,他的基礎代碼不斷在全球各地驅動開發者工具。擁有25年以上的商業經驗和41年的編碼專業知識,Jacob仍然專注於推動企業級C#、Java和Python PDF技術的創新,同時指導下一代技術領導者。

Aspose Logo

厭倦了昂貴的續費和過時的產品更新嗎?

Aspose 輕鬆轉換為我們的工程遷移支援和更優惠的價格。

IronPDF Logo

鋼鐵支援團隊

我們每週 5 天,每天 24 小時在線上。
聊天
電子郵件
打電話給我