跳至頁尾內容
產品比較

IronPDF vs Report.NET:.NET開發者的完整比較

IronPDF在Chromium引擎的原生HTML渲染、完整的Bootstrap支援、完整的文件和深度的.NET整合方面,優於ComPDFKit。

PDF(可攜式文件格式)是由Adobe建立的一種文件型別,用於確保文件共享的一致性。 此格式在不同裝置和操作系統上,一致地維持佈局、文字和圖片。 PDF提供安全性、互動性功能和緊湊的文件大小,令其成為分發文件而不改變內容的理想選擇。

對於使用C#的開發者來說,PDF程式庫提供了處理PDF文件的解決方案。 這些程式庫支持文件建立、內容修改以及文字和圖片提取。 他們支持表單處理、數位簽名和跨平台相容等功能。 這些程式庫旨在提高性能,使高效的PDF處理成為可能。

本文比較兩個C#的PDF程式庫:IronPDFComPDFKit。 這個比較涵蓋特點、功能、程式碼範例和授權。 通過檢視這些方面,開發者可以確定哪個程式庫最適合其PDF相關的專案。

快速比較概覽

在進入詳細分析之前,這是關鍵特點的完整比較:

功能 IronPDF ComPDFKit
HTML轉PDF 原生Chromium引擎 可通過SDK和API使用
Bootstrap支持 完整的CSS3/Flexbox支持 限制的CSS框架支持
安裝 單一的NuGet套件 需要多個套件
文件 有500多個範例的擴展文件 基本的文件
支持 每周5天24小時專屬工程支持 標準的電子郵件支持
定價模式 永久授權從$999開始 基於報價的定價
跨平台 Windows、Linux、macOS、Docker、Azure Windows、Linux、macOS
性能 優化的異步/多執行緒 標準的同步處理
企業功能 PDF/A、PDF/UA、HSM簽名 基本的PDF/A支持
學習曲線 最小 - 直觀的API 中等 - 複雜的API結構
  1. PDF查看: ComPDFKit提供功能強大的PDF查看器,讓使用者以高保真度查看PDF文件。 查看器支持流暢滾動、縮放和導航,確保流暢的使用者體驗。
  2. 註釋: 程式庫包含工具平滑地整合PDF註釋。 使用者可以高亮顯示文字、新增評論和建立各種型別的註釋,這對於協作工作流程是必不可少的。
  3. 表單處理: 程式庫為互動表單提供了廣泛的支持。 開發者可以建立、填充和提取PDF表單中的資料,這對於需要表單處理的應用程式非常理想。
  4. PDF編輯: ComPDFKit提供了廣泛的PDF編輯能力,包括修改PDF文件中的文字、圖片和其他內容。 此功能對於需要更新或定制現有PDF文件的應用程式很有用。
  5. 轉換: 該程式庫支持將PDF文件轉換為和從Word、Excel、PowerPoint和圖片等各種格式轉換。 這種靈活性對於需要轉換PDF內容以便不同用途的應用程式非常重要。
  6. 安全: ComPDFKit包括強大的安全功能,如加密和權限管理。 開發者可以保護PDF文件以防止未授權的存取,從而保護敏感資訊。
  7. 光學字元識別(OCR): 該程式庫包括OCR功能,可以將掃描的文件轉換為可編輯和可搜索的PDF。 此功能對於數位化紙質文件並使其可電子存取是必不可少的。

ComPDFKit主頁展示其完整的PDF SDK解決方案,適用於開發者,包含註釋功能截圖和PDF操作能力的程式碼範例。

ComPDFKit PDF SDK是一個可靠的C# PDF SDK,使開發者能夠在其應用程式中整合完整的PDF功能。 這個程式庫支持廣泛的PDF功能,是編程處理PDF文件所需的。 它被設計用於各種環境,包括Web、桌面和移動平台,這使其成為開發者用於跨平台專案的多功能工具。 範例解決方案包括多個功能,開發者可以選擇並測試。

ComPDFKit提供哪些關鍵功能?

核心能力:

  • PDF查看: 提供有效的查看器,具有流暢的滾動、縮放和導航能力
  • 註釋: 包括用于高亮文字、新增評論及建立各種類賂註釋的工具
  • 表單處理: 提供支持建立、填充和提取交互式PDF表單中的資料
  • PDF編輯: 允許修改現有PDF文件中的文字、圖像和其他內容
  • 轉換: 支持將PDF轉換為Word、Excel、PowerPoint和圖片格式
  • 安全: 包含加密和權限管理以保護敏感資料
  • 光學字元識別(OCR): 將掃描的文件轉換為可編輯和可搜索的PDF

為何考慮ComPDFKit的架構?

  1. HTML轉PDF轉換: IronPDF在將HTML、CSS和JavaScript內容轉換為高品質PDF文件方面表現卓越。 此功能支持HTML字串轉PDF、URL、ASPX網頁和MVC視圖,使其成為各種基於Web的內容的靈活方案。
  2. PDF編輯: 程式庫提供廣泛的編輯能力,包括新增、複製和刪除頁面、合併和拆分PDF,以及操作文字和圖像。 開發者還可以將頁眉、頁腳、水印和數位簽名新增到PDF文件。
  3. 表單處理: IronPDF支持智能表單建立和程式性填充PDF表單。 此功能對於需要動態生成表單和從使用者提交的表單中提取資料的應用程式非常重要。
  4. 安全功能: IronPDF提供強大的安全選項,如設置密碼和權限、加密文件和新增數位簽名。 這些特性確保PDF文件中的敏感資訊受到未授權存取的保護。
  5. 光學字元識別和資料提取: 該程式庫包括光學字元識別(OCR)功能,允許將掃描的文件轉換為可編輯和可搜索的PDF。 此外,IronPDF可以從現有的PDF中提取文字、圖片和其他資料,以便於內容的再利用和分析。
  6. 圖片轉換: IronPDF支持將各種圖片格式,包括JPG、PNG、GIF、BMP和SVG,轉換為PDF文件。 它還提供將PDF頁面渲染為圖片的能力,這對於需要PDF內容視覺預覽的應用程式非常有用。
  7. 跨平台相容性: IronPDF與多個.NET平台相容,包括.NET Core、.NET Framework和.NET Standard。 它支持在Windows、Linux、macOS和Azure上部署,使其成為在多樣環境中工作的開發者的多功能選擇。
  8. 性能優化: 程式庫被設計為具有高性能,支持多執行緒和非同步操作。 這確保了PDF處理任務能夠高效執行,即使是在具有高工作量的應用程式中。
  9. 全面的文件和支持: IronPDF提供詳細的文件和眾多的程式碼範例,使開發者容易上手並實現其功能。 此外,IronPDF還提供技術支持,以協助解決在開發過程中可能出現的問題。

對於需要可靠註釋功能的企業應用程式,ComPDFKit提供基本功能。 高級表單建立能力可能需要額外的程式設計工作。 雖然在OCR任務方面功能正常,但開發者尋求高級文字識別應該評估如IronOCR這樣的替代方案以獲得更高的準確度。

ComPDFKit有哪些限制?

儘管其功能齊全,ComPDFKit在企業開發中有幾個問題需要考慮:

  • CSS支持: 與原生Chromium渲染器相比,現代CSS框架的相容性有限
  • 文件: 基本範例未包含完整的故障排除指南
  • 整合複雜性: 可能需要多個套件以獲得完整功能

什麼是IronPDF程式庫?

IronPDF主頁顯示C# PDF程式庫介面,提供HTML轉PDF的程式碼範例,突出超過1000萬次下載和《財富》500強公司的企業採用。

IronPDF是一款多功能的.NET PDF程式庫,允許開發者使用C#建立、編輯和管理PDF文件。 它通過簡化的API提供完整的PDF功能。程式庫在從HTML、CSS、JavaScript和不同圖片格式渲染中出類拔萃。 這使得它成為開發者在.NET應用程式中整合可靠PDF功能的理想工具。

IronPDF提供哪些關鍵功能?

先進能力:

為何選擇IronPDF用於生產系統?

IronPDF的架構在生產環境中優先考慮性能和可靠性:

IronPDF如何準備好進入企業?

IronPDF以面向生產的特性來區分自己:

如何建立新VISUAL STUDIO專案?

在探索程式碼範例之前,開發者應建立一個新的VISUAL STUDIO專案。 本指南概述了如何在VISUAL STUDIO中設置C#控制臺應用程式。

為何我需要安裝VISUAL STUDIO?

VISUAL STUDIO提供用於C#專案的改進IDE。 從視覺化工作室下載頁面下載它。 該IDE提供整合的除錯、IntelliSense和包管理,這對PDF開發至關重要。

什麼樣的專案配置最合適?

安裝後,打開VISUAL STUDIO。 使用VISUAL STUDIO社區版時,登錄或無需登錄即可繼續。 按照這些配置步驟進行:

  1. 點擊"建立新專案"或導航至文件 > 新建 > 專案。

VISUAL STUDIO IDE顯示文件選單開啟的選項,提供建立新專案、打開文件及管理資源庫的選項,強調建立新專案選項。

  1. 搜索控制台APP並從搜索結果中選擇控制台應用程式。

VISUAL STUDIO的建立新專案對話框中顯示控制台應用程式範本的選擇,標出C#、Linux、macOS、Windows和控制台標籤,適合跨平台開發。

  1. 開啟NuGet包管理器: 在SOLUTION EXPLORER中,右擊"參考"並選擇"管理NuGet包"。
  2. 搜尋並安裝: 在NuGet包管理器中搜尋"ComPDFKit"。 選擇合適的包(例如,ComPDFKit.NetFrameworkComPDFKit.Conversion.NetFramework)並點擊"安裝"。

哪些是必需的專案設置?

  1. 確認安裝: 確保該包出現在SOLUTION EXPLORER中的"參考"下。
  • 平台目標:設置為x64以便處理大文件
  • 輸出型別:控制臺應用程式用於測試,類庫用於生產
  • 框架版本:建議.NET 6+,以獲得最佳性能
  • NuGet包管理:啟用包還原以便依賴管理
  1. 下載包: 從官方ComPDFKit網站獲取ComPDFKit.NetFramework.nupkg文件。
  2. 配置NuGet資源: 建立或編輯一個專案目錄中的nuget.config文件,以包括本地包的路徑。

通過各種方法可將IronPDF整合至專案。 有關完整的安裝概覽,請參考官方文件。 該程式庫支持多種安裝方法,以適應不同的開發工作流。

  1. 安裝本地包: 重新打開您的解決方案到VISUAL STUDIO,進入"管理NuGet包",選擇本地包資源。 從本地資源安裝ComPDFKit包。

  2. Visual Studio NuGet包管理器: 在解決方案中右擊"依賴項"並選擇"管理NuGet包"。在"瀏覽"標籤中,搜尋"IronPDF"並安裝最新版本。 如需高級NuGet安裝選項,請參閱詳細指南。

  3. 獲取授權: 聯繫ComPDFKit團隊以獲取試用或完整授權。
  4. 在程式碼中應用授權:

  5. 包管理器主控台: 通過工具 > NuGet包管理器 > 包管理器主控台使用NuGet包管理器主控台。 執行命令:

    _CODEBLOCK0

    這提供了通過命令行介面快速安裝程式庫的功能。

包管理器主控台窗口顯示IronPDF NuGet包版本2024.5.2在C#測試板專案中的安裝,並確認成功安裝。

  1. 直接手動下載方法: 存取IronPDF NuGet包頁。 下載包文件,雙擊將其新增到專案中,然後重新載入解決方案。

  2. 手動安裝: 直接下載最新的IronPDF版本。 按照提供的說明進行手動VISUAL STUDIO整合。 對於Windows專用的安裝,請參閱Windows安裝指南

為何選擇特定的安裝方式?

不同的安裝方法適合於不同的場合:

  • NuGet包管理器: 最適合對Internet有存取權限的VISUAL STUDIO使用者
  • 包管理器主控台: 適合於腳本化的部屬和CI/CD流水線
  • 直接下載: 適合於離線開發環境
  • 手動安裝: 對於自定義部屬配置是必需的

這些方法有效地將IronPDF整合到.NET專案中。 如需快速入門指導,請存取入門指南。平台專用指南涵蓋F#整合VB.NET使用

如何安裝ComPDFKit C#?

新增ComPDFKit到專案的兩大主要方法:NuGet包管理器或本地包安裝。 相比單包的IronPDF的方法,安裝過程需要更多步驟。

何時應使用NuGet包管理器?

  1. 打開NuGet包管理器: 在方案管理器中右擊"參考"並選擇"管理NuGet包"。
  2. 搜尋並安裝: 在包管理器中搜尋"ComPDFKit"。 選擇合適的包(ComPDFKit.NetFramework)並點擊"安裝"。

NuGet包管理器介面顯示comPDFKit搜尋結果,列表上有三個套餐:ComPDFKit.NetFramework、ComPDFKit.Conversion.NetFramework和compdfkit-api-.NET,適合不同用途。

  1. 驗證安裝: 確保該包顯示在方案管理器的"參考"下。 可能需要多個包才能獲得完全功能。

何時應使用本地包?

本地包安裝更適合有諸多限制的環境:

  1. 下載包: 從官方ComPDFKit網站獲取ComPDFKit.NetFramework.nupkg。
  2. 配置NuGet來源: 在專案目錄中建立或編輯nuget.config以包括本地包路徑。

    _CODEBLOCK1

  3. 安裝本地包: 重新打開解決方案,導航到"管理NuGet包",選擇本地包來源,並安裝ComPDFKit。

如何應用我的授權金鑰?

不同程式庫之間的授權實施有顯著差異:

  1. 獲取授權: 聯繫ComPDFKit以獲取試用或完整授權。
  2. 在程式碼中應用授權:

    _CODEBLOCK2

    新增此方法以驗證授權。 有關IronPDF更簡單的授權實施,請參閱授權金鑰文件。 IronPDF僅需要設置License.LicenseKey屬性,簡化了授權過程。

如何將HTML轉換為PDF?

將HTML轉換為PDF是一種常見需求,用於生成報告、發票或從Web內容生成文件。 IronPDF與ComPDFKit都提供HTML轉PDF的轉換能力,但其方法不同。 IronPDF使用內建的Chromium渲染引擎,以獲得像素完美的輸出,而ComPDFKit的渲染引擎和CSS框架支持應當與您的具體專案需求相適應。

IronPDF如何處理HTML轉PDF轉換?

IronPDF使用基於Chrome的渲染引擎以獲得高品質的輸出。 此過程將HTML、CSS和JavaScript準確地轉換為PDF格式。 該程式庫支持HTML字串HTML文件URL

基本的HTML字串轉PDF轉換範例:

using IronPdf;
using System;

class Program
{
    static void Main()
    {
        // Define your HTML string
        string htmlString = @"
            <h1>Hello, IronPDF!</h1>
            <p>This is a simple PDF created from an HTML string.</p>";

        var renderer = new ChromePdfRenderer();
        // Convert the HTML string to a PDF document
        PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlString);
        // Save the PDF document to a file
        string outputPath = "sample.pdf";
        pdf.SaveAs(outputPath);
        Console.WriteLine($"PDF created successfully and saved to {outputPath}");
    }
}
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        // Define your HTML string
        string htmlString = @"
            <h1>Hello, IronPDF!</h1>
            <p>This is a simple PDF created from an HTML string.</p>";

        var renderer = new ChromePdfRenderer();
        // Convert the HTML string to a PDF document
        PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlString);
        // Save the PDF document to a file
        string outputPath = "sample.pdf";
        pdf.SaveAs(outputPath);
        Console.WriteLine($"PDF created successfully and saved to {outputPath}");
    }
}
Imports IronPdf
Imports System

Friend Class Program
	Shared Sub Main()
		' Define your HTML string
		Dim htmlString As String = "
            <h1>Hello, IronPDF!</h1>
            <p>This is a simple PDF created from an HTML string.</p>"

		Dim renderer = New ChromePdfRenderer()
		' Convert the HTML string to a PDF document
		Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(htmlString)
		' Save the PDF document to a file
		Dim outputPath As String = "sample.pdf"
		pdf.SaveAs(outputPath)
		Console.WriteLine($"PDF created successfully and saved to {outputPath}")
	End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF輸出顯示了一個簡單的PDF,包含'Hello, IronPDF!'的標題和描述文字,展示了HTML轉PDF的基本轉換能力。

IronPDF還能直接轉換HTML文件,支持CSS和JavaScript的嵌入:

using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        // Convert the HTML file to a PDF document
        PdfDocument pdf = renderer.RenderHtmlFileAsPdf("index.html");
        // Save the PDF document to a file
        string outputPath = "HTML File.pdf";
        pdf.SaveAs(outputPath);
        Console.WriteLine($"PDF created successfully and saved to {outputPath}");
    }
}
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        // Convert the HTML file to a PDF document
        PdfDocument pdf = renderer.RenderHtmlFileAsPdf("index.html");
        // Save the PDF document to a file
        string outputPath = "HTML File.pdf";
        pdf.SaveAs(outputPath);
        Console.WriteLine($"PDF created successfully and saved to {outputPath}");
    }
}
Imports IronPdf
Imports System

Friend Class Program
	Shared Sub Main()
		Dim renderer = New ChromePdfRenderer()
		' Convert the HTML file to a PDF document
		Dim pdf As PdfDocument = renderer.RenderHtmlFileAsPdf("index.html")
		' Save the PDF document to a file
		Dim outputPath As String = "HTML File.pdf"
		pdf.SaveAs(outputPath)
		Console.WriteLine($"PDF created successfully and saved to {outputPath}")
	End Sub
End Class
$vbLabelText   $csharpLabel

Sample invoice #123 showing website design services totaling $385, rendered as a PDF document with professional formatting and layout preserved from HTML source.

IronPDF支持哪些高級HTML功能?

IronPDF的Chromium引擎可以處理複雜的Web技術:

ComPDFKit如何處理HTML轉PDF轉換?

ComPDFKit的.NET程式庫將HTML轉PDF轉換作為其PDF生成功能之一(截至2026年4月)。 該程式庫還提供Open API服務,用於雲端文件處理。 開發者應參考ComPDFKit文件以確認目前的實施細節及任何CSS框架渲染限制,以供其特定使用情況。

ComPDFKit的HTML渲染如何比較?

IronPDF使用嵌入的Chromium引擎提供像素完美的Bootstrap和CSS3渲染,而ComPDFKit的渲染能力和CSS框架相容性應根據您的具體渲染需求進行評估:

  • 渲染引擎: IronPDF嵌入Chromium,確保一致的跨瀏覽器CSS渲染
  • CSS框架支持: IronPDF的Chromium引擎本原支持Bootstrap 5、Flexbox和CSS Grid
  • JavaScript執行: IronPDF的引擎執行動態內容渲染的JavaScript
  • 本地處理: IronPDF完全在內部渲染,無外部服務依賴

Bootstrap CSS與PDF生成能否合用?

現代電子商務和商業應用廣泛使用Bootstrap,以確保UI設計的一致性。 當生成發票、收據和報告為PDF時,維持Bootstrap樣式能確保品牌一致性。 IronPDF的嵌入Chromium引擎提供完整的Bootstrap支援,而ComPDFKit在處理複雜的CSS框架時的渲染能力應視具體專案需求而評估。

IronPDF如何處理Bootstrap樣式?

IronPDF使用Chromium的渲染引擎,提供所有版本(Bootstrap 5, 4, 和 3)的像素完美Bootstrap支援。 該程式庫無縫處理Flexbox佈局、CSS Grid、響應式媒體和自定義組件。 有關高級CSS渲染,請參閱渲染選項指南

using IronPdf;

// Set license
IronPdf.License.LicenseKey = "License-Key";

var renderer = new ChromePdfRenderer();

// Bootstrap 5 e-commerce invoice example
string bootstrapInvoice = @"
<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link href='___PROTECTED_URL_138___ rel='stylesheet'>
    <style>
        @page { margin: 20mm; }
        .invoice-header { border-bottom: 3px solid #0d6efd; }
        .product-row { border-bottom: 1px solid #dee2e6; }
        .total-section { background-color: #f8f9fa; }
    </style>
</head>
<body>
    <div class='container-fluid p-4'>

        <div class='row invoice-header pb-4 mb-4'>
            <div class='col-8'>
                <h1 class='display-4 text-primary'>INVOICE</h1>
                <p class='text-muted mb-0'>TechStore Inc.</p>
                <p class='text-muted mb-0'>123 Commerce Street, Tech City, TC 12345</p>
                <p class='text-muted'>Email: sales@techstore.com | Phone: (555) 123-4567</p>
            </div>
            <div class='col-4 text-end'>
                <p class='mb-1'><strong>Invoice #:</strong> INV-2024-1089</p>
                <p class='mb-1'><strong>Date:</strong> October 27, 2024</p>
                <p class='mb-1'><strong>Due Date:</strong> November 27, 2024</p>
                <span class='badge bg-success'>PAID</span>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-6'>
                <h5 class='text-primary'>Bill To:</h5>
                <p class='mb-1'><strong>Acme Corporation</strong></p>
                <p class='mb-1'>456 Business Ave</p>
                <p class='mb-1'>Enterprise City, EC 67890</p>
                <p class='mb-0'>contact@acmecorp.com</p>
            </div>
            <div class='col-6 text-end'>
                <h5 class='text-primary'>Payment Method:</h5>
                <p class='mb-1'>Credit Card ending in 4242</p>
                <p class='mb-0'>Transaction ID: TXN-9876543210</p>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-12'>
                <table class='table'>
                    <thead class='table-primary'>
                        <tr>
                            <th scope='col'>#</th>
                            <th scope='col'>Product</th>
                            <th scope='col'>Description</th>
                            <th scope='col' class='text-center'>Qty</th>
                            <th scope='col' class='text-end'>Unit Price</th>
                            <th scope='col' class='text-end'>Amount</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class='product-row'>
                            <td>1</td>
                            <td><strong>IronPDF Pro License</strong></td>
                            <td>Professional developer license with 1 year support</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$2,999.00</td>
                            <td class='text-end'><strong>$2,999.00</strong></td>
                        </tr>
                        <tr class='product-row'>
                            <td>2</td>
                            <td><strong>Priority Support</strong></td>
                            <td>24/7 priority technical support package</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$999.00</td>
                            <td class='text-end'><strong>$999.00</strong></td>
                        </tr>
                        <tr class='product-row'>
                            <td>3</td>
                            <td><strong>Training Package</strong></td>
                            <td>On-site developer training (2 days)</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$1,500.00</td>
                            <td class='text-end'><strong>$1,500.00</strong></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div class='row justify-content-end mb-4'>
            <div class='col-md-6'>
                <div class='card total-section'>
                    <div class='card-body'>
                        <div class='row mb-2'>
                            <div class='col-6'><strong>Subtotal:</strong></div>
                            <div class='col-6 text-end'>$5,498.00</div>
                        </div>
                        <div class='row mb-2'>
                            <div class='col-6'><strong>Tax (8.5%):</strong></div>
                            <div class='col-6 text-end'>$467.33</div>
                        </div>
                        <div class='row mb-2'>
                            <div class='col-6 text-success'><strong>Discount (10%):</strong></div>
                            <div class='col-6 text-end text-success'>-$549.80</div>
                        </div>
                        <hr>
                        <div class='row'>
                            <div class='col-6'><h4 class='text-primary'>Total:</h4></div>
                            <div class='col-6 text-end'><h4 class='text-primary'>$5,415.53</h4></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-12'>
                <div class='alert alert-info' role='alert'>
                    <h6 class='alert-heading'>Payment Terms</h6>
                    <p class='mb-0'>Payment is due within 30 days. Late payments may incur a 1.5% monthly interest charge. Thank you for your business!</p>
                </div>
            </div>
        </div>

        <div class='row border-top pt-3'>
            <div class='col-12 text-center text-muted'>
                <small>TechStore Inc. | Tax ID: 12-3456789 | All prices in USD</small>
            </div>
        </div>
    </div>
</body>
</html>";

// Render PDF with optimized settings
var pdf = renderer.RenderHtmlAsPdf(bootstrapInvoice);

// Add metadata for document management
pdf.MetaData.Title = "Invoice INV-2024-1089";
pdf.MetaData.Author = "TechStore Inc.";
pdf.MetaData.Subject = "Sales Invoice";
pdf.MetaData.Keywords = "invoice, payment, e-commerce";

// Save the invoice
pdf.SaveAs("invoice-with-bootstrap.pdf");
using IronPdf;

// Set license
IronPdf.License.LicenseKey = "License-Key";

var renderer = new ChromePdfRenderer();

// Bootstrap 5 e-commerce invoice example
string bootstrapInvoice = @"
<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link href='___PROTECTED_URL_138___ rel='stylesheet'>
    <style>
        @page { margin: 20mm; }
        .invoice-header { border-bottom: 3px solid #0d6efd; }
        .product-row { border-bottom: 1px solid #dee2e6; }
        .total-section { background-color: #f8f9fa; }
    </style>
</head>
<body>
    <div class='container-fluid p-4'>

        <div class='row invoice-header pb-4 mb-4'>
            <div class='col-8'>
                <h1 class='display-4 text-primary'>INVOICE</h1>
                <p class='text-muted mb-0'>TechStore Inc.</p>
                <p class='text-muted mb-0'>123 Commerce Street, Tech City, TC 12345</p>
                <p class='text-muted'>Email: sales@techstore.com | Phone: (555) 123-4567</p>
            </div>
            <div class='col-4 text-end'>
                <p class='mb-1'><strong>Invoice #:</strong> INV-2024-1089</p>
                <p class='mb-1'><strong>Date:</strong> October 27, 2024</p>
                <p class='mb-1'><strong>Due Date:</strong> November 27, 2024</p>
                <span class='badge bg-success'>PAID</span>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-6'>
                <h5 class='text-primary'>Bill To:</h5>
                <p class='mb-1'><strong>Acme Corporation</strong></p>
                <p class='mb-1'>456 Business Ave</p>
                <p class='mb-1'>Enterprise City, EC 67890</p>
                <p class='mb-0'>contact@acmecorp.com</p>
            </div>
            <div class='col-6 text-end'>
                <h5 class='text-primary'>Payment Method:</h5>
                <p class='mb-1'>Credit Card ending in 4242</p>
                <p class='mb-0'>Transaction ID: TXN-9876543210</p>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-12'>
                <table class='table'>
                    <thead class='table-primary'>
                        <tr>
                            <th scope='col'>#</th>
                            <th scope='col'>Product</th>
                            <th scope='col'>Description</th>
                            <th scope='col' class='text-center'>Qty</th>
                            <th scope='col' class='text-end'>Unit Price</th>
                            <th scope='col' class='text-end'>Amount</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class='product-row'>
                            <td>1</td>
                            <td><strong>IronPDF Pro License</strong></td>
                            <td>Professional developer license with 1 year support</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$2,999.00</td>
                            <td class='text-end'><strong>$2,999.00</strong></td>
                        </tr>
                        <tr class='product-row'>
                            <td>2</td>
                            <td><strong>Priority Support</strong></td>
                            <td>24/7 priority technical support package</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$999.00</td>
                            <td class='text-end'><strong>$999.00</strong></td>
                        </tr>
                        <tr class='product-row'>
                            <td>3</td>
                            <td><strong>Training Package</strong></td>
                            <td>On-site developer training (2 days)</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$1,500.00</td>
                            <td class='text-end'><strong>$1,500.00</strong></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div class='row justify-content-end mb-4'>
            <div class='col-md-6'>
                <div class='card total-section'>
                    <div class='card-body'>
                        <div class='row mb-2'>
                            <div class='col-6'><strong>Subtotal:</strong></div>
                            <div class='col-6 text-end'>$5,498.00</div>
                        </div>
                        <div class='row mb-2'>
                            <div class='col-6'><strong>Tax (8.5%):</strong></div>
                            <div class='col-6 text-end'>$467.33</div>
                        </div>
                        <div class='row mb-2'>
                            <div class='col-6 text-success'><strong>Discount (10%):</strong></div>
                            <div class='col-6 text-end text-success'>-$549.80</div>
                        </div>
                        <hr>
                        <div class='row'>
                            <div class='col-6'><h4 class='text-primary'>Total:</h4></div>
                            <div class='col-6 text-end'><h4 class='text-primary'>$5,415.53</h4></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-12'>
                <div class='alert alert-info' role='alert'>
                    <h6 class='alert-heading'>Payment Terms</h6>
                    <p class='mb-0'>Payment is due within 30 days. Late payments may incur a 1.5% monthly interest charge. Thank you for your business!</p>
                </div>
            </div>
        </div>

        <div class='row border-top pt-3'>
            <div class='col-12 text-center text-muted'>
                <small>TechStore Inc. | Tax ID: 12-3456789 | All prices in USD</small>
            </div>
        </div>
    </div>
</body>
</html>";

// Render PDF with optimized settings
var pdf = renderer.RenderHtmlAsPdf(bootstrapInvoice);

// Add metadata for document management
pdf.MetaData.Title = "Invoice INV-2024-1089";
pdf.MetaData.Author = "TechStore Inc.";
pdf.MetaData.Subject = "Sales Invoice";
pdf.MetaData.Keywords = "invoice, payment, e-commerce";

// Save the invoice
pdf.SaveAs("invoice-with-bootstrap.pdf");
Imports IronPdf

' Set license
IronPdf.License.LicenseKey = "License-Key"

Dim renderer As New ChromePdfRenderer()

' Bootstrap 5 e-commerce invoice example
Dim bootstrapInvoice As String = "
<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link href='___PROTECTED_URL_138___ rel='stylesheet'>
    <style>
        @page { margin: 20mm; }
        .invoice-header { border-bottom: 3px solid #0d6efd; }
        .product-row { border-bottom: 1px solid #dee2e6; }
        .total-section { background-color: #f8f9fa; }
    </style>
</head>
<body>
    <div class='container-fluid p-4'>

        <div class='row invoice-header pb-4 mb-4'>
            <div class='col-8'>
                <h1 class='display-4 text-primary'>INVOICE</h1>
                <p class='text-muted mb-0'>TechStore Inc.</p>
                <p class='text-muted mb-0'>123 Commerce Street, Tech City, TC 12345</p>
                <p class='text-muted'>Email: sales@techstore.com | Phone: (555) 123-4567</p>
            </div>
            <div class='col-4 text-end'>
                <p class='mb-1'><strong>Invoice #:</strong> INV-2024-1089</p>
                <p class='mb-1'><strong>Date:</strong> October 27, 2024</p>
                <p class='mb-1'><strong>Due Date:</strong> November 27, 2024</p>
                <span class='badge bg-success'>PAID</span>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-6'>
                <h5 class='text-primary'>Bill To:</h5>
                <p class='mb-1'><strong>Acme Corporation</strong></p>
                <p class='mb-1'>456 Business Ave</p>
                <p class='mb-1'>Enterprise City, EC 67890</p>
                <p class='mb-0'>contact@acmecorp.com</p>
            </div>
            <div class='col-6 text-end'>
                <h5 class='text-primary'>Payment Method:</h5>
                <p class='mb-1'>Credit Card ending in 4242</p>
                <p class='mb-0'>Transaction ID: TXN-9876543210</p>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-12'>
                <table class='table'>
                    <thead class='table-primary'>
                        <tr>
                            <th scope='col'>#</th>
                            <th scope='col'>Product</th>
                            <th scope='col'>Description</th>
                            <th scope='col' class='text-center'>Qty</th>
                            <th scope='col' class='text-end'>Unit Price</th>
                            <th scope='col' class='text-end'>Amount</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class='product-row'>
                            <td>1</td>
                            <td><strong>IronPDF Pro License</strong></td>
                            <td>Professional developer license with 1 year support</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$2,999.00</td>
                            <td class='text-end'><strong>$2,999.00</strong></td>
                        </tr>
                        <tr class='product-row'>
                            <td>2</td>
                            <td><strong>Priority Support</strong></td>
                            <td>24/7 priority technical support package</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$999.00</td>
                            <td class='text-end'><strong>$999.00</strong></td>
                        </tr>
                        <tr class='product-row'>
                            <td>3</td>
                            <td><strong>Training Package</strong></td>
                            <td>On-site developer training (2 days)</td>
                            <td class='text-center'>1</td>
                            <td class='text-end'>$1,500.00</td>
                            <td class='text-end'><strong>$1,500.00</strong></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div class='row justify-content-end mb-4'>
            <div class='col-md-6'>
                <div class='card total-section'>
                    <div class='card-body'>
                        <div class='row mb-2'>
                            <div class='col-6'><strong>Subtotal:</strong></div>
                            <div class='col-6 text-end'>$5,498.00</div>
                        </div>
                        <div class='row mb-2'>
                            <div class='col-6'><strong>Tax (8.5%):</strong></div>
                            <div class='col-6 text-end'>$467.33</div>
                        </div>
                        <div class='row mb-2'>
                            <div class='col-6 text-success'><strong>Discount (10%):</strong></div>
                            <div class='col-6 text-end text-success'>-$549.80</div>
                        </div>
                        <hr>
                        <div class='row'>
                            <div class='col-6'><h4 class='text-primary'>Total:</h4></div>
                            <div class='col-6 text-end'><h4 class='text-primary'>$5,415.53</h4></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class='row mb-4'>
            <div class='col-12'>
                <div class='alert alert-info' role='alert'>
                    <h6 class='alert-heading'>Payment Terms</h6>
                    <p class='mb-0'>Payment is due within 30 days. Late payments may incur a 1.5% monthly interest charge. Thank you for your business!</p>
                </div>
            </div>
        </div>

        <div class='row border-top pt-3'>
            <div class='col-12 text-center text-muted'>
                <small>TechStore Inc. | Tax ID: 12-3456789 | All prices in USD</small>
            </div>
        </div>
    </div>
</body>
</html>"

' Render PDF with optimized settings
Dim pdf = renderer.RenderHtmlAsPdf(bootstrapInvoice)

' Add metadata for document management
pdf.MetaData.Title = "Invoice INV-2024-1089"
pdf.MetaData.Author = "TechStore Inc."
pdf.MetaData.Subject = "Sales Invoice"
pdf.MetaData.Keywords = "invoice, payment, e-commerce"

' Save the invoice
pdf.SaveAs("invoice-with-bootstrap.pdf")
$vbLabelText   $csharpLabel

顯示的Bootstrap主要功能:

  • 網格系統: col-*類提供響應式佈局結構
  • 字體:h5提供分層式文字樣式
  • 表格:table-hover用于結構化資料展示
  • 卡片: card-body為總結區段提供背景樣式
  • 徽章: badge bg-success用於支付狀態指示
  • 警報: alert alert-info用於支付條款通知
  • 工具: pb-</em> 用於間距工具
  • 自定義樣式: 與Bootstrap類組合以實現具體發票設計

IronPDF的Chromium引擎確保完美的Bootstrap組件渲染:

  • 網格系統: col-*類提供響應式佈局
  • 字體: h5提供分層式樣式
  • 表格table-hover 用於結構化資料
  • 卡片cardcard-body 用於樣式化的區塊
  • 徽章badge bg-success 用於狀態指示
  • 警示alert alert-info 用於通知
  • 實用工具text-center、間距工具
  • 自訂樣式:與Bootstrap結合設計發票

對於網頁字型和圖標,IronPDF提供完整的自訂排版支援。 在疑難排解Bootstrap佈局時,請參考Bootstrap Flex CSS 疑難排解。 在視窗及縮放設置時,正確的配置可確保響應式佈局正確渲染。

ComPDFKit與Bootstrap的考量是什麼?

ComPDFKit的HTML到PDF轉換不使用內嵌的Chromium引擎,這意味著複雜的Bootstrap佈局、CSS網格和Flexbox渲染可能與原生瀏覽器引擎結果不同:

  • CSS框架支援:複雜Flexbox或CSS網格佈局的渲染可能有所不同
  • 渲染一致性:結果取決於HTML引擎的實現
  • 自訂樣式:應根據專案需求測試Bootstrap組件的渲染忠實度

對於需要可靠的Bootstrap渲染且能完全控制樣式和佈局的應用程式,IronPDF的內嵌Chromium引擎提供一致的結果。 IronPDF的整合方法保持完整CSS框架的相容性,而不依賴外部渲染服務。

如何將水印新增到PDF中?

加水印到PDF有助於保護文件完整性、聲明所有權和增加安全性。 水印可以是文字、標誌或圖片,顯示在背景或前景。 它們阻止未經授權的使用和發佈,同時傳達文件狀態或建立者身份的重要資訊。

如何使用IronPDF新增水印?

IronPDF提供簡單易用的程式化PDF文件水印應用程式。 此功能與程式庫整合,允許開發人員使用C#程式碼施加水印。 對於背景和前景位置,IronPDF提供靈活的定位選項。

using IronPdf;
using IronPdf.Editing;

class Program
{
    static void Main()
    {
        License.LicenseKey = "License-Code";

        string watermarkHtml = @"
            <img style='width: 500px;' src='C:\Users\Tayyab Ali\Desktop\watermark.png'>
            <h1>IronPDF Watermark</h1>";

        ChromePdfRenderer renderer = new ChromePdfRenderer();
        PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>It's a PDF with a watermark</h1>");
        // Apply watermark with 30 degrees rotation and 50% opacity
        pdf.ApplyWatermark(watermarkHtml, rotation: 30, opacity: 50);
        pdf.SaveAs("Confidential.pdf");
    }
}
using IronPdf;
using IronPdf.Editing;

class Program
{
    static void Main()
    {
        License.LicenseKey = "License-Code";

        string watermarkHtml = @"
            <img style='width: 500px;' src='C:\Users\Tayyab Ali\Desktop\watermark.png'>
            <h1>IronPDF Watermark</h1>";

        ChromePdfRenderer renderer = new ChromePdfRenderer();
        PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>It's a PDF with a watermark</h1>");
        // Apply watermark with 30 degrees rotation and 50% opacity
        pdf.ApplyWatermark(watermarkHtml, rotation: 30, opacity: 50);
        pdf.SaveAs("Confidential.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Editing

Friend Class Program
	Shared Sub Main()
		License.LicenseKey = "License-Code"

		Dim watermarkHtml As String = "
            <img style='width: 500px;' src='C:\Users\Tayyab Ali\Desktop\watermark.png'>
            <h1>IronPDF Watermark</h1>"

		Dim renderer As New ChromePdfRenderer()
		Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>It's a PDF with a watermark</h1>")
		' Apply watermark with 30 degrees rotation and 50% opacity
		pdf.ApplyWatermark(watermarkHtml, rotation:= 30, opacity:= 50)
		pdf.SaveAs("Confidential.pdf")
	End Sub
End Class
$vbLabelText   $csharpLabel

 PDF頁面顯示紅色

此範例使用ChromePdfRenderer從HTML建立PDF。 ApplyWatermark方法應用包含圖像和標題的水印。 旋轉設置為30度並有50%透明度,保證可見性而不遮蓋內容。 生成的PDF將保存到指定路徑。

有哪些進階水印選項?

IronPDF提供完整的水印功能:

  • 基於HTML的水印:使用完整的HTML/CSS設計複雜水印
  • 定位控制:3x3 格位置系統
  • 透明度設置:精細調整透明度
  • 旋轉選項:以任意角度應用斜角水印
  • 頁面選擇:應用於所有頁面或特定範圍
  • 多重水印:根據需要分層不同的水印

有關進階技術,請參閱壓印文字和圖像高效新增多重印章印章新內容指南展示動態水印生成。

如何使用ComPDFKit新增水印?

ComPDFKit提供通過程式庫的方法程式化新增水印的功能。 這個程式碼範例演示如何新增文字水印:

static private bool AddTextWatermark(CPDFDocument document)
{
    CPDFWatermark watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
    watermark.SetText("test");
    watermark.SetFontName("Helvetica"); 
    watermark.SetPages("0-3");
    byte[] color = { 255, 0, 0 };
    watermark.SetTextRGBColor(color);
    watermark.SetScale(2);
    watermark.SetRotation(0);
    watermark.SetOpacity(120);
    watermark.SetVertalign(C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER);
    watermark.SetHorizalign(C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER);
    watermark.SetVertOffset(0);
    watermark.SetHorizOffset(0);
    watermark.SetFront(true);
    watermark.SetFullScreen(true);
    watermark.SetVerticalSpacing(10);
    watermark.SetHorizontalSpacing(10);
    watermark.CreateWatermark();
    string path = "AddTextWatermarkTest.pdf";
    if (!document.WriteToFilePath(path))
    {
        return false;
    }
    Console.WriteLine("Browse the changed file in " + path);
    return true;
}

CPDFDocument document = CPDFDocument.InitWithFilePath("SamplePDF.pdf");
if (AddTextWatermark(document))
{
    Console.WriteLine("Add text watermark done.");
}
else
{
    Console.WriteLine("Add text watermark failed.");
}
static private bool AddTextWatermark(CPDFDocument document)
{
    CPDFWatermark watermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT);
    watermark.SetText("test");
    watermark.SetFontName("Helvetica"); 
    watermark.SetPages("0-3");
    byte[] color = { 255, 0, 0 };
    watermark.SetTextRGBColor(color);
    watermark.SetScale(2);
    watermark.SetRotation(0);
    watermark.SetOpacity(120);
    watermark.SetVertalign(C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER);
    watermark.SetHorizalign(C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER);
    watermark.SetVertOffset(0);
    watermark.SetHorizOffset(0);
    watermark.SetFront(true);
    watermark.SetFullScreen(true);
    watermark.SetVerticalSpacing(10);
    watermark.SetHorizontalSpacing(10);
    watermark.CreateWatermark();
    string path = "AddTextWatermarkTest.pdf";
    if (!document.WriteToFilePath(path))
    {
        return false;
    }
    Console.WriteLine("Browse the changed file in " + path);
    return true;
}

CPDFDocument document = CPDFDocument.InitWithFilePath("SamplePDF.pdf");
if (AddTextWatermark(document))
{
    Console.WriteLine("Add text watermark done.");
}
else
{
    Console.WriteLine("Add text watermark failed.");
}
Private Shared Function AddTextWatermark(ByVal document As CPDFDocument) As Boolean
	Dim watermark As CPDFWatermark = document.InitWatermark(C_Watermark_Type.WATERMARK_TYPE_TEXT)
	watermark.SetText("test")
	watermark.SetFontName("Helvetica")
	watermark.SetPages("0-3")
	Dim color() As Byte = { 255, 0, 0 }
	watermark.SetTextRGBColor(color)
	watermark.SetScale(2)
	watermark.SetRotation(0)
	watermark.SetOpacity(120)
	watermark.SetVertalign(C_Watermark_Vertalign.WATERMARK_VERTALIGN_CENTER)
	watermark.SetHorizalign(C_Watermark_Horizalign.WATERMARK_HORIZALIGN_CENTER)
	watermark.SetVertOffset(0)
	watermark.SetHorizOffset(0)
	watermark.SetFront(True)
	watermark.SetFullScreen(True)
	watermark.SetVerticalSpacing(10)
	watermark.SetHorizontalSpacing(10)
	watermark.CreateWatermark()
	Dim path As String = "AddTextWatermarkTest.pdf"
	If Not document.WriteToFilePath(path) Then
		Return False
	End If
	Console.WriteLine("Browse the changed file in " & path)
	Return True
End Function

Private document As CPDFDocument = CPDFDocument.InitWithFilePath("SamplePDF.pdf")
If AddTextWatermark(document) Then
	Console.WriteLine("Add text watermark done.")
Else
	Console.WriteLine("Add text watermark failed.")
End If
$vbLabelText   $csharpLabel

 PDF 頁顯示重複的紅色

此範例使用CPDFDocument打開現有的PDF。 AddTextWatermark方法初始化文字水印,設置類似文字內容、字體、顏色、縮放、旋轉、不透明度、對齊和間距等屬性。 水印應用到指定頁面,並保存到定義的路徑。 使用不同的方法處理圖像水印,這增加了實現的複雜性。

如何建立PDF/A合規文件?

PDF/A是為長期數位保存而設計的PDF標準版本。 確保PDF/A符合性保證將來可靠的查看和再現。 本節探討如何使用兩個程式庫建立PDF/A合規文件。

IronPDF如何建立PDF/A文件?

IronPDF簡化了標準PDF到PDF/A符合格式的轉換過程。 程式庫支援各種PDF/A標準,包括PDF/A-1,PDF/A-2和PDF/A-3。關於PDF/A重要更新PDF/A-3與ZUGFeRD支持的資訊,請參閱產品公告。

using IronPdf;
using System;

class Program
{
    static void Main()
    {
        License.LicenseKey = "License-Key";
        PdfDocument pdf = PdfDocument.FromFile("Source.pdf");
        pdf.SaveAsPdfA("pdfa-compliant.pdf", PdfAVersions.PdfA3);
    }
}
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        License.LicenseKey = "License-Key";
        PdfDocument pdf = PdfDocument.FromFile("Source.pdf");
        pdf.SaveAsPdfA("pdfa-compliant.pdf", PdfAVersions.PdfA3);
    }
}
Imports IronPdf
Imports System

Friend Class Program
	Shared Sub Main()
		License.LicenseKey = "License-Key"
		Dim pdf As PdfDocument = PdfDocument.FromFile("Source.pdf")
		pdf.SaveAsPdfA("pdfa-compliant.pdf", PdfAVersions.PdfA3)
	End Sub
End Class
$vbLabelText   $csharpLabel

這個過程包括:

  1. 初始化IronPDF:首先匯入IronPDF程式庫並設置您的授權金鑰。
  2. 載入PDF:使用PdfDocument.FromFile載入您的來源PDF檔案。
  3. 轉換並保存:通過指定所需的PDF/A版本來轉換載入的PDF並保存生成的文件。

為什麼選擇PDF/A進行文件歸檔?

PDF/A為長期保存提供了多個優勢:

  • 自含文件:嵌入所有字型和資源
  • 無外部依賴:消除對外部內容的依賴
  • 標準化格式:ISO認證的歸檔用途
  • 元資料保存:保留文件屬性
  • 視覺再現性:保證一致的外觀年代

IronPDF還支援PDF/UA格式,滿足可及性要求,確保文件符合Section 508合規標準。

ComPDFKit如何建立PDF/A文件?

ComPDFKit提供可靠的PDF/A轉換,通過文件初始化、輸出路徑定義和轉換方法調用。

static public bool CovertToPDFA1a(CPDFDocument document)
{
    string convertToPDFA1aPath = "ConvertToPDFA1aTest.pdf";
    if (!document.WritePDFAToFilePath(CPDFType.CPDFTypePDFA1a, convertToPDFA1aPath))
    {
        return false;
    }
    Console.WriteLine("Browse the changed file in " + convertToPDFA1aPath);
    return true;
}

CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
if (CovertToPDFA1a(document))
{
    Console.WriteLine("Convert to PDF/A-1a done.");
}
else
{
    Console.WriteLine("Convert to PDF/A-1a failed.");
}
static public bool CovertToPDFA1a(CPDFDocument document)
{
    string convertToPDFA1aPath = "ConvertToPDFA1aTest.pdf";
    if (!document.WritePDFAToFilePath(CPDFType.CPDFTypePDFA1a, convertToPDFA1aPath))
    {
        return false;
    }
    Console.WriteLine("Browse the changed file in " + convertToPDFA1aPath);
    return true;
}

CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
if (CovertToPDFA1a(document))
{
    Console.WriteLine("Convert to PDF/A-1a done.");
}
else
{
    Console.WriteLine("Convert to PDF/A-1a failed.");
}
Public Shared Function CovertToPDFA1a(ByVal document As CPDFDocument) As Boolean
	Dim convertToPDFA1aPath As String = "ConvertToPDFA1aTest.pdf"
	If Not document.WritePDFAToFilePath(CPDFType.CPDFTypePDFA1a, convertToPDFA1aPath) Then
		Return False
	End If
	Console.WriteLine("Browse the changed file in " & convertToPDFA1aPath)
	Return True
End Function

Private document As CPDFDocument = CPDFDocument.InitWithFilePath("CommonFivePage.pdf")
If CovertToPDFA1a(document) Then
	Console.WriteLine("Convert to PDF/A-1a done.")
Else
	Console.WriteLine("Convert to PDF/A-1a failed.")
End If
$vbLabelText   $csharpLabel

步驟包括:

  1. 初始化文件:使用CPDFDocument.InitWithFilePath載入PDF文件。
  2. 設置輸出目錄:確保輸出目錄存在或必要時建立它。
  3. 轉換為PDF/A:使用指定的PDF/A型別調用WritePDFAToFilePath進行轉換並保存文件。

如何將數位簽章新增到PDF?

數位簽章用於驗證文件真實性和完整性。 本節展示如何使用兩個程式庫新增數位簽章。 有關完整的數位簽章實現,IronPDF提供詳細文件。

如何使用IronPDF簽署PDF?

IronPDF提供簡單而有效的數位簽章應用。 該程式庫支援X.509證書和HSM整合以滿足企業安全需求。

using IronPdf;
using IronPdf.Signing;

class Program
{
    static void Main(string[] args)
    {
        var simpleSignature = new PdfSignature("MyCert.p12", "newpassword");
        simpleSignature.SignPdfFile("sample.pdf");
    }
}
using IronPdf;
using IronPdf.Signing;

class Program
{
    static void Main(string[] args)
    {
        var simpleSignature = new PdfSignature("MyCert.p12", "newpassword");
        simpleSignature.SignPdfFile("sample.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Signing

Friend Class Program
	Shared Sub Main(ByVal args() As String)
		Dim simpleSignature = New PdfSignature("MyCert.p12", "newpassword")
		simpleSignature.SignPdfFile("sample.pdf")
	End Sub
End Class
$vbLabelText   $csharpLabel

這個過程包括:

  1. 初始化IronPDF:匯入所需的IronPDF程式庫。
  2. 建立簽章:使用證書檔和密碼初始化PdfSignature物件。
  3. 簽署PDF:使用SignPdfFile將簽章應用於PDF。

IronPDF提供哪些進階簽署選項?

IronPDF提供完整的數位簽章功能:

  • 多種簽章型別:基於證書、視覺和表單欄位簽章
  • HSM支援:硬體安全模塊整合
  • 時間戳伺服器:為簽章新增受信的時間戳
  • 簽章外觀:定制視覺簽章表示形式
  • 驗證支援:程式化驗證現有簽章
  • 版本控制:維護簽章版本歷史

有關簽章問題的疑難排解,請參閱數位簽章疑難排解指南

如何使用ComPDFKit簽署PDF?

ComPDFKit提供完整的數位簽章建立,具有廣泛的自訂選項。

private static void CreateDigitalSignature(CPDFDocument document, string certificatePath, string password)
{
    Console.WriteLine("--------------------");
    Console.WriteLine("Create digital signature.");
    CPDFSignatureCertificate certificate = CPDFPKCS12CertHelper.GetCertificateWithPKCS12Path("Certificate.pfx", "ComPDFKit");
    CPDFPage page = document.PageAtIndex(0);
    CPDFSignatureWidget signatureField = page.CreateWidget(C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS) as CPDFSignatureWidget;
    signatureField.SetRect(new CRect(28, 420, 150, 370));
    signatureField.SetWidgetBorderRGBColor(new byte[] { 0, 0, 0 });
    signatureField.SetWidgetBgRGBColor(new byte[] { 150, 180, 210 });
    signatureField.UpdateAp();
    string name = GetGrantorFromDictionary(certificate.SubjectDict) + "\n";
    string date = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
    string reason = "I am the owner of the document.";
    string location = certificate.SubjectDict["C"];
    string DN = certificate.Subject;

    CPDFSignatureConfig signatureConfig = new CPDFSignatureConfig
    {
        Text = GetGrantorFromDictionary(certificate.SubjectDict),
        Content =
            "Name: " + name + "\n" +
            "Date: " + date + "\n" +
            "Reason: " + reason + " \n" +
            "Location: " + location + "\n" +
            "DN: " + DN + "\n",
        IsContentAlignLeft = false,
        IsDrawLogo = true,
        LogoBitmap = new Bitmap("Logo.png"),
        TextColor = new float[] { 0, 0, 0 },
        ContentColor = new float[] { 0, 0, 0 }
    };
    string filePath = document.FileName + "_Signed.pdf";
    signatureField.UpdataApWithSignature(signatureConfig);
    if (document.WriteSignatureToFilePath(signatureField,
        filePath,
        certificatePath, password,
        location,
        reason, CPDFSignaturePermissions.CPDFSignaturePermissionsNone))
    {
        Console.WriteLine("File saved in " + filePath);
        Console.WriteLine("Create digital signature done.");
    }
    else
    {
        Console.WriteLine("Create digital signature failed.");
    }
    Console.WriteLine("--------------------");
}
private static void CreateDigitalSignature(CPDFDocument document, string certificatePath, string password)
{
    Console.WriteLine("--------------------");
    Console.WriteLine("Create digital signature.");
    CPDFSignatureCertificate certificate = CPDFPKCS12CertHelper.GetCertificateWithPKCS12Path("Certificate.pfx", "ComPDFKit");
    CPDFPage page = document.PageAtIndex(0);
    CPDFSignatureWidget signatureField = page.CreateWidget(C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS) as CPDFSignatureWidget;
    signatureField.SetRect(new CRect(28, 420, 150, 370));
    signatureField.SetWidgetBorderRGBColor(new byte[] { 0, 0, 0 });
    signatureField.SetWidgetBgRGBColor(new byte[] { 150, 180, 210 });
    signatureField.UpdateAp();
    string name = GetGrantorFromDictionary(certificate.SubjectDict) + "\n";
    string date = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
    string reason = "I am the owner of the document.";
    string location = certificate.SubjectDict["C"];
    string DN = certificate.Subject;

    CPDFSignatureConfig signatureConfig = new CPDFSignatureConfig
    {
        Text = GetGrantorFromDictionary(certificate.SubjectDict),
        Content =
            "Name: " + name + "\n" +
            "Date: " + date + "\n" +
            "Reason: " + reason + " \n" +
            "Location: " + location + "\n" +
            "DN: " + DN + "\n",
        IsContentAlignLeft = false,
        IsDrawLogo = true,
        LogoBitmap = new Bitmap("Logo.png"),
        TextColor = new float[] { 0, 0, 0 },
        ContentColor = new float[] { 0, 0, 0 }
    };
    string filePath = document.FileName + "_Signed.pdf";
    signatureField.UpdataApWithSignature(signatureConfig);
    if (document.WriteSignatureToFilePath(signatureField,
        filePath,
        certificatePath, password,
        location,
        reason, CPDFSignaturePermissions.CPDFSignaturePermissionsNone))
    {
        Console.WriteLine("File saved in " + filePath);
        Console.WriteLine("Create digital signature done.");
    }
    else
    {
        Console.WriteLine("Create digital signature failed.");
    }
    Console.WriteLine("--------------------");
}
Imports Microsoft.VisualBasic

Private Shared Sub CreateDigitalSignature(ByVal document As CPDFDocument, ByVal certificatePath As String, ByVal password As String)
	Console.WriteLine("--------------------")
	Console.WriteLine("Create digital signature.")
	Dim certificate As CPDFSignatureCertificate = CPDFPKCS12CertHelper.GetCertificateWithPKCS12Path("Certificate.pfx", "ComPDFKit")
	Dim page As CPDFPage = document.PageAtIndex(0)
	Dim signatureField As CPDFSignatureWidget = TryCast(page.CreateWidget(C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS), CPDFSignatureWidget)
	signatureField.SetRect(New CRect(28, 420, 150, 370))
	signatureField.SetWidgetBorderRGBColor(New Byte() { 0, 0, 0 })
	signatureField.SetWidgetBgRGBColor(New Byte() { 150, 180, 210 })
	signatureField.UpdateAp()
	Dim name As String = GetGrantorFromDictionary(certificate.SubjectDict) & vbLf
	Dim [date] As String = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss")
	Dim reason As String = "I am the owner of the document."
	Dim location As String = certificate.SubjectDict("C")
	Dim DN As String = certificate.Subject

	Dim signatureConfig As New CPDFSignatureConfig With {
		.Text = GetGrantorFromDictionary(certificate.SubjectDict),
		.Content = "Name: " & name & vbLf & "Date: " & [date] & vbLf & "Reason: " & reason & " " & vbLf & "Location: " & location & vbLf & "DN: " & DN & vbLf,
		.IsContentAlignLeft = False,
		.IsDrawLogo = True,
		.LogoBitmap = New Bitmap("Logo.png"),
		.TextColor = New Single() { 0, 0, 0 },
		.ContentColor = New Single() { 0, 0, 0 }
	}
	Dim filePath As String = document.FileName & "_Signed.pdf"
	signatureField.UpdataApWithSignature(signatureConfig)
	If document.WriteSignatureToFilePath(signatureField, filePath, certificatePath, password, location, reason, CPDFSignaturePermissions.CPDFSignaturePermissionsNone) Then
		Console.WriteLine("File saved in " & filePath)
		Console.WriteLine("Create digital signature done.")
	Else
		Console.WriteLine("Create digital signature failed.")
	End If
	Console.WriteLine("--------------------")
End Sub
$vbLabelText   $csharpLabel

步驟包括:

  1. 初始化文件和證書:載入PDF文件並使用CPDFPKCS12CertHelper檢索證書。
  2. 建立並配置簽章欄位:向PDF新增簽章欄位,設置其屬性並配置簽章詳情。
  3. 施加簽章:使用WriteSignatureToFilePath施加簽章並保存簽署的PDF。

如何從PDF中提取文字?

從PDF文件提取文字對於資料處理和分析至關重要。 本節說明如何使用兩個程式庫進行文字提取。

IronPDF如何提取文字?

IronPDF提供從PDF文件中提取文字的簡單方法。 程式庫提供提取所有文字或特定頁面內容的方法。 對於解析PDF內容,IronPDF支援結構化提取。 當存取PDF DOM物件時,開發人員可以檢索詳細的內容資訊。

using IronPdf;
using System.IO;

PdfDocument pdf = PdfDocument.FromFile("PDF File With Text.pdf");
string text = pdf.ExtractAllText();
File.WriteAllText("PDF Text.txt", text);
using IronPdf;
using System.IO;

PdfDocument pdf = PdfDocument.FromFile("PDF File With Text.pdf");
string text = pdf.ExtractAllText();
File.WriteAllText("PDF Text.txt", text);
Imports IronPdf
Imports System.IO

Private pdf As PdfDocument = PdfDocument.FromFile("PDF File With Text.pdf")
Private text As String = pdf.ExtractAllText()
File.WriteAllText("PDF Text.txt", text)
$vbLabelText   $csharpLabel

這個過程包括:

  1. 初始化IronPDF:匯入IronPDF程式庫。
  2. 載入PDF:使用PdfDocument.FromFile載入PDF文件。
  3. 提取文字:調用ExtractAllText從PDF中檢索所有文字內容。
  4. 將文字保存至檔案:使用標準檔案I/O操作將提取的文字寫入檔案。

有哪些高級的文字提取功能可用?

IronPDF提供先進的文字提取能力:

  • 頁面特定提取:從個別頁面提取文字
  • 結構化內容:存取帶有格式資訊的文字
  • 查找和替換在PDF中查找和替換文字
  • 正則表達式支援:基於模式的文字提取
  • 坐標為基礎的提取:從特定區域提取文字
  • 語言支援:處理UTF-8和國際字元

有關完整的文字閱讀範例,請查看閱讀PDF文字指南

ComPDFKit如何提取文字?

ComPDFKit提供從PDF文件靈活提取文字的功能。

static private bool PDFToText(CPDFDocument document)
{
    string path = "//PDFToText.txt";
    if (!document.PdfToText("1-" + document.PageCount.ToString(), path))//Page ranges are counted from 1
    {
        return false;
    }
    Console.WriteLine("Browse the generated file in " + path);
    return true;
}

static void Main(string[] args)
{
    Console.WriteLine("Running PDFPage test sample…\r\n");
    SDKLicenseHelper.LicenseVerify();
    CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");

    if (PDFToText(document))
    {
        Console.WriteLine("PDF to text done.");
    }
    else
    {
        Console.WriteLine("PDF to text failed.");
    }
    Console.WriteLine("--------------------");
    Console.WriteLine("Done!");
    Console.WriteLine("--------------------");
    Console.ReadLine();
}
static private bool PDFToText(CPDFDocument document)
{
    string path = "//PDFToText.txt";
    if (!document.PdfToText("1-" + document.PageCount.ToString(), path))//Page ranges are counted from 1
    {
        return false;
    }
    Console.WriteLine("Browse the generated file in " + path);
    return true;
}

static void Main(string[] args)
{
    Console.WriteLine("Running PDFPage test sample…\r\n");
    SDKLicenseHelper.LicenseVerify();
    CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");

    if (PDFToText(document))
    {
        Console.WriteLine("PDF to text done.");
    }
    else
    {
        Console.WriteLine("PDF to text failed.");
    }
    Console.WriteLine("--------------------");
    Console.WriteLine("Done!");
    Console.WriteLine("--------------------");
    Console.ReadLine();
}
Imports Microsoft.VisualBasic

Private Shared Function PDFToText(ByVal document As CPDFDocument) As Boolean
	Dim path As String = "//PDFToText.txt"
	If Not document.PdfToText("1-" & document.PageCount.ToString(), path) Then 'Page ranges are counted from 1
		Return False
	End If
	Console.WriteLine("Browse the generated file in " & path)
	Return True
End Function

Shared Sub Main(ByVal args() As String)
	Console.WriteLine("Running PDFPage test sample…" & vbCrLf)
	SDKLicenseHelper.LicenseVerify()
	Dim document As CPDFDocument = CPDFDocument.InitWithFilePath("CommonFivePage.pdf")

	If PDFToText(document) Then
		Console.WriteLine("PDF to text done.")
	Else
		Console.WriteLine("PDF to text failed.")
	End If
	Console.WriteLine("--------------------")
	Console.WriteLine("Done!")
	Console.WriteLine("--------------------")
	Console.ReadLine()
End Sub
$vbLabelText   $csharpLabel

步驟是:

  1. 初始化文件:使用CPDFDocument.InitWithFilePath載入PDF文件。
  2. 提取和保存文字:使用PdfToText從指定的頁面範圍提取文字並將其保存到檔案中。

真實世界的使用案例場景

了解何時使用每個程式庫有助於開發人員根據專案需求做出明智的決定。 這些情境說明每個程式庫擅長的實際應用。

何時應選擇IronPDF?

企業文件生成系統 一家金融服務公司需要生成每月超過50,000份具有複雜佈局、圖表和合規性要求的報表。

IronPDF的優勢:

SaaS發票生成平台 一個提供多租戶SaaS平台的公司,幫助生成成千上萬使用者的品牌發票,並支持自定義模板。

IronPDF的優勢:

  • HTML/CSS支援:完整的Bootstrap相容性可用於品牌模板
  • 效能:透過Docker部署提供可擴展架構
  • 自訂化頁眉/頁腳水印用於品牌化
  • API設計:簡單的API減少開發時間
  • 雲端準備:原生AzureAWS支援

何時應考慮ComPDFKit?

基本PDF查看應用程式 一個需要PDF查看和基本註釋功能的桌面應用,無需HTML轉換。

ComPDFKit的優勢:

  • 查看器元件:內建查看功能
  • 註釋工具:原生的註釋支援
  • 簡單整合:直接PDF操作無需HTML
  • 離線操作:核心功能無需網路

文件存檔系統 一個專注於PDF組織與基本編輯的內部文件管理系統。

ComPDFKit的優勢:

  • 檔案操作:強大的PDF合併/拆分能力
  • 基本編輯:文字和圖像修改工具
  • 傳統方法:熟悉的PDF為中心API設計

有哪些授權選項?

IronPDF和ComPDFKit的授權模型在方法和使用條款上有所不同。 了解這些差異有助於開發人員根據專案需求和預算選擇合適的工具。

IronPDF提供哪些授權選項?

IronPDF pricing page showing three license tiers (Lite $999, Plus $1,499, Professional $2,999) with Professional selected, displaying 10 developers/locations/projects coverage and $4,998 total with extended support and upgrade protection.

IronPDF遵循透明的商用授權模型:

授權型別:

  • Lite授權($999):1開發者,1地點,1專案
  • Plus授權($1,499):3開發者,3地點,3專案
  • Professional授權($2,999):10開發者,10地點,10專案
  • Enterprise/OEM:無限部署的自定定價

主要優勢:

  • 永久性授權:一次性付款使用終身
  • 免版稅分發:無運行時費用
  • 源程式碼可用:對於安全Audit可選購
  • 靈活升級:可用擴展授權升級
  • 試用期免費試用授權評估

IronPDF的商業模式確保企業獲得專用支持、完整文件和專業PDF生成和操作的高級功能。 透明的定價結構消除了隱藏成本,提供預算的可預測性。

ComPDFKit提供哪些授權選項?

ComPDFKit提供靈活的授權,滿足不同商業需求:

授權選項:

  • 永久授權:一次性付款獲得終身SDK存取權限
  • 訂閱授權:定期付款並持續更新
  • 基於報價的定價:根據專案需求提供的自定價

考慮:

  • 可變成本:定價需要直接聯繫以獲得報價
  • 更新費用:版本更新的可選費用
  • 支援包:獨立的支持協議要求
  • API使用上限:基於雲端API處理可能需要額外的成本

有哪些文件和支持可用?

IronPDF提供了哪些支持?

IronPDF提供文件和支持基礎建設:

文件資源:

支持渠道:

  • 24/5工程支持:直接聯繫開發團隊
  • 回應時間:有保證的快速支持回應
  • 程式碼審查:工程團隊審查複雜實施
  • 定制解決方案:獨特需求的協助
  • 正常更新產品更新階段性功能

發送工程支援請求,詳細指導確保有效問題解決。 支持基礎結構包括不同平台的部署協助

ComPDFKit提供哪些支援?

ComPDFKit提供基本文件和支援資源:

文件:

  • 入門指南:基本設置說明
  • API參考:標準方法文件
  • 範例程式碼:有限的核心功能範例
  • 平台文件:基本的平台整合指南

支持選項:

  • 電子郵件支援:標準營業時間內回應
  • 技術協助:基本疑難排解幫助
  • 社群論壇:使用者驅動的支持社群

雖然兩個程式庫都提供文件和支援,IronPDF提供全面的資源、更快的回應時間和直接的工程支持,這對於生產環境部署至關重要。

效能和優化考量

效能影響生產系統的可行性。 了解每個程式庫的優化能力有助於架構師設計高效的解決方案。

IronPDF如何優化效能?

IronPDF提供廣泛的效能優化功能

架構優勢:

  • 原生Chrome引擎:優化的C++渲染引擎
  • 記憶體管理:高效處理大文件
  • 執行緒安全:為並發網頁應用而設計
  • 資源池:可重用的渲染實例

效能功能:

ComPDFKit的效能特徵是什麼?

ComPDFKit提供標準效能,適用於常見的PDF操作:

效能檔案:

  • 記憶體使用:資源消耗因文件複雜性而異
  • 並發性:查看ComPDFKit文件以獲取非同步和執行緒建議
  • 跨平台:適用於Windows、Linux、macOS、Docker、Azure和AWS

企業整合模式

生產系統需要特定的架構模式以提高可靠性和可擴展性。 了解整合方法有助於團隊實現可靠的解決方案。

如何在微服務中實現IronPDF?

IronPDF支援現代架構模式:

容器化的 PDF 服務:

// Dockerfile for IronPDF microservice
FROM mcr.microsoft.com/dotnet/aspnet:6.0
RUN apt-get update && apt-get install -y \
    libgdiplus \
    libc6-dev \
    libx11-6
COPY . /app
WORKDIR /app
ENTRYPOINT ["dotnet", "PdfService.dll"]
// Dockerfile for IronPDF microservice
FROM mcr.microsoft.com/dotnet/aspnet:6.0
RUN apt-get update && apt-get install -y \
    libgdiplus \
    libc6-dev \
    libx11-6
COPY . /app
WORKDIR /app
ENTRYPOINT ["dotnet", "PdfService.dll"]
' Dockerfile for IronPDF microservice
FROM mcr.microsoft.com/dotnet/aspnet:6.0
RUN apt-get update && apt-get install -y _
    libgdiplus _
    libc6-dev _
    libx11-6
COPY . /app
WORKDIR /app
ENTRYPOINT ["dotnet", "PdfService.dll"]
$vbLabelText   $csharpLabel

可擴展的 API 實施:

[ApiController]
[Route("api/[controller]")]
public class PdfController : ControllerBase
{
    private readonly ChromePdfRenderer _renderer;

    public PdfController()
    {
        _renderer = new ChromePdfRenderer();
        // Configure for production
        _renderer.RenderingOptions.EnableJavaScript = true;
        _renderer.RenderingOptions.RenderDelay = 500;
    }

    [HttpPost("generate")]
    public async Task<IActionResult> GeneratePdf([FromBody] PdfRequest request)
    {
        try
        {
            var pdf = await _renderer.RenderHtmlAsPdfAsync(request.Html);

            // Apply security if needed
            if (request.RequirePassword)
            {
                pdf.SecuritySettings.SetPassword(request.Password);
            }

            var stream = pdf.Stream;
            return File(stream, "application/pdf", request.FileName);
        }
        catch (Exception ex)
        {
            // 完整的 error handling
            return StatusCode(500, new { error = ex.Message });
        }
    }
}
[ApiController]
[Route("api/[controller]")]
public class PdfController : ControllerBase
{
    private readonly ChromePdfRenderer _renderer;

    public PdfController()
    {
        _renderer = new ChromePdfRenderer();
        // Configure for production
        _renderer.RenderingOptions.EnableJavaScript = true;
        _renderer.RenderingOptions.RenderDelay = 500;
    }

    [HttpPost("generate")]
    public async Task<IActionResult> GeneratePdf([FromBody] PdfRequest request)
    {
        try
        {
            var pdf = await _renderer.RenderHtmlAsPdfAsync(request.Html);

            // Apply security if needed
            if (request.RequirePassword)
            {
                pdf.SecuritySettings.SetPassword(request.Password);
            }

            var stream = pdf.Stream;
            return File(stream, "application/pdf", request.FileName);
        }
        catch (Exception ex)
        {
            // 完整的 error handling
            return StatusCode(500, new { error = ex.Message });
        }
    }
}
Imports Microsoft.AspNetCore.Mvc

<ApiController>
<Route("api/[controller]")>
Public Class PdfController
    Inherits ControllerBase

    Private ReadOnly _renderer As ChromePdfRenderer

    Public Sub New()
        _renderer = New ChromePdfRenderer()
        ' Configure for production
        _renderer.RenderingOptions.EnableJavaScript = True
        _renderer.RenderingOptions.RenderDelay = 500
    End Sub

    <HttpPost("generate")>
    Public Async Function GeneratePdf(<FromBody> request As PdfRequest) As Task(Of IActionResult)
        Try
            Dim pdf = Await _renderer.RenderHtmlAsPdfAsync(request.Html)

            ' Apply security if needed
            If request.RequirePassword Then
                pdf.SecuritySettings.SetPassword(request.Password)
            End If

            Dim stream = pdf.Stream
            Return File(stream, "application/pdf", request.FileName)
        Catch ex As Exception
            ' 完整的 error handling
            Return StatusCode(500, New With {.error = ex.Message})
        End Try
    End Function
End Class
$vbLabelText   $csharpLabel

優勢:

  • 水平擴展:根據需要新增實例
  • 錯誤隔離:服務失敗不影響系統
  • 資源控制:容器限制防止資源耗盡
  • 部署靈活性:與Kubernetes,Docker Swarm相容

ComPDFKit企業整合將如何?

ComPDFKit 支持整合到伺服器端應用中,適用於Windows、Linux、macOS、Docker、Azure和AWS環境。 開發人員應該查看ComPDFKit文件以獲取多租戶部署、擴展策略和容器化架構的具體指導。

安全與合規功能

企業應用程式需要可靠的安全功能以滿足法規要求和資料保護。

IronPDF如何處理安全性?

IronPDF提供完整的安全功能

加密選項:

  • AES 256位加密:軍事級安全性
  • 使用者/所有者密碼:分別的存取級別
  • 權限控制:細粒度行為限制
  • 數位簽章:基於證書的身份驗證
  • HSM 支援:硬體安全模塊整合

合規功能:

實現範例:

// Secure document generation
var pdf = renderer.RenderHtmlAsPdf(htmlContent);

// Apply complete security
pdf.SecuritySettings.SetPassword("user123");
pdf.SecuritySettings.SetOwnerPassword("owner456");
pdf.SecuritySettings.MakePdfDocumentReadOnly();
pdf.SecuritySettings.SetPdfSecuritySettings(
    canPrint: true,
    canCopy: false,
    canModify: false
);

// Add digital signature
var signature = new PdfSignature("cert.pfx", "password");
pdf.SignWithSignature(signature);

// Ensure compliance
pdf.SaveAsPdfA("secure-compliant.pdf", PdfAVersions.PdfA3);
// Secure document generation
var pdf = renderer.RenderHtmlAsPdf(htmlContent);

// Apply complete security
pdf.SecuritySettings.SetPassword("user123");
pdf.SecuritySettings.SetOwnerPassword("owner456");
pdf.SecuritySettings.MakePdfDocumentReadOnly();
pdf.SecuritySettings.SetPdfSecuritySettings(
    canPrint: true,
    canCopy: false,
    canModify: false
);

// Add digital signature
var signature = new PdfSignature("cert.pfx", "password");
pdf.SignWithSignature(signature);

// Ensure compliance
pdf.SaveAsPdfA("secure-compliant.pdf", PdfAVersions.PdfA3);
' Secure document generation
Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)

' Apply complete security
pdf.SecuritySettings.SetPassword("user123")
pdf.SecuritySettings.SetOwnerPassword("owner456")
pdf.SecuritySettings.MakePdfDocumentReadOnly()
pdf.SecuritySettings.SetPdfSecuritySettings(
    canPrint:=True,
    canCopy:=False,
    canModify:=False
)

' Add digital signature
Dim signature As New PdfSignature("cert.pfx", "password")
pdf.SignWithSignature(signature)

' Ensure compliance
pdf.SaveAsPdfA("secure-compliant.pdf", PdfAVersions.PdfA3)
$vbLabelText   $csharpLabel

ComPDFKit提供什麼安全性?

ComPDFKit提供基本的安全功能:

  • 密碼保護:基本使用者/所有者密碼
  • 加密:標準PDF加密
  • 權限:有限的權限設置
  • 數位簽章:基於證書的簽名

對於像HSM支持、消毒、和全面的可及性合規工具等進階功能,請參閱ComPDFKit文件以驗證當前可用性。

我應該選擇哪個PDF程式庫?

IronPDF和ComPDFKit的比較揭示了不同使用情境和需求的明顯區別。

IronPDF為何在企業應用中出類拔萃

IronPDF是生產系統的上佳選擇,尤其是需要:

技術卓越:

  • 原生HTML渲染:Chromium引擎保證完美轉換
  • 效能:高容量的非同步/多執行緒處理
  • 可靠性:為網頁應用設計的執行緒安全架構
  • 整合:簡單的API減少開發時間

商業價值:

  • 全面成本擁有:透明的定價無隱藏費用
  • 支持基礎建設:24/5工程支持將停機時間降至最低
  • 文件:500多個範例加速開發
  • 未來驗證:常規更新和新功能

IronPDF獲得了财富500強公司開發團隊在高容量文件生成工作負載中的信任,其功能包括可靠的Bootstrap渲染、非同步處理和企業支持。

當ComPDFKit可能足夠時

ComPDFKit可能適合於:

  • 簡單PDF查看:基本桌面應用程式
  • 有限範圍:無HTML轉換需求的專案
  • 預算約束:當基於報價的定價適合預算模型時
  • 基本操作:簡單的合併/拆分需求

最終建議

對許多具備效能、可靠性和架構模式優先順序的生.NET開發者來說,IronPDF提供完整的解決方案。 它的技術能力、企業功能和卓越的支持基礎建設的結合確保了項目的成功交付。

關鍵決策因素:

需求 IronPDF ComPDFKit 優勝者
HTML到PDF 原生Chromium 外部API IronPDF
效能 非同步/多執行緒 同步 IronPDF
CSS支援 完整的Bootstrap/Flexbox 限制的 IronPDF
文件 500多個範例 基本 IronPDF
支援 24/5工程 僅限電子郵尹洹汲 IronPDF
企业功能 完整的 限制的 IronPDF
總位 Transparent 可變的 IronPDF

IronPDF提供免費試用授權測試程式庫及其能力。 IronPDF授權從$999開幕。 此外,Iron Software打包九個程式庫僅需支付兩個的費用,包括IronXLIronOCR以及IronPDF。

對於需要企業支持的專業PDF生成的團隊,IronPDF提供完整的解決方案。 其與財富500強公司合作的成就記錄、完整的功能集和對於開發者成功的承諾使其成爲嚴肅.NET應用的改進選擇。

請注意ComPDFKit是其相應所有者的註冊商標。 此網站與ComPDFKit無關,不受其認可或贊助。 所有產品名稱、徽標和品牌均為其各自所有者的財產。 比較僅供資訊參考,並反映了撰寫時的公開可用資訊。

常見問題

如何在C#中將HTML轉換為PDF?

您可以使用IronPDF的RenderHtmlAsPdf方法將HTML字串轉換為PDF。此方法適合將HTML、CSS和JavaScript轉換為高品質的PDF文件。

使用C# PDF程式庫有什麼好處?

像IronPDF和ComPDFKit這樣的C# PDF程式庫可以實現PDF建立、修改和文字/圖像提取。它們支持表單處理、數位簽章和安全性等功能,提供跨不同平台的彈性。

我能在C#中為我的PDF新增安全性嗎?

是的,使用IronPDF,您可以透過設置密碼、加密文件和新增數位簽章來增強PDF的安全性,以保護敏感資訊。

ComPDFKit如何處理PDF編輯和轉換?

ComPDFKit提供強大的PDF編輯功能和轉換至包括PDF/A在內的多種格式,以便長期數位保存,使其在跨平台專案中更加靈活。

C# PDF程式庫有哪些授權選項?

IronPDF提供商業授權模式,附有永久授權,而ComPDFKit提供永久和訂閱式授權,以滿足業務需求的靈活性。

使用這些程式庫的開發者可獲得什麼支援和資源?

IronPDF提供全面的文件和快速的客戶支援,使其適合企業級應用程式。ComPDFKit也提供完善的文件和技術支援。

IronPDF和ComPDFKit在HTML轉PDF方面如何比較?

IronPDF在HTML轉PDF上表現出色,支持HTML字串、URL、ASPX網頁表單和MVC視圖,而ComPDFKit提供更廣泛的PDF編輯和轉換功能。

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

Iron 支援團隊

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