產品比較

IronPDF與Apryse C#之比較

發佈 2024年3月6日
分享:

1. 介紹

作為 C# 開發人員,處理 PDF 是我們工作中的常見部分,特別是在構建需要生成、編輯或顯示文件的應用程序時。這就是為什麼擁有一個良好的 PDF 庫至關重要的原因。這些庫通過提供內建的函數來處理複雜任務,例如文件轉換、文字編輯和處理 PDF 中的圖像,為我們節省了時間和麻煩。沒有它們,我們就得從頭開始編寫所有的代碼,不僅耗時,而且容易出錯。

在這次比較中,我們將會檢視兩個熱門的 PDF 庫: IronPDFApryse C#IronPDF 因其強大的功能而聞名,使在 .NET 環境中使用 PDF 變得輕而易舉,從將 HTML 轉換為 PDF 到高級文件編輯。另一方面,Apryse C# 提供了一種簡化的 PDF 處理方法,專注於易用性和效率。我們將深入探究每個庫所提供的具體功能,以幫助您決定哪一個最適合您的項目。

2. Apryse C#

IronPDF與Apryse C#的比較:圖1 - Apryse C#網頁

Apryse C# 這是一個針對.NET應用程序的綜合PDF庫,旨在簡化C#環境中PDF操作的過程。它之前被稱為PDFTron SDK。其廣泛的功能和工具使其成為開發人員精確且輕鬆處理PDF文件的寶貴資產。

2.1 主要功能

  • 輕鬆整合至 .NET 專案: Apryse C# 提供與 .NET(包括 ASP.NET Core 和傳統的 .NET Framework 應用程式)無縫整合。這確保了開發人員能夠將 PDF 功能直接納入其專案中,無需大量的設定或配置。
  • 文件創建與編輯: 開發人員可以使用 Apryse C# 從頭創建 PDF 或編輯現有的 PDF。這包括添加文字、圖像和表單,甚至直接在應用程式中操作 PDF 頁面,例如重新排序、合併或拆分文件。
  • HTML 至 PDF 轉換: 使用 Apryse C#,將 HTML 內容轉換為 PDF 格式非常簡單。此功能對於從網頁或 HTML 模板生成發票、報告和其他文件特別有用。
  • 廣泛的表單欄位支援: Apryse C# 提供對 PDF 表單欄位的強大支援,允許開發人員程式化地創建、編輯和填寫 PDF 表單。這非常適合基於用戶輸入或外部數據來源自動生成填寫的表單。
  • 文字和內容擷取: 該庫能夠從 PDF 文件中擷取文字和其他內容。此功能對於需要分析或處理 PDF 中信息的應用程式(例如搜尋工具或內容管理系統)至關重要。
  • 安全性和加密: Apryse C# 提供全面的安全功能,包括加密 PDF 文件、設置權限和管理數字簽名。這確保了敏感文件受到保護並符合合規標準。
  • 進階 PDF 功能: 開發人員可以利用諸如註解、書籤和超連結等進階 PDF 功能,提升其 PDF 文件的互動性和可用性。這使得創建更具動態性和用戶友好的 PDF 成為可能。

3. IronPDF C#

IronPDF 與 Apryse C# 的比較:圖 2 - IronPDF 網頁

IronPDF 作為專為 .NET 開發人員量身打造的多功能且強大PDF庫,IronPDF 突出其優勢。其簡化了複雜的PDF處理過程,允許在C#應用中直接創建、編輯和轉換PDF文檔。IronPDF 提供Java、Python 和 C# 等不同的編程語言版本。IronPDF 設計以滿足各種PDF處理需求,成為開發人員尋求效率和可靠性的首選解決方案。

3.1 主要功能

  • 無縫的 .NET 整合: IronPDF 確保與 .NET 專案的輕鬆整合,支持 .NET Framework 和 .NET Core,包括 ASP.NET 專案。這種相容性使應用程式中納入 PDF 功能變得更為簡便,而無需複雜的設定。
  • HTML 轉 PDF: IronPDF 的其中一個亮點功能是其將 HTML 轉換為 PDF 的能力。 HTML 轉 PDF. 此功能使開發人員能夠將網頁或HTML字串轉換成高質量的PDF文件,非常適合從HTML模板生成報告、收據和其他文檔。
  • 進階PDF編輯: 使用IronPDF,開發人員可以深入編輯PDF文件。此功能包括新增文字、圖片和向量圖形,並修改PDF文件中的現有內容。IronPDF提供一套完整的編輯工具,以根據具體需求自訂PDF。
  • PDF表單處理: IronPDF提供強大的支持來處理 PDF 表單它允許創建和編輯表單欄位,以及以程式化方式填寫表單。這對於自動化文件工作流程和數據輸入過程特別有用。
  • 內容提取: 該庫在從PDF文件中提取文本、圖像甚至元資料方面表現出色。這一功能支持從內容分析到數據遷移項目的一系列應用,使開發人員能夠有效檢索和使用PDF內容。
  • 文件安全: IronPDF 提供全面的安全功能,包括支持 密碼保護, 加密和 PDF 文件權限管理。這確保了敏感信息保持安全且文件訪問受到控制。
  • 性能和可擴展性: 考慮到性能設計,IronPDF 針對速度和可擴展性進行了優化,使其適合處理大量的 PDF 文件或應對高需求的應用程序而不會影響性能。
  • 全面的文檔和支持: IronPDF 擁有廣泛的文檔和反應迅速的支持團隊。這確保了開發人員能夠獲得他們需要的資源和幫助,以有效地在他們的項目中實現和排除 PDF 功能的故障。
  • 兼容各種 PDF 標準: IronPDF C# 支持廣泛的 PDF 標準,確保文件與不同的查看器兼容並符合行業規範。這包括支持 PDF/A 用於歸檔目的, PDF/UA 以提高可及性,等等。

4. 建立 C# 主控台應用程式

在 Visual Studio 中建立一個主控台應用程式是一個簡單的過程,這為任何 .NET 開發專案奠定了基礎,包括使用像 IronPDF 或 Apryse C# 這樣的程式庫進行 PDF 操作。以下是如何開始:

4.1 啟動 Visual Studio

在你的電腦上打開 Visual Studio。如果你還沒有安裝 Visual Studio,請從微軟官方網站下載並安裝符合你需求的版本。

4.2 創建一個新項目

打開 Visual Studio 後,從初始儀表板中選擇“創建一個新項目”選項。

IronPDF與Apryse C#比較:圖3 - 創建一個新的VS項目

4.3 選擇專案類型

在“建立新專案”窗口中,你會看到各種專案範本。在搜索框中輸入“Console”或從列表中找到“主控台應用程式”範本。請确保選擇特定於 C# 的範本,而不是其他語言的範本。

IronPDF 與 Apryse C# 的比較:圖4 - 選擇控制台應用程式範本

4.4 配置您的專案

選擇「控制台應用程式」範本後,點擊「下一步」按鈕。您將被提示配置新專案:

  • 專案名稱: 為您的專案輸入一個名稱。
  • 位置: 選擇您想在電腦上儲存專案的位置。

    • 解決方案名稱: 預設情況下,這與您的專案名稱匹配,但您可根據需要進行更改。

IronPDF與Apryse C#的比較:圖5 - 配置專案詳情

  • Framework: 選擇您希望使用的 .NET 版本。除非您有特定要求,否則建議使用最新版本。

IronPDF與Apryse C#的比較:圖6 - 選擇合適的.NET框架

4.5 建立專案

設定專案屬性後,點擊「建立」按鈕。Visual Studio 將會建立一個新的主控台應用程式專案,並包含一個預設的 Program.cs 檔案。

4.6 探索專案結構

花點時間在解決方案總管窗格中探索產生的專案結構。對於主控台應用程式,您主要將與 Program.cs 檔案一起工作,這是您將撰寫 C# 代碼的地方。

5. 安裝 IronPDF 庫

將 IronPDF 庫整合到您的 .NET 專案中,讓您可以利用其完善的 PDF 操作功能。有多種方法可以安裝 IronPDF,確保了根據您的首選工作流程或開發環境設置的靈活性。

5.1 使用 NuGet 套件管理器

Visual Studio 中的 NuGet 套件管理器提供了一個友好的界面來管理庫和依賴項。

  1. 在 Visual Studio 中打開你的專案。

  2. 導航到方案總管,右鍵點擊你的專案,選擇 "管理 NuGet 套件"。

  3. 點擊 "瀏覽" 標籤,然後搜索 "IronPdf"。

  4. 在搜索結果中找到 IronPDF,選擇它,然後點擊 "安裝"。Visual Studio 會處理其餘的部分,將 IronPDF 添加到你的專案中。

IronPDF 與 Apryse C# 之比較:圖 7 - 通過 NuGet 套件管理器安裝 IronPDF

5.2 使用 Visual Studio 命令行

對於那些更喜歡使用命令行的用戶,Visual Studio 中的 Package Manager Console 提供了一種直接安裝包的方式。

  1. 打開 Visual Studio 並進入您的項目。

  2. 導航到工具 > NuGet 套件管理器 > 套件管理器控制台。

  3. 在控制台中,輸入以下命令並按 Enter:
Install-Package IronPdf

此命令將下載並安裝最新版本的IronPDF到您的專案中。

5.3 從 NuGet 網頁直接下載

如果您更喜歡在將套件整合到您的專案之前手動下載套件,您可以從 NuGet 網站進行下載。

  1. 訪問 NuGet 網站 並搜尋 "IronPdf."

  2. IronPdf 頁面找到「下載套件」連結並點擊它以下載 .nupkg 文件。

IronPDF 與 Apryse C# 的比較:圖 8 - 通過 NuGet 網頁直接安裝 IronPDF

  1. 下載完成後,您可以手動將套件添加到您的專案。在 Visual Studio 中,導航到方案總管,右鍵點擊您的專案,然後選擇「添加 > 引用」。導航到下載的 .nupkg 文件所在的位置,選中它,並將其添加到您的專案中。

這些方法中的每一種都能成功將 IronPDF 集成到您的 .NET 專案中,讓您開始使用其強大的 PDF 處理功能。

6. 安裝 Apryse C

將 Apryse C# 整合到您的 C# 專案中,根據您使用的是 .NET Framework 還是 .NET Core,以及您的開發環境偏好,您有幾個選擇。以下是根據 Apryse 文件和設置指南提供的一般步驟:

6.1 適用於 .NET 框架

  1. 下載適用於 Windows 的 Apryse SDK:您需要訪問 Apryse 網站 下載適用於 .NET Framework 應用程式的 SDK。

IronPDF 與 Apryse C# 的比較:圖 9 - 在 Apryse 網頁下載 Apryse SDK

  1. 提取 SDK:下載之後,將 SDK 提取到系統上的已知位置。

  2. 獲取 Apryse 試用金鑰:在 Apryse 平台註冊以獲得試用金鑰,您將使用它來激活 SDK 的試用功能。

  3. 設置您的項目:在 Visual Studio 中創建一個新的 .NET Framework 控制台應用程序。然後,將提取的 SDK 中的 Lib 文件夾添加到您的項目目錄中。

  4. 添加引用:右鍵點擊項目中的引用,選擇「添加引用」,並導航到您已複製 PDFNetLoader.dll 和適用於您架構的 PDFNet.dllLib 文件夾。 (x86 或 x64)請確保將 PDFNet.dll 的「本地複製」屬性設置為否。

配置 App.config:確保您的 App.config 文件中的 loadFromRemoteSources 設置為已啟動(true)。

在 SDK 中有範例文件夾。您可以直接打開並運行這些範例解決方案。

7 個 IronPDF 進階功能

7.1 將 HTML 轉換為 PDF

IronPDF 擅長將 HTML 轉換為 PDF 文件。此功能對於需要生成報告、發票或將網頁快照生成 PDF 文件的 Web 應用程式而言至關重要。該函式庫可以準確地渲染 HTML、CSS 和 JavaScript,並在生成的 PDF 中捕捉網頁內容的佈局和樣式。

7.1.1 HTML 字串轉換為 PDF

將 HTML 字串直接轉換為 PDF 可讓您從應用程式中生成的 HTML 內容或存儲在變數中的 HTML 內容動態生成 PDF。這對於根據使用者輸入或應用程式數據生成自訂報告、收據或文件特別有用。

using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
IronPdf.License.LicenseKey = "License-Key goes here";
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a different HTML string
string htmlContent = @"
<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>My PDF</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        p {
            color: #666;
            text-align: justify;
        }
    </style>
</head>
<body>
    <h1>Welcome to My PDF</h1>
    <p>This is a sample paragraph demonstrating how to create a PDF from HTML using IronPdf in C#.</p>
    <p>You can add more content here as needed.</p>
</body>
</html>";
// Create a PDF from the HTML string using C#
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Export to a file or Stream
pdf.SaveAs("output.pdf");
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
IronPdf.License.LicenseKey = "License-Key goes here";
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a different HTML string
string htmlContent = @"
<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>My PDF</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        p {
            color: #666;
            text-align: justify;
        }
    </style>
</head>
<body>
    <h1>Welcome to My PDF</h1>
    <p>This is a sample paragraph demonstrating how to create a PDF from HTML using IronPdf in C#.</p>
    <p>You can add more content here as needed.</p>
</body>
</html>";
// Create a PDF from the HTML string using C#
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Export to a file or Stream
pdf.SaveAs("output.pdf");
Imports IronPdf
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
IronPdf.License.LicenseKey = "License-Key goes here"
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a different HTML string
Dim htmlContent As String = "
<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>My PDF</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        p {
            color: #666;
            text-align: justify;
        }
    </style>
</head>
<body>
    <h1>Welcome to My PDF</h1>
    <p>This is a sample paragraph demonstrating how to create a PDF from HTML using IronPdf in C#.</p>
    <p>You can add more content here as needed.</p>
</body>
</html>"
' Create a PDF from the HTML string using C#
Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
' Export to a file or Stream
pdf.SaveAs("output.pdf")
VB   C#

IronPDF與Apryse C#之間的比較:圖 10 - 由HTML字串輸出的PDF

7.1.2 HTML 文件轉 PDF

當您將 HTML 文件存儲在磁盤上時,IronPDF 可以將此文件轉換為 PDF 文件。此方法非常適合將現有的 HTML 文檔、模板或報告轉換為 PDF 文件,這些文件可以存儲在您的項目或服務器上。

using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from the HTML string using C#
var pdf = renderer.RenderHtmlFileAsPdf("invoice.html");
// Export to a file or Stream
pdf.SaveAs("file.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from the HTML string using C#
var pdf = renderer.RenderHtmlFileAsPdf("invoice.html");
// Export to a file or Stream
pdf.SaveAs("file.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "License-Key goes here"
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from the HTML string using C#
Dim pdf = renderer.RenderHtmlFileAsPdf("invoice.html")
' Export to a file or Stream
pdf.SaveAs("file.pdf")
VB   C#

比較 IronPDF 和 Apryse C#:圖11 - 從 HTML 文件生成的 PDF 文件

7.1.3 URL 轉成 PDF

IronPDF 可以通過提供 URL 將一個實時網頁轉換成 PDF 文件。這個功能對於捕捉網頁的當前狀態非常有用,包括複雜的佈局、CSS 和 JavaScript 生成的內容。

using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from the HTML string using C#
var pdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework");
// Export to a file or Stream
pdf.SaveAs("url.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from the HTML string using C#
var pdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework");
// Export to a file or Stream
pdf.SaveAs("url.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "License-Key goes here"
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from the HTML string using C#
Dim pdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework")
' Export to a file or Stream
pdf.SaveAs("url.pdf")
VB   C#

IronPDF與Apryse C# 比較:圖12 - 從URL輸出的PDF

7.2 PDF 合併和拆分

借助 IronPDF,將多個 PDF 文檔合併成一個文件或將一個 PDF 拆分成幾個較小的文檔非常簡單。此功能對於需要組織和結構 PDF 內容的文檔管理系統至關重要。

using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
var html_a = @"
    <h1>PDF A</h1>
    <p>This is the content of PDF A.</p>
    <p>This is the first page of PDF A.</p>
    <div style='page-break-after: always;'></div>
    <p>This is the second page of PDF A.</p>";
var html_b = @"
    <h1>PDF B</h1>
    <p>This is the content of PDF B.</p>
    <p>This is the first page of PDF B.</p>
    <div style='page-break-after: always;'></div>
    <p>This is the second page of PDF B.</p>";
var renderer = new ChromePdfRenderer();
var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
var html_a = @"
    <h1>PDF A</h1>
    <p>This is the content of PDF A.</p>
    <p>This is the first page of PDF A.</p>
    <div style='page-break-after: always;'></div>
    <p>This is the second page of PDF A.</p>";
var html_b = @"
    <h1>PDF B</h1>
    <p>This is the content of PDF B.</p>
    <p>This is the first page of PDF B.</p>
    <div style='page-break-after: always;'></div>
    <p>This is the second page of PDF B.</p>";
var renderer = new ChromePdfRenderer();
var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "License-Key goes here"
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
Dim html_a = "
    <h1>PDF A</h1>
    <p>This is the content of PDF A.</p>
    <p>This is the first page of PDF A.</p>
    <div style='page-break-after: always;'></div>
    <p>This is the second page of PDF A.</p>"
Dim html_b = "
    <h1>PDF B</h1>
    <p>This is the content of PDF B.</p>
    <p>This is the first page of PDF B.</p>
    <div style='page-break-after: always;'></div>
    <p>This is the second page of PDF B.</p>"
Dim renderer = New ChromePdfRenderer()
Dim pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)
Dim pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)
Dim merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b)
merged.SaveAs("Merged.pdf")
VB   C#

7.3 添加水印

IronPDF 允許您向 PDF 頁面添加水印,這在品牌推廣或將文件標記為機密時非常有用。此功能支持文字和圖像水印,提供靈活的方式來應用和顯示水印。

using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs("Watermarked.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs("Watermarked.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "License-Key goes here"
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Stamps a Watermark onto a new or existing PDF
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
pdf.SaveAs("Watermarked.pdf")
VB   C#

IronPDF 與 Apryse C# 之間的比較:圖 13 - 輸出的 PDF 帶有「SAMPLE」浮水印

7.4 PDF Forms

IronPDF 支援操作互動式 PDF 表單。它可以程式化地創建、填寫和提交 PDF 表單。這對需要自動化表單處理或將表單數據收集整合到工作流程中的應用程式特別有用。

using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
const string differentFormHtml = @"
    <html>
        <body>
            <h2>Employee Information Form</h2>
            <form>
                First name: <br> 
                Last name: <br> 
                <br>
                <p>Please select your department:</p>
                <select name='department'>
                    <option value='HR'>HR</option>
                    <option value='Finance'>Finance</option>
                    <option value='IT'>IT</option>
                    <option value='Marketing'>Marketing</option>
                </select>
                <br>
                <br>
                <p>Please select your employment status:</p>
                <label for='fulltime'>Full-time</label> <br>
                <label for='parttime'>Part-time</label> <br>
                <br>
                <p>Please select your skills:</p>
                <label for='skill1'> Programming</label><br>
                <label for='skill2'> Design</label><br>
                <label for='skill3'> Marketing</label><br>
            </form>
        </body>
    </html>";
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
renderer.RenderHtmlAsPdf(differentFormHtml).SaveAs("EmployeeInfoForm.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
const string differentFormHtml = @"
    <html>
        <body>
            <h2>Employee Information Form</h2>
            <form>
                First name: <br> 
                Last name: <br> 
                <br>
                <p>Please select your department:</p>
                <select name='department'>
                    <option value='HR'>HR</option>
                    <option value='Finance'>Finance</option>
                    <option value='IT'>IT</option>
                    <option value='Marketing'>Marketing</option>
                </select>
                <br>
                <br>
                <p>Please select your employment status:</p>
                <label for='fulltime'>Full-time</label> <br>
                <label for='parttime'>Part-time</label> <br>
                <br>
                <p>Please select your skills:</p>
                <label for='skill1'> Programming</label><br>
                <label for='skill2'> Design</label><br>
                <label for='skill3'> Marketing</label><br>
            </form>
        </body>
    </html>";
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
renderer.RenderHtmlAsPdf(differentFormHtml).SaveAs("EmployeeInfoForm.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "License-Key goes here"
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
Const differentFormHtml As String = "
    <html>
        <body>
            <h2>Employee Information Form</h2>
            <form>
                First name: <br> 
                Last name: <br> 
                <br>
                <p>Please select your department:</p>
                <select name='department'>
                    <option value='HR'>HR</option>
                    <option value='Finance'>Finance</option>
                    <option value='IT'>IT</option>
                    <option value='Marketing'>Marketing</option>
                </select>
                <br>
                <br>
                <p>Please select your employment status:</p>
                <label for='fulltime'>Full-time</label> <br>
                <label for='parttime'>Part-time</label> <br>
                <br>
                <p>Please select your skills:</p>
                <label for='skill1'> Programming</label><br>
                <label for='skill2'> Design</label><br>
                <label for='skill3'> Marketing</label><br>
            </form>
        </body>
    </html>"
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
renderer.RenderingOptions.CreatePdfFormsFromHtml = True
renderer.RenderHtmlAsPdf(differentFormHtml).SaveAs("EmployeeInfoForm.pdf")
VB   C#

IronPDF 與 Apryse C# 的比較:圖14 - 輸出帶有互動表單的 PDF

7.5 安全和加密

IronPDF 提供了多種安全 PDF 文件的功能,包括加密 PDF 文件、設置權限和添加數字簽名。這確保了 PDF 文件中的敏感信息得到保護,並且文件的完整性得到維護。

using IronPdf;
IronPdf.License.LicenseKey = "License-Key" goes here;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
var pdf = PdfDocument.FromFile("invoice.pdf");
// Change or set the document encryption password
pdf.SecuritySettings.OwnerPassword = "top-secret"; // password to edit the pdf
pdf.SecuritySettings.UserPassword = "sharable"; // password to open the pdf
pdf.SaveAs("secured.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "License-Key" goes here;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
var pdf = PdfDocument.FromFile("invoice.pdf");
// Change or set the document encryption password
pdf.SecuritySettings.OwnerPassword = "top-secret"; // password to edit the pdf
pdf.SecuritySettings.UserPassword = "sharable"; // password to open the pdf
pdf.SaveAs("secured.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "License-Key" goes here
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
Dim pdf = PdfDocument.FromFile("invoice.pdf")
' Change or set the document encryption password
pdf.SecuritySettings.OwnerPassword = "top-secret" ' password to edit the pdf
pdf.SecuritySettings.UserPassword = "sharable" ' password to open the pdf
pdf.SaveAs("secured.pdf")
VB   C#

IronPDF 與 Apryse C# 的比較:圖15 - 受密碼保護的 PDF 彈出窗口

7.6 高级PDF编辑

IronPDF 不仅提供基本的 PDF 编辑功能,还提供高级编辑功能。这包括添加页眉和页脚、自定义页面布局和设计,以及嵌入图像和字体。这些功能允许根据特定的应用需求进行动态 PDF 生成和自定义。

using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new IronPdf.ChromePdfRenderer();
var multi_page_html = @"
    <p> This is 1st Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 2nd Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 3rd Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 4th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 5th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 6th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 7th Page</p>";
// Create a PDF or Load an existing PDF using IronPdf.PdfDocument.Load()
var pdfdoc = renderer.RenderHtmlAsPdf(multi_page_html);
// Create a Header for the first page only
var firstPageHeader = new HtmlHeaderFooter();
firstPageHeader.HtmlFragment = "This is the First Page Header";
pdfdoc.AddHtmlHeaders(firstPageHeader, 1);
pdfdoc.SaveAs("PagesWithHeaders.pdf");
using IronPdf;
IronPdf.License.LicenseKey = "License-Key goes here";
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new IronPdf.ChromePdfRenderer();
var multi_page_html = @"
    <p> This is 1st Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 2nd Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 3rd Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 4th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 5th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 6th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 7th Page</p>";
// Create a PDF or Load an existing PDF using IronPdf.PdfDocument.Load()
var pdfdoc = renderer.RenderHtmlAsPdf(multi_page_html);
// Create a Header for the first page only
var firstPageHeader = new HtmlHeaderFooter();
firstPageHeader.HtmlFragment = "This is the First Page Header";
pdfdoc.AddHtmlHeaders(firstPageHeader, 1);
pdfdoc.SaveAs("PagesWithHeaders.pdf");
Imports IronPdf
IronPdf.License.LicenseKey = "License-Key goes here"
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New IronPdf.ChromePdfRenderer()
Dim multi_page_html = "
    <p> This is 1st Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 2nd Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 3rd Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 4th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 5th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 6th Page</p>
    <div style = 'page-break-after: always;' ></div>
    <p> This is 7th Page</p>"
' Create a PDF or Load an existing PDF using IronPdf.PdfDocument.Load()
Dim pdfdoc = renderer.RenderHtmlAsPdf(multi_page_html)
' Create a Header for the first page only
Dim firstPageHeader = New HtmlHeaderFooter()
firstPageHeader.HtmlFragment = "This is the First Page Header"
pdfdoc.AddHtmlHeaders(firstPageHeader, 1)
pdfdoc.SaveAs("PagesWithHeaders.pdf")
VB   C#

IronPDF與Apryse C#的比較:圖16 - 輸出的多頁 PDF

8 Apryse C# 高級功能

8.1 PDF註解和標註

Apryse C#使開發人員能夠以程式化的方式向PDF文件添加註解和標註。這包括文字註解、高亮、下劃線和形狀,這些對於文件審查過程或向PDF添加補充信息都是必不可少的。

using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize("License");
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            Page page = doc.GetPage(1);
           Text txt = Text.Create(doc, new Rect(10, 20, 30, 40));
        txt.SetIcon("UserIcon");
        txt.SetContents("It's an annotation!"); 
        page.AnnotPushBack(txt);
            page.AnnotPushBack(annot);
            doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
        }
    }
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize("License");
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            Page page = doc.GetPage(1);
           Text txt = Text.Create(doc, new Rect(10, 20, 30, 40));
        txt.SetIcon("UserIcon");
        txt.SetContents("It's an annotation!"); 
        page.AnnotPushBack(txt);
            page.AnnotPushBack(annot);
            doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
        }
    }
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF
Friend Class Program
	Shared Sub Main()
		PDFNet.Initialize("License")
		Using doc As New PDFDoc("input.pdf")
			Dim page As Page = doc.GetPage(1)
		   Dim txt As Text = Text.Create(doc, New Rect(10, 20, 30, 40))
		txt.SetIcon("UserIcon")
		txt.SetContents("It's an annotation!")
		page.AnnotPushBack(txt)
			page.AnnotPushBack(annot)
			doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
		End Using
	End Sub
End Class
VB   C#

IronPDF 和 Apryse C# 的比較:圖 17 - 帶有圖標和註解的輸出 PDF

8.2 文件轉換

使用Apryse C#,開發者可以將各種文件格式轉換為PDF,包括Office文件、圖像和HTML。這個功能對於需要統一文件格式進行存檔、共享或顯示的應用程式至關重要。

using pdftron;
using pdftron.PDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        PDFDoc pdfdoc = new PDFDoc();
        Convert.ToPdf(pdfdoc, "input.docx");
        pdfdoc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
    }
}
using pdftron;
using pdftron.PDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        PDFDoc pdfdoc = new PDFDoc();
        Convert.ToPdf(pdfdoc, "input.docx");
        pdfdoc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
    }
}
Imports pdftron
Imports pdftron.PDF
Friend Class Program
	Shared Sub Main()
		PDFNet.Initialize()
		Dim pdfdoc As New PDFDoc()
		Convert.ToPdf(pdfdoc, "input.docx")
		pdfdoc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
	End Sub
End Class
VB   C#

8.3 內容提取與分析

Apryse C# 擅長從 PDF 文件中提取文本、圖像和其他內容。此功能對於內容分析、數據提取和資訊檢索應用程式至關重要,使得能夠針對各種目的處理 PDF 內容。

using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            PageIterator itr = doc.GetPageIterator();
            for (; itr.HasNext(); itr.Next())
            {
                Page page = itr.Current();
                TextExtractor txt = new TextExtractor();
                txt.Begin(page);
                Console.WriteLine(txt.GetAsText());
            }
        }
    }
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            PageIterator itr = doc.GetPageIterator();
            for (; itr.HasNext(); itr.Next())
            {
                Page page = itr.Current();
                TextExtractor txt = new TextExtractor();
                txt.Begin(page);
                Console.WriteLine(txt.GetAsText());
            }
        }
    }
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF
Friend Class Program
	Shared Sub Main()
		PDFNet.Initialize()
		Using doc As New PDFDoc("input.pdf")
			Dim itr As PageIterator = doc.GetPageIterator()
			Do While itr.HasNext()
				Dim page As Page = itr.Current()
				Dim txt As New TextExtractor()
				txt.Begin(page)
				Console.WriteLine(txt.GetAsText())
				itr.Next()
			Loop
		End Using
	End Sub
End Class
VB   C#

IronPDF與Apryse C# 的比較:圖18 - 從PDF中提取的文字的控制台輸出

8.4 安全和加密

Apryse C# 提供了全面的工具來保護 PDF 文件的安全。開發人員可以應用密碼保護、加密文件和管理用戶權限,以確保敏感信息得到保護。

using pdftron;
using pdftron.SDF;
using pdftron.PDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            doc.InitSecurityHandler();
            SecurityHandler newHandler = new SecurityHandler();
            newHandler.ChangeUserPassword("new_password");
            newHandler.SetPermission(SecurityHandler.Permission.e_print, true);
            doc.SetSecurityHandler(newHandler);
            doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
        }
    }
}
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            doc.InitSecurityHandler();
            SecurityHandler newHandler = new SecurityHandler();
            newHandler.ChangeUserPassword("new_password");
            newHandler.SetPermission(SecurityHandler.Permission.e_print, true);
            doc.SetSecurityHandler(newHandler);
            doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
        }
    }
}
Imports pdftron
Imports pdftron.SDF
Imports pdftron.PDF
Friend Class Program
	Shared Sub Main()
		PDFNet.Initialize()
		Using doc As New PDFDoc("input.pdf")
			doc.InitSecurityHandler()
			Dim newHandler As New SecurityHandler()
			newHandler.ChangeUserPassword("new_password")
			newHandler.SetPermission(SecurityHandler.Permission.e_print, True)
			doc.SetSecurityHandler(newHandler)
			doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
		End Using
	End Sub
End Class
VB   C#

8.5 涂銷

Apryse C# 也支援從 PDF 文件中涂銷敏感信息,這是一個對於合規和隱私問題至關重要的功能。這允許開發人員永久移除或遮蔽 PDF 中的文本和圖像。

using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            Redactor.Redaction [] redactions = {
                new Redactor.Redaction(1, new Rect(100, 100, 200, 200), false, "redacted"),
            };
            Redactor.Redact(doc, redactions);
            doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
        }
    }
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
    static void Main()
    {
        PDFNet.Initialize();
        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            Redactor.Redaction [] redactions = {
                new Redactor.Redaction(1, new Rect(100, 100, 200, 200), false, "redacted"),
            };
            Redactor.Redact(doc, redactions);
            doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
        }
    }
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF
Friend Class Program
	Shared Sub Main()
		PDFNet.Initialize()
		Using doc As New PDFDoc("input.pdf")
			Dim redactions() As Redactor.Redaction = { New Redactor.Redaction(1, New Rect(100, 100, 200, 200), False, "redacted")}
			Redactor.Redact(doc, redactions)
			doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
		End Using
	End Sub
End Class
VB   C#

9. 文件和支援

9.1 IronPDF 文件和支援

文件: IronPDF 提供了全面的文件,涵盖範圍廣泛的主題,從入門指南到進階功能,如 HTML 轉換為 PDF、PDF 編輯、合併、拆分和安全性。這些文件設計簡明易懂,並提供大量的程式碼範例和說明,引導開發人員在其 .NET 應用程式中實現各種 PDF 相關功能。

支援: 對於需要幫助的開發人員,IronPDF 提供了多種渠道的支援服務。這包括電子郵件支援、工單支援和實時工程支援聊天室,您可以與他們的技術支援團隊聯絡,獲得特定問題的幫助。您也可以通過支援系統提供反饋。

IronPDF與Apryse C#的比較:圖19 - Iron Software支援團隊聊天

9.2 Apryse C# 文件和支持

文件: Apryse C# (前身為 PDFTron for .NET) 擁有詳盡的文件,包括全面的 API 參考、開發者指南以及涵蓋廣泛 PDF 操作任務的示例代碼。

支持: Apryse 為開發者提供了一個支持系統,提供與其技術團隊的直接電子郵件支持,用於故障排除和實施問題的協助。您還可以在 Stack Overflow 上提問。

10. 授權資訊

10.1 IronPDF 許可證

IronPDF 提供多種針對不同項目需求而設計的許可證選擇,包括 Lite、Plus 和 Professional 許可證,起價 $749 的 Lite 許可證。這些許可證根據涵蓋的開發者數量、地點和項目而有所不同。此外,IronPDF 還提供免版稅再分發選項以及延長支持和更新的選項,這些附加功能的具體費用另計。

IronPDF 為開發者提供一系列永久許可證選項:

  • Lite 版:費用為 $749,適用於 1 名開發者、1 個地點和 1 個項目,包括電子郵件支持。
  • Plus 版:價格為 $1,499,涵蓋最多 3 名開發者、3 個地點和 3 個項目,提供 24 小時電子郵件和聊天支持,以及電話支持。
  • Professional 版:價格為 $2,999,適用於最多 10 名開發者、10 個地點和 10 個項目,提供全面支持,包括電子郵件、聊天、電話和屏幕共享支持。

他們還提供每月 $500 的訂閱服務,包括 10,000 個 API 調用,每多調用一次收取 $0.02。如需無限制使用,IronPDF 提供企業解決方案,需要報價。此解決方案包括無限永久許可證和無限 API 調用,以及其他功能。

IronPDF 和 Apryse C# 的比較:圖 20 - IronPDF 授權網頁

10.2 Apryse C# 授權

Apryse C# 提供可自訂的定價模式,根據具體的專案需求,包括功能、文件量和部署情境進行調整。您需要聯絡他們的銷售團隊以獲取詳細資訊。 價格信息.

IronPDF與Apryse C#之間的比較:圖21 - Apryse表單,與他們的銷售團隊聯繫

11 結論

總而言之,IronPDF 和 Apryse C# 各自為處理 PDF 的 .NET 開發者帶來了強大的功能。然而,IronPDF 憑藉其廣泛的 PDF 操作功能提供了優勢。它在處理全面任務,例如廣泛的編輯方面表現出色。 合併 PDF 這增加了它的吸引力。通過 Iron Suite 套件,開發人員可以以具成本效益的價格獲得一套工具,使其能夠使用強大的實用工具集來應對各種開發需求。

IronPDF 因其在大多數 PDF 處理情況下的全面多功能性和價值主張而脫穎而出。最終的決定理想上應基於項目需求和開發人員所需的特定功能。

< 上一頁
IronPDF 與 PDFSharpCore 的比較
下一個 >
IronPDF與PdfPig的比較

準備開始了嗎? 版本: 2024.10 剛剛發布

免費 NuGet 下載 總下載次數: 10,993,239 查看許可證 >