产品比较

IronPDF 与 Apryse C# 的比较

发布 2024年三月6日
分享:

1.导言

作为 C# 开发人员,处理 PDF 是我们工作中常见的一部分,尤其是在构建需要生成、编辑或显示文档的应用程序时。 因此,拥有一个良好的 PDF 库至关重要。 这些库为转换文档、编辑文本和处理 PDF 中的图像等复杂任务提供了内置功能,从而节省了我们的时间和麻烦。 如果没有它们,我们就必须从头开始编写所有代码,这不仅耗时,而且容易出错。

在这次比较中,我们将看到两个流行的 PDF 库: IronPDFC#. IronPDF for .NET 以其强大的功能而著称,从将 HTML 转换为 PDF 到高级文档编辑,它都能让您在 .NET 环境中轻松处理 PDF。 Apryse C# 则提供了一种简化的 PDF 操作方法,注重易用性和效率。 我们将深入探讨每个库提供的具体功能,帮助您决定哪个库最适合您的项目。

2.Apryse C#

IronPDF 与 Apryse C# 的比较:图 1 - Apryse C# 网页

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 库,它脱颖而出。 它简化了复杂的 PDF 操作过程,允许直接在 C# 应用程序中创建、编辑和转换 PDF 文档。 IronPDF for Python 可使用 Java、Python 和 C# 等不同编程语言。 IronPDF 专为满足广泛的 PDF 处理需求而设计,是追求效率和可靠性的开发人员的首选解决方案。

3.1 主要功能

  • Seamless .NET Integration: 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 选择项目类型

在 "创建新项目 "窗口中,你会看到各种项目模板。 在搜索框中键入 "控制台",或从列表中找到 "控制台应用程序 "模板。确保选择 C# 专用模板,而不是其他语言。

IronPDF 与 Apryse C#:图 4 - 选择控制台应用程序模板

4.4 配置项目

选择 "控制台应用程序 "模板后,点击 "下一步 "按钮。 系统会提示你配置新项目:

  • 项目名称: 输入项目名称。
  • 位置: 选择要在电脑上保存项目的位置。

    • 解决方案名称: 默认情况下,该名称与项目名称一致,但您也可以随意更改。

    IronPDF 与 Apryse C#:图 5 - 配置项目细节

    • 框架: 选择您希望使用的 .NET 版本。 就大多数用途而言,除非您有特殊要求,否则建议使用最新版本。

    IronPDF 与 Apryse C#.NET 的比较图 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"。

    1. 在搜索结果中找到 IronPDF,选择它,然后点击 "安装"。Visual Studio 会处理剩下的工作,将 IronPDF 添加到你的项目中。

    IronPDF 与 Apryse C#:图 7 - 通过 NuGet 软件包管理器安装 IronPDF

5.2 使用 Visual Studio 命令行

对于喜欢使用命令行的用户,Visual Studio 中的软件包管理器控制台提供了一种直接安装软件包的方法。

  1. 打开 Visual Studio,进入项目。
  2. 导航至工具 > NuGet 包管理器 > 包管理器控制台.
    1. 在控制台中键入以下命令并按 Enter:
Install-Package IronPdf

该命令将下载最新版本的 IronPDF 并安装到项目中。

5.3 从 NuGet 网页直接下载

如果希望在将软件包集成到项目之前手动下载,可以从 NuGet 网站下载。

  1. 访问 **NuGet 网站*** 并搜索 "IronPDF"。

    1. 铁页找到 "下载软件包 "链接并点击,下载 .nupkg 文件。

    IronPDF 与 Apryse C#:图 8 - 通过 NuGet 网页直接安装 IronPDF

  2. 下载完成后,您可以手动将软件包添加到项目中。 在 Visual Studio 中,导航到 "解决方案资源管理器",右键单击项目,然后选择 "添加 > 引用"。导航到下载的 .nupkg 文件位置,选择该文件并将其添加到项目中。

    上述每种方法都能成功地将 IronPDF 集成到您的 .NET 项目中,让您开始使用其强大的 PDF 处理功能。

6.安装 Apryse C#

要将 Apryse C# 集成到 C# 项目中,您有几种选择,具体取决于您使用的是 .NET Framework 还是 .NET Core,以及您的开发环境偏好。 以下是根据 Apryse 文档和设置指南中的信息总结出的一般步骤:

6.1 适用于 .NET Framework

  1. 下载适用于 Windows 的 Apryse SDK:您需要访问 安普利斯网站 下载适合 .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. 添加引用:右键单击项目中的 "引用",选择 "添加引用",然后导航到Lib文件夹,在该文件夹中复制了PDFNetLoader.dll和适合你的架构的PDFNet.dll。 (x86 或 x64). 确保将 PDFNet.dll 的 "复制本地 "属性设置为 false。
  5. 配置 App.config:确保您的 App.config 文件已将 loadFromRemoteSources 设置为 true。

    SDK 中有示例文件夹。 您可以直接打开并运行这些示例解决方案。

7 IronPDF 高级功能

7.1 HTML 转换为 PDF

IronPDF 擅长将 HTML 转换为 PDF 文档。 对于需要将报告、发票或网页快照生成 PDF 文件的网络应用程序来说,这一功能至关重要。 该库可准确渲染 HTML、CSS 和 JavaScript,在生成的 PDF 中捕捉网页内容的布局和样式。

7.1.1 HTML 字符串转 PDF

将 HTML 字符串直接转换为 PDF,可从应用程序中生成或存储在变量中的 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 文档、模板或报告。

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 - 带有 'SAMPLE' 水印的输出 PDF

7.4 份 PDF 表格

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&num;高级功能

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&num;文档和支持

文档: Apryse C# (前称 PDFTron for .NET) 拥有详细的文档,其中包括全面的 API 参考、开发人员指南和用于各种 PDF 操作任务的示例代码。

支持: Apryse 为开发人员提供支持系统,其技术团队可通过电子邮件提供直接支持,帮助开发人员排除故障和解决实施问题。 您还可以在 stack overflow 上提问。

10.许可证信息

10.1 个 IronPDF 许可

IronPDF 针对不同的项目需求提供多种许可选项,包括精简版许可、增强版许可和专业版许可,其中精简版许可的起价为 $749。 这些许可证根据开发人员、地点和项目的数量而有所不同。 此外,IronPDF 还提供免版税再分发、扩展支持和更新选项,这些附加功能的具体费用由用户自行决定。

IronPDF 为开发人员提供一系列永久许可证选项:

  • Lite Edition:费用为 $749,适用于 1 名开发人员、1 个地点和 1 个项目,包括电子邮件支持。
  • 加强版:价格为 1,499 美元,最多可覆盖 3 个开发人员、3 个地点和 3 个项目,提供 24 小时电子邮件和聊天支持以及电话支持。
  • 专业版:该版本售价 2999 美元,最多可支持 10 名开发人员、10 个地点和 10 个项目,提供包括电子邮件、聊天、电话和屏幕共享支持在内的全面支持。

    他们还提供每月 500 美元的包月套餐,包括 10,000 次 API 调用,每次额外调用费用为 0.02 美元。 对于无限制使用,IronPDF 提供企业解决方案,并要求报价。 该解决方案包括无限版永久许可和无限次 API 调用等功能。

    IronPDF 与 Apryse C# 的比较:图 20 - IronPDF 许可网页

10.2 Apryse C&num;许可证

Apryse C# 提供可定制的定价模式,可根据具体项目要求(包括功能、文档量和部署方案)进行调整。 您必须联系他们的销售团队,才能获得 定价信息.

IronPDF 与 Apryse C#:图 21 - 与销售团队联系的 Apryse 表单

11 结论

总之,IronPDF 和 Apryse C# 都为处理 PDF 的 .NET 开发人员带来了强大的功能。 然而,IronPDF 凭借其丰富的 PDF 操作功能而独占鳌头。 它的亮点在于能够处理大量编辑等综合任务、 merging PDFs 这增加了它的吸引力。 有了 Iron Suite 软件包,开发人员就能以具有成本效益的价格获得一整套工具,为满足各种开发需求配备一套强大的实用程序。

IronPDF 因其在大多数 PDF 处理方案中的整体多功能性和价值主张而脱颖而出。 最终的决定最好基于项目要求和开发人员所需的具体功能。

< 前一页
IronPDF 与 PDFSharpCore 的比较
下一步 >
IronPDF与PdfPig的比较

准备开始了吗? 版本: 2024.9 刚刚发布

免费NuGet下载 总下载量: 10,731,156 查看许可证 >