
SpirePDF C# HTML到PDF教程及库对比
将HTML转换为PDF是许多.NET应用程序的关键需求,从生成发票和报告到创建文档和电子书。 在选择IronPDF和Spire.PDF进行HTML到PDF转换时,理解它们的优点、限制和实际性能变得至关重要。 这篇全面的比较分析了两个库的能力,帮助您为您的PDF生成需求做出明智的决策。
IronPDF和Spire.PDF在HTML到PDF转换中的关键区别是什么?
IronPDF是一个多功能的.NET PDF库,旨在处理广泛的PDF相关任务,包括转换PDF文件、PDF编辑、PDF创建、读取PDF文件等。 它以易于集成到现有.NET应用程序、高性能以及支持现代Web标准如HTML5、CSS3和JavaScript而闻名。 IronPDF的Chrome基础渲染引擎确保从HTML内容生成像素完美的PDF。
Spire.PDF for .NET是另一个强大的.NET PDF库,提供了全面的PDF创建和操作功能集。 它支持各种PDF功能,如文本和图像提取、PDF表单填充和数字签名。 虽然功能全面,但其HTML到PDF转换功能有特定的限制,开发人员应予以考虑。
| 翻译类别 | 特点/方面 | IronPDF | Spire.PDF | 主要优势 |
|---|---|---|---|---|
| 核心架构 | 设计理念 | 简单至上、直观的 API | 多类方法,手动设置 | IronPDF:更快的开发 |
| API 复杂性 | 像 RenderHtmlAsPdf() 这样的简单方法 | 需要多线程方法 | IronPDF:更简单的 API | |
| 学习曲线 | 低的 | 中等到高 | IronPDF:更快采用 | |
| 平台支持 | 跨平台 | 本地支持,无需额外软件包 | 有限的 Linux/macOS 支持 | IronPDF:真正的跨平台 |
| .NET版本 | .NET 8、7、6、5、Core 3.1+、Framework 4.6.2+。 | .NET Core 2.0+,Framework 2.0+ | 两者:广泛的框架支持 | |
| 操作系统 | Windows、Linux、macOS、Docker 本机 | 主要侧重于 Windows | IronPDF:更广泛的操作系统支持 | |
| HTML 转 PDF | 渲染引擎 | 完整的 Chrome V8 引擎 | 自定义 HTML 解析器 | IronPDF:高浏览器一致性 |
| 支持 CSS3/HTML5 | 全面支持 | 有限(仅限基本 CSS) | IronPDF:现代网络标准 | |
| JavaScript 执行 | 完全支持 JavaScript | 对 JavaScript 的支持有限 | IronPDF:动态内容就绪 | |
| 网络字体 | 谷歌字体、系统字体 | 有限的字体支持 | IronPDF:排版灵活性 | |
| 渲染速度 | 由于Chrome的开销,简单HTML略慢 | 简单/静态HTML更快 | Spire: 基本HTML的开销更低 | |
| Security & Encryption | 加密级别 | AES-256、自定义处理程序 | AES-256 标准 | 两者:行业标准 |
| 简化应用程序接口 | 单个 SecuritySettings 类 | 多种安全方法 | IronPDF:统一方法 | |
| 内容处理 | 重action 方法 | 真正的内容删除,单行 API | 手动矩形叠加 | IronPDF:合规就绪 |
| 水印 | 基于 HTML/CSS,完全样式化 | 基于文本的轮换翻译 | IronPDF:丰富的水印 | |
| 文件转换 | DOCX 转换为 PDF | 内置 DocxToPdfRenderer | 需要 Spire.Doc 库 | IronPDF:无额外费用 |
| 性能指标 | 内存使用 | 更高(Chrome引擎的开销) | 更低(更简单的渲染引擎) | Spire:降低内存占用 |
| 线程支持 | 本地Async/Await优化 | 需要 STA 线程 | IronPDF:现代异步模式 | |
| 开发人员经验 | 代码示例 | 100 多个可直接运行的示例 | 基本示例 | IronPDF:丰富的资源 |
| 错误信息 | 描述性、可操作性 | 技术信息 | IronPDF:更好的调试 | |
| Licensing & Pricing | 入门级 | Lite:$999 (1 个开发人员,1 个项目) | 开发者: $999/年 (1 位开发者) | IronPDF:永久许可证 |
| Team License | Plus:$1,499 (3 个开发人员,3 个项目) | 站点Enterprise:$4,599/年 | IronPDF:更好的团队价值 | |
| 套件选项 | Iron Suite:$2,998(10个产品) | 无套件选项 | IronPDF:卓越价值 | |
| 支持 | 支持包括 | 是,24/5 工程支持 | 仅限论坛(额外付费支持) | IronPDF:包括支持 |
| 支持渠道 | 电子邮件、聊天、电话、屏幕共享 | 论坛、电子邮件(付费层级) | IronPDF:更多渠道 | |
| 最适合 | 使用案例 | 现代网络应用程序、复杂的 HTML/CSS | 简单的文档,基本的布局 | 与上下文相关 |
注意。Spire.PDF 提供基本的 PDF 功能,内存使用率较低,而 IronPDF 则在 HTML 呈现和现代网络标准支持方面表现出色。请根据优先考虑复杂的 HTML 呈现还是最小的资源使用量进行选择。
有关IronPDF的详细信息,请访问ironpdf.com。
跨平台兼容性在两个库中如何比较?
IronPDF
IronPDF凭借其广泛的跨平台兼容性而脱颖而出。 它支持.NET框架内的多种环境,确保在不同平台之间的无缝操作。 以下是IronPDF平台兼容性的摘要:
-
.NET 版本:
-
完全集成且支持C#、VB.NET和F#
- .NET Core (8, 7, 6, 5, 和 3.1+)
- .NET Standard (2.0+)
- .NET Framework (4.6.2+)
-
应用程序环境: IronPDF 可在诸多应用程序环境中工作,如 Windows, Linux, Mac, Docker, Azure, 和 AWS。
-
IDE: 支持使用的IDE包括 Microsoft Visual Studio 和 JetBrains Rider & ReSharper
-
操作系统和处理器: 支持包括 Windows, Mac, Linux, x64, x86, ARM 在内的多种操作系统和处理器
有关IronPDF兼容性的更多细节,请访问IronPDF功能页面。
Spire.PDF
Spire.PDF在.NET环境中具有完整的支持,但虽然它在Windows操作系统内工作,但不具备IronPDF在Linux和macOS上的原生支持。 在macOS或Linux上部署时,Spire.PDF需要为每个平台使用不同的插件,这可能会使部署方案复杂化。
-
.NET支持:
- .NET Framework 2.0+
- .NET Core 2.0+
- 使用C#编写,支持VB.NET
-
**应用环境:**Spire.PDF适用于多个应用环境,如Windows和ASP.NET应用。 它还可以支持Windows Forms。
哪款库提供了更好的HTML到PDF转换功能?
IronPDF。 功能
- PDF转换: IronPDF可以将HTML转换为PDF。 \u51ed\u501f\u5bf9\u73b0\u4ee3 Web \u6807\u51c6\u7684\u5168\u9762\u652f\u6301\uff0c\u60a8\u53ef\u4ee5\u653e\u5fc3\uff0cIronPDF \u5c06\u59cb\u7ec8\u4ece\u60a8\u7684 HTML \u5185\u5bb9\u4e2d\u8fd4\u56de\u50cf\u7d20\u5b8c\u7f8e\u7684 PDF\u3002 IronPDF还可以将PDF文件从其他格式如DOCX,图像,RTF等转换。
- PDF 生成: 使用 IronPDF,您可以从URL、ASPX文件或HTML字符串生成PDF。
- **安全功能:**借助IronPDF,您可以始终确保任何敏感的PDF文件是安全的,这要归功于它的安全功能。 使用IronPDF加密您的PDF文件,设置密码,并为PDF文件设置权限。
- PDF 编辑功能: 使用 IronPDF,您可以处理现有的PDF文档,轻松地编辑它们并阅读PDF文件。 IronPDF提供编辑功能,例如添加页眉和页脚、在PDF页面上盖章文字和图像、向PDF添加自定义水印、与PDF表单合作,以及拆分或合并PDF文件。
- **集成:**无缝集成到ASP.NET和MVC应用程序中。
- **PDF版本支持:**支持PDF版本1.2-1.7
有关IronPDF功能的完整列表,请访问IronPDF功能。
Spire.PDF功能
- **PDF创建:**从头开始或从现有文件创建PDF。
- **文本和图像提取:**使用Spire.PDF提取PDF页面和内容。
- **PDF表单处理:**填写和管理PDF表单。
- **PDF转换:**将PDF转换为其他格式如HTML、RTF和图像。
- **页面操作:**插入、删除和重排序PDF中的页面。
- **有限的HTML支持:**HTML到PDF引擎对现代CSS和JavaScript的支持有限。 默认转换路径对CSS页面断裂属性和外部CSS文件识别有约束,JavaScript执行支持有限。 提供一个可选的ChromeHtmlConverter插件以改进渲染。
Bootstrap和现代CSS框架渲染
现代Web开发严重依赖于CSS框架,例如Bootstrap,用于快速的UI开发和响应式设计。 PDF生成库必须准确转换这些框架,以保持专业文档的质量和设计一致性。
IronPDF。:全面支持Bootstrap和Tailwind
IronPDF的Chromium引擎提供了对所有现代CSS框架的完整支持:
- **Bootstrap 5:**完全支持 Flexbox 和 CSS Grid,以及所有响应式组件
- **Bootstrap 4:**完整的卡片布局、导航系统和实用类
- **Tailwind CSS:**所有实用性优先的类和响应式修饰符
- **Foundation:**完整的网格和组件系统
- **现代 CSS3:**Flexbox、Grid、自定义属性、动画和变换
已通过真实示例验证:Bootstrap首页和Bootstrap模板以像素完美的精度转换。
代码示例:与Bootstrap的团队成员卡片
using IronPdf;
var renderer = new ChromePdfRenderer();
string bootstrapTeam = @"
<!DOCTYPE html>
<html>
<head>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
<div class='container my-5'>
<h1 class='text-center mb-5'>Our Team</h1>
<div class='row row-cols-1 row-cols-md-3 g-4'>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Jennifer Martinez</h5>
<p class='text-muted mb-3'>Chief Technology Officer</p>
<p class='card-text flex-grow-1'>Leading our technical vision and innovation strategy with over 15 years of experience in software architecture.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>David Chen</h5>
<p class='text-muted mb-3'>Head of Engineering</p>
<p class='card-text flex-grow-1'>Managing our engineering teams and ensuring product quality through rigorous testing and code review processes.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Sarah Johnson</h5>
<p class='text-muted mb-3'>Product Manager</p>
<p class='card-text flex-grow-1'>Driving product strategy and customer satisfaction through data-driven decisions and user research.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<h3>Join Our Team</h3>
<p class='text-muted mb-3'>We're always looking for talented individuals to join our growing team.</p>
<a href='#' class='btn btn-primary btn-lg'>View Open Positions</a>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(bootstrapTeam);
pdf.SaveAs("team-members.pdf");Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim bootstrapTeam As String = "
<!DOCTYPE html>
<html>
<head>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
<div class='container my-5'>
<h1 class='text-center mb-5'>Our Team</h1>
<div class='row row-cols-1 row-cols-md-3 g-4'>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Jennifer Martinez</h5>
<p class='text-muted mb-3'>Chief Technology Officer</p>
<p class='card-text flex-grow-1'>Leading our technical vision and innovation strategy with over 15 years of experience in software architecture.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>David Chen</h5>
<p class='text-muted mb-3'>Head of Engineering</p>
<p class='card-text flex-grow-1'>Managing our engineering teams and ensuring product quality through rigorous testing and code review processes.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
<div class='col'>
<div class='card h-100 shadow-sm text-center'>
<div class='card-body d-flex flex-column'>
<img src='https://via.placeholder.com/150' class='rounded-circle mx-auto mb-3' alt='Team member' style='width: 150px; height: 150px; object-fit: cover;'>
<h5 class='card-title'>Sarah Johnson</h5>
<p class='text-muted mb-3'>Product Manager</p>
<p class='card-text flex-grow-1'>Driving product strategy and customer satisfaction through data-driven decisions and user research.</p>
<div class='d-flex justify-content-center gap-2 mt-auto'>
<a href='#' class='btn btn-sm btn-outline-primary'>LinkedIn</a>
<a href='#' class='btn btn-sm btn-outline-secondary'>Email</a>
</div>
</div>
</div>
</div>
</div>
<div class='text-center mt-5'>
<h3>Join Our Team</h3>
<p class='text-muted mb-3'>We're always looking for talented individuals to join our growing team.</p>
<a href='#' class='btn btn-primary btn-lg'>View Open Positions</a>
</div>
</div>
</body>
</html>"
Dim pdf = renderer.RenderHtmlAsPdf(bootstrapTeam)
pdf.SaveAs("team-members.pdf")**输出:**一个专业的团队页面,采用 Bootstrap 的卡片网格、flexbox 对齐方式、响应式图像和按钮组件——所有内容都能在 PDF 中准确呈现。
Spire.PDF:有限的HTML和现代框架支持
Spire.PDF的HTML到PDF引擎在现代CSS框架上有显着的限制,如其自身文档中所述:
- **有限的CSS支持:**仅限基础CSS; 对全面的CSS3特性支持有限
- **有限的Flexbox支持:**Bootstrap 4/5大量依赖Flexbox,支持有限,影响布局准确性
- **有限的CSS Grid支持:**使用CSS Grid的现代布局系统可能无法正确渲染
- **JavaScript 的局限性:**与现代浏览器相比, JavaScript执行功能有限。
- **Bootstrap 3最可靠:**比Bootstrap 4/5更可靠的旧的基于表格的Bootstrap版本
- **复杂布局可能需要变通办法:**现代响应设计可能需要重大调整
开发人员报告的Spire.PDF HTML转换问题:
- Bootstrap导航栏渲染中存在布局问题
- 含flexbox的卡片组件未正确对齐
- 响应式网格断点在PDF输出中被忽略
- 现代CSS功能需要手动CSS重写或替代方案
**开发影响:**使用 Bootstrap 4+ 或现代 CSS 框架的应用程序在使用 Spire.PDF 时面临重大挑战。 开发团队必须:
- 保持专门用于PDF生成的简化CSS(双倍维护)
- 降级为Bootstrap 3或完全放弃框架(限制现代功能)
- 广泛测试并手动修复每个组件(耗时且易碎)
对于需要现代CSS框架支持的项目,Spire.PDF的HTML渲染限制使其在没有重大额外开发工作和持续维护负担的情况下不适用。
有关详细的Bootstrap兼容性信息,请参阅Bootstrap & Flexbox CSS指南。
常见PDF任务的代码示例如何比较?
为了说明IronPDF和Spire.PDF for .NET的能力,我们将通过代码示例比较它们在几个关键PDF功能上的实现,让您了解这些特性如何帮助您的PDF项目。
将HTML转换为PDF
IronPDF 示例:
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external HTML assets: images, CSS, and JavaScript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");Imports IronPdf
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from an HTML string using C#
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
pdf.SaveAs("output.pdf")
' Advanced Example with HTML Assets
' Load external HTML assets: images, CSS, and JavaScript.
' An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
myAdvancedPdf.SaveAs("html-with-assets.pdf")IronPDF中的ChromePdfRenderer类利用完整的Chrome浏览器引擎来渲染HTML内容。 这意味着CSS3动画、JavaScript执行和现代Web字体都将在Chrome中如实渲染。 RenderHtmlAsPdf()方法接受HTML字符串和加载外部资产的可选基本路径,使转换简单和复杂的HTML文档变得简单。 渲染器支持高级渲染选项,包括自定义纸张大小、边距和JavaScript延迟设置。
Spire.PDF示例:
using Spire.Pdf;
using Spire.Pdf.HtmlConverter;
using System.IO;
using System.Threading;
using System.Drawing;
namespace ConvertHtmlStringToPdfWithoutPlugin
{
class Program
{
static void Main(string[] args)
{
// Create a PdfDocument object
PdfDocument doc = new PdfDocument();
// Create a PdfPageSettings object
PdfPageSettings setting = new PdfPageSettings();
// Set page size and margins through the object
setting.Size = new SizeF(1000, 1000);
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);
// Create a PdfHtmlLayoutFormat object
PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
// Set IsWaiting property to true
htmlLayoutFormat.IsWaiting = true;
// Read HTML string from a .html file
string htmlString = File.ReadAllText(@"C:\Users\Administrator\Desktop\Document\Html\Sample.html");
// Load HTML from HTML string using LoadFromHTML method
Thread thread = new Thread(() =>
{ doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
// Save to a PDF file
doc.SaveToFile("HtmlStringToPdf.pdf");
}
}
}Imports Spire.Pdf
Imports Spire.Pdf.HtmlConverter
Imports System.IO
Imports System.Threading
Imports System.Drawing
Namespace ConvertHtmlStringToPdfWithoutPlugin
Class Program
Shared Sub Main(ByVal args As String())
' Create a PdfDocument object
Dim doc As New PdfDocument()
' Create a PdfPageSettings object
Dim setting As New PdfPageSettings()
' Set page size and margins through the object
setting.Size = New SizeF(1000, 1000)
setting.Margins = New Spire.Pdf.Graphics.PdfMargins(20)
' Create a PdfHtmlLayoutFormat object
Dim htmlLayoutFormat As New PdfHtmlLayoutFormat()
' Set IsWaiting property to true
htmlLayoutFormat.IsWaiting = True
' Read HTML string from a .html file
Dim htmlString As String = File.ReadAllText("C:\Users\Administrator\Desktop\Document\Html\Sample.html")
' Load HTML from HTML string using LoadFromHTML method
Dim thread As New Thread(Sub()
doc.LoadFromHTML(htmlString, True, setting, htmlLayoutFormat)
End Sub)
thread.SetApartmentState(ApartmentState.STA)
thread.Start()
thread.Join()
' Save to a PDF file
doc.SaveToFile("HtmlStringToPdf.pdf")
End Sub
End Class
End NamespaceSpire.PDF的HTML到PDF转换需要创建多个对象,包括PdfHtmlLayoutFormat。 转换必须在单线程公寓(STA)线程中执行,增加了实施的复杂性。 用户报告说"Spire生成的PDF文件只是一个图像。 有些css甚至不正确,比如忽略粗体字",这表明CSS渲染保真度方面的限制。
IronPDF使用Chrome的渲染引擎进行高品质的HTML到PDF转换,确保由于支持现代Web标准而准确再现Web内容。 Spire.PDF也提供强大的HTML到PDF转换,但可能无法达到IronPDF的渲染精度,并且采取了更长,更手动的方法。
如何加密PDF文档?
IronPDF 示例:
using IronPdf;
using System;
// Open an Encrypted File, alternatively create a new PDF from HTML
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;
// Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
// Change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");Imports IronPdf
Imports System
' Open an Encrypted File, alternatively create a new PDF from HTML
Private pdf = PdfDocument.FromFile("encrypted.pdf", "password")
' Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = DateTime.Now
' Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption()
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserFormData = False
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights
' Change or set the document encryption password
pdf.Password = "my-password"
pdf.SaveAs("secured.pdf")IronPDF的SecuritySettings类提供全面的API用于管理PDF安全。 您可以使用布尔属性控制个人权限,设置不同级别的打印权限,并将密码与其他安全设置分开管理。 API设计遵循.NET惯例,具有强类型枚举如PdfPrintSecurity。 在文档中了解更多关于PDF权限和密码的信息。
Spire.PDF示例:
using Spire.Pdf;
using Spire.Pdf.Security;
// Create a PdfDocument object
PdfDocument pdf = new PdfDocument();
// Load a sample PDF file
pdf.LoadFromFile(@"E:\Files\sample.pdf");
// Encrypt the PDF file with a password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print | PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit);
// Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF);Imports Spire.Pdf
Imports Spire.Pdf.Security
' Create a PdfDocument object
Private pdf As New PdfDocument()
' Load a sample PDF file
pdf.LoadFromFile("E:\Files\sample.pdf")
' Encrypt the PDF file with a password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print Or PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit)
' Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF)Spire.PDF的加密方法使用Security.Encrypt()方法结合位运算标志来设置权限。 虽然更简洁,但这种方法需要理解位操作,并提供的控制粒度低于IronPDF的各项权限属性。
两个库都提供易于使用的方法来加密PDF以及设定加密的PDF文档的读取能力。 IronPDF提供了一种简便的方法,同时仍然让您对PDF的安全设置有完全控制权。 Spire.PDF流程略微简短,但仍包含额外的选项来设定权限。
有哪些选项可以修订PDF内容?
IronPDF 示例:
using IronPdf;
// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
// Save the redacted document
pdf.SaveAs("redacted.pdf");Imports IronPdf
' Load the PDF document
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are")
' Save the redacted document
pdf.SaveAs("redacted.pdf")IronPDF提供一个专用的修订API,执行真实内容移除,而不仅仅是视觉遮掩。 RedactTextOnAllPages()方法搜索并永久删除指定文本,确保符合数据保护法规。 附加方法允许在特定页面或区域进行修订。
Spire.PDF借助矩形覆盖进行修订的示例:
虽然Spire.PDF没有专用的修订工具,但仍可以通过手动过程进行内容修订,如下所示:
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
// Specify the input PDF file path
string inputPdfFilePath = "path/to/your/input.pdf";
// Specify the output redacted PDF file path
string outputPdfFilePath = "path/to/your/redacted_output.pdf";
// Create a new PdfDocument object
PdfDocument pdfDocument = new PdfDocument();
// Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath);
// Redact content on each page
foreach (PdfPageBase page in pdfDocument.Pages)
{
// Define the area to redact (e.g., coordinates and size of the rectangle)
RectangleF redactArea = new RectangleF(100, 100, 200, 50); // Example coordinates and size
// Apply redaction
page.Canvas.DrawRectangle(new PdfSolidBrush(Color.Black), redactArea);
}
// Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath);Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing
' Specify the input PDF file path
Private inputPdfFilePath As String = "path/to/your/input.pdf"
' Specify the output redacted PDF file path
Private outputPdfFilePath As String = "path/to/your/redacted_output.pdf"
' Create a new PdfDocument object
Private pdfDocument As New PdfDocument()
' Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath)
' Redact content on each page
For Each page As PdfPageBase In pdfDocument.Pages
' Define the area to redact (e.g., coordinates and size of the rectangle)
Dim redactArea As New RectangleF(100, 100, 200, 50) ' Example coordinates and size
' Apply redaction
page.Canvas.DrawRectangle(New PdfSolidBrush(Color.Black), redactArea)
Next page
' Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath)这种手动方法需要计算每个修订区域的确切坐标,并且仅提供视觉遮掩而非真实内容移除。 底层文本仍可以通过PDF编辑工具提取。
IronPDF简化了修订,其强大但简单的修订工具。 由于缺乏内置的修订工具,Spire.PDF需要进行更多手动处理进行修订,致使工作流程可能效率较低。
如何签署PDF文档?
IronPDF 示例:
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Instantiate the renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature with certificate
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
' Instantiate the renderer
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>")
' Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create PdfSignature with certificate
Private sig = New PdfSignature(cert)
' Sign PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")IronPDF的数字签名实现遵循.NET证书处理模式。 PdfSignature类接受标准的X509Certificate2对象,并在内部处理PDF签名的复杂性。 您还可以添加视觉签名外观并配置签名域。
Spire.PDF示例:
using Spire.Pdf;
using Spire.Pdf.Security;
using System.Drawing;
// Create a PdfDocument object
PdfDocument doc = new PdfDocument();
// Load a sample PDF file
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pdf");
// Load the certificate
PdfCertificate cert = new PdfCertificate("C:\\Users\\Administrator\\Desktop\\MyCertificate.pfx", "e-iceblue");
// Create a PdfSignature object and specify its position and size
PdfSignature signature = new PdfSignature(doc, doc.Pages[doc.Pages.Count - 1], cert, "MySignature");
RectangleF rectangleF = new RectangleF(doc.Pages[0].ActualSize.Width - 260 - 54 , 200, 260, 110);
signature.Bounds = rectangleF;
signature.Certificated = true;
// Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
// Set various details about the signature
signature.NameLabel = "Signer:";
signature.Name = "Gary";
signature.ContactInfoLabel = "Phone:";
signature.ContactInfo = "0123456";
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "USA";
signature.ReasonLabel = "Reason:";
signature.Reason = "I am the author";
signature.DistinguishedNameLabel = "DN:";
signature.DistinguishedName = signature.Certificate.IssuerName.Name;
// Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\\Users\\Administrator\\Desktop\\handwrittingSignature.png");
// Set the signature font
signature.SignDetailsFont = new PdfTrueTypeFont(new Font("Arial Unicode MS", 12f, FontStyle.Regular));
// Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges | PdfCertificationFlags.AllowFormFill;
// Save to file
doc.SaveToFile("VisiableSignature.pdf");Imports Spire.Pdf
Imports Spire.Pdf.Security
Imports System.Drawing
' Create a PdfDocument object
Private doc As New PdfDocument()
' Load a sample PDF file
doc.LoadFromFile("C:\Users\Administrator\Desktop\sample.pdf")
' Load the certificate
Dim cert As New PdfCertificate("C:\Users\Administrator\Desktop\MyCertificate.pfx", "e-iceblue")
' Create a PdfSignature object and specify its position and size
Dim signature As New PdfSignature(doc, doc.Pages(doc.Pages.Count - 1), cert, "MySignature")
Dim rectangleF As New RectangleF(doc.Pages(0).ActualSize.Width - 260 - 54, 200, 260, 110)
signature.Bounds = rectangleF
signature.Certificated = True
' Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail
' Set various details about the signature
signature.NameLabel = "Signer:"
signature.Name = "Gary"
signature.ContactInfoLabel = "Phone:"
signature.ContactInfo = "0123456"
signature.DateLabel = "Date:"
signature.Date = DateTime.Now
signature.LocationInfoLabel = "Location:"
signature.LocationInfo = "USA"
signature.ReasonLabel = "Reason:"
signature.Reason = "I am the author"
signature.DistinguishedNameLabel = "DN:"
signature.DistinguishedName = signature.Certificate.IssuerName.Name
' Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\Users\Administrator\Desktop\handwrittingSignature.png")
' Set the signature font
signature.SignDetailsFont = New PdfTrueTypeFont(New Font("Arial Unicode MS", 12F, FontStyle.Regular))
' Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges Or PdfCertificationFlags.AllowFormFill
' Save to file
doc.SaveToFile("VisiableSignature.pdf")Spire.PDF提供对签名外观的广泛控制,但需要更多代码。 您必须手动设置每个标签,精确定位签名,并单独配置视觉元素。
对PDF进行数字签名可以在各种场合中有帮助,从用于认证PDF文档到简单签署新项目。 IronPDF提供了一种简单的方法来添加数字签名,允许轻松地自动化签署过程。 Spire.PDF也支持PDF的数字签名; 然而,这个过程可能更为手动,需要更多努力来实现。
有哪些方法可以为PDF添加水印?
IronPDF 示例:
using IronPdf;
// 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(@"C:\Path\To\Watermarked.pdf");Imports IronPdf
' Stamps a Watermark onto a new or existing PDF
Private renderer = New ChromePdfRenderer()
Private 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("C:\Path\To\Watermarked.pdf")IronPDF的水印功能接受HTML内容,允许您使用CSS进行样式设置。 ApplyWatermark()方法提供旋转角度和对齐的参数,使水印定位更加精确。 了解更多关于自定义水印和高级样式选项。
Spire.PDF示例:
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
// Create a PdfDocument object
PdfDocument pdf = new PdfDocument();
// Load a sample PDF document
pdf.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf");
// Create a PdfTrueTypeFont object
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 50f), true);
// Set the watermark text
string text = "CONFIDENTIAL";
// Measure the text size
SizeF textSize = font.MeasureString(text);
// Calculate the values of two offset variables,
// which will be used to calculate the translation amount of the coordinate system
float offset1 = (float)(textSize.Width * System.Math.Sqrt(2) / 4);
float offset2 = (float)(textSize.Height * System.Math.Sqrt(2) / 4);
// Traverse all the pages in the document
foreach (PdfPageBase page in pdf.Pages)
{
// Set the page transparency
page.Canvas.SetTransparency(0.8f);
// Translate the coordinate system by specified coordinates
page.Canvas.TranslateTransform(page.Canvas.Size.Width / 2 - offset1 - offset2, page.Canvas.Size.Height / 2 + offset1 - offset2);
// Rotate the coordinate system 45 degrees counterclockwise
page.Canvas.RotateTransform(-45);
// Draw watermark text on the page
page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0);
}
// Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf");Imports System
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing
' Create a PdfDocument object
Private pdf As New PdfDocument()
' Load a sample PDF document
pdf.LoadFromFile("C:\Users\Administrator\Desktop\sample.pdf")
' Create a PdfTrueTypeFont object
Dim font As New PdfTrueTypeFont(New Font("Arial", 50F), True)
' Set the watermark text
Dim text As String = "CONFIDENTIAL"
' Measure the text size
Dim textSize As SizeF = font.MeasureString(text)
' Calculate the values of two offset variables,
' which will be used to calculate the translation amount of the coordinate system
Dim offset1 As Single = CSng(textSize.Width * Math.Sqrt(2) / 4)
Dim offset2 As Single = CSng(textSize.Height * Math.Sqrt(2) / 4)
' Traverse all the pages in the document
For Each page As PdfPageBase In pdf.Pages
' Set the page transparency
page.Canvas.SetTransparency(0.8F)
' Translate the coordinate system by specified coordinates
page.Canvas.TranslateTransform(page.Canvas.Size.Width \ 2 - offset1 - offset2, page.Canvas.Size.Height \ 2 + offset1 - offset2)
' Rotate the coordinate system 45 degrees counterclockwise
page.Canvas.RotateTransform(-45)
' Draw watermark text on the page
page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0)
Next page
' Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf")Spire.PDF的水印需要使用坐标系统转换进行定位和旋转的手动计算。 虽然这提供了细致的控制,但需要理解图形编程概念。
IronPDF提供简单的方法来添加文本水印,同时允许您完全控制水印的位置和设计。 如果您有HTML和CSS的经验,IronPDF利用HTML和CSS使流程更为简便。 Spire.PDF的方式长且更为手动,但仍然提供了一个强大的水印工具,能够完全控制水印的设计和位置。
如何在PDF上盖章图像和文本?
IronPDF 示例:
using IronPdf;
using IronPdf.Editing;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");Imports IronPdf
Imports IronPdf.Editing
' Instantiate Renderer
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create text stamper
Private textStamper As New TextStamper() With {
.Text = "Text Stamper!",
.FontFamily = "Bungee Spice",
.UseGoogleFont = True,
.FontSize = 30,
.IsBold = True,
.IsItalic = True,
.VerticalAlignment = VerticalAlignment.Top
}
' Stamp the text stamper
pdf.ApplyStamp(textStamper)
pdf.SaveAs("stampText.pdf")
' Create image stamper
Dim imageStamper As New ImageStamper(New Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg")) With {.VerticalAlignment = VerticalAlignment.Top}
' Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0)
pdf.SaveAs("stampImage.pdf")IronPDF的加盖API使用专用类处理不同的印章类型。ImageStamper可以从URL或本地文件加载图像。 所有盖章都共享共同的对齐属性,以实现一致的定位。 了解更多盖章选项,包括HTML盖章和条码集成。
Spire.PDF(文本盖章示例):
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
// Assumes a PdfDocument is already loaded as `doc` object
PdfPageBase page = doc.Pages[0];
PdfGraphicsState state = page.Canvas.Save();
// Define font and brushes for different effects
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);
PdfSolidBrush brush1 = new PdfSolidBrush(Color.DeepSkyBlue);
PdfSolidBrush brush2 = new PdfSolidBrush(Color.CadetBlue);
// Apply transformations and draw strings with shadow and effect
page.Canvas.TranslateTransform(20, 200);
page.Canvas.ScaleTransform(1f, 0.6f);
page.Canvas.SkewTransform(-10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0);
page.Canvas.SkewTransform(10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0);
page.Canvas.ScaleTransform(1f, -1f);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18);
// Restore graphics to previous state
page.Canvas.Restore(state);Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing
' Assumes a PdfDocument is already loaded as `doc` object
Private page As PdfPageBase = doc.Pages(0)
Private state As PdfGraphicsState = page.Canvas.Save()
' Define font and brushes for different effects
Private font As New PdfFont(PdfFontFamily.Helvetica, 18F)
Private brush1 As New PdfSolidBrush(Color.DeepSkyBlue)
Private brush2 As New PdfSolidBrush(Color.CadetBlue)
' Apply transformations and draw strings with shadow and effect
page.Canvas.TranslateTransform(20, 200)
page.Canvas.ScaleTransform(1F, 0.6F)
page.Canvas.SkewTransform(-10, 0)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0)
page.Canvas.SkewTransform(10, 0)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0)
page.Canvas.ScaleTransform(1F, -1F)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18)
' Restore graphics to previous state
page.Canvas.Restore(state)Spire.PDF需要通过手动转换直接操作画布来实现每个效果。 创建复杂的盖章需要理解图形状态管理和坐标转换。
IronPDF的文本和图像盖章工具是一种强大、易于使用的盖章工具,类似于当应用盖章内容时所熟悉的HTML和CSS方式。 而Spire.PDF也提供了一个基础的文本盖章工具,应用盖章文本到您的PDF文件上却需要更多的努力。
哪款库能够更好地处理DOCX到PDF的转换?
IronPDF 示例:
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");Imports IronPdf
' Instantiate Renderer
Dim renderer As New DocxToPdfRenderer()
' Render from DOCX file
Dim pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
' Save the PDF
pdf.SaveAs("pdfFromDocx.pdf")IronPDF包含一个专用的DocxToPdfRenderer类,本机处理DOCX转换。 API与IronPDF中的其他渲染类一致,只需两行代码即可完成基本的转换。 高级选项通过渲染器的属性提供页面设置和格式化。 了解更多关于DOCX到PDF转换的特性。
使用Spire.Doc进行DOCX到PDF转换的Spire.PDF示例:
Spire.PDF本身不能将DOCX转换为PDF; 然而,可以使用Spire.Doc库进行此转换,然后可以使用Spire.PDF处理生成的PDF。
using Spire.Doc;
// Create a Document object
Document doc = new Document();
// Load a Word document
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.docx");
// Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF);
// Dispose of resources
doc.Dispose();Imports Spire.Doc
' Create a Document object
Private doc As New Document()
' Load a Word document
doc.LoadFromFile("C:\Users\Administrator\Desktop\Sample.docx")
' Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF)
' Dispose of resources
doc.Dispose()这种方式需要购买和管理一个额外的库(Spire.Doc),增加了成本和复杂性。
IronPDF提供了内置支持,直接进行DOCX到PDF的转换,意味着您可以节省时间,而无需额外库来处理这项任务。 另一方面,Spire.PDF不能直接处理DOCX到PDF的转换,需要使用Spire.Doc库将DOCX文件转换为PDF。
性能指标揭示了什么?
基于测试和用户反馈,以下是在实际使用中的库比较:
渲染性能
对于基本布局,Spire.PDF优化用于简单内容,如静态表格或基本样式文本,使其在这些用例中快速而有效。 然而,当处理包含现代CSS3功能、JavaScript或响应布局的复杂HTML时,IronPDF的基于Chrome的引擎更能提供准确的结果,但渲染时间略高。
内存使用
与IronPDF相比,由于Spire.PDF的渲染引擎更简单,内存使用量通常较少。然而,这会影响渲染精度和功能支持。 对于内存至关重要且HTML复杂性较低的应用程序,Spire.PDF可能更具优势。
线程和异步支持
IronPDF提供本地异步/等待支持,使用如RenderHtmlAsPdfAsync()的方法,适用于现代.NET应用程序。 Spire.PDF需要手动的线程管理与STA线程,增加了多线程应用的复杂性。
定价和许可模型如何比较?
IronPDF。 定价和许可
IronPDF提供多种级别和附加功能供您购买许可证。 开发者还可以购买Iron Suite,可以以两个产品的价格获得Iron Software的所有产品。 如果您尚未准备好购买许可证,IronPDF提供免费试用,为期30天。
定价:
- **永久许可证:**根据您的团队规模、项目需求和地点数量提供一系列永久许可证。 每种许可证类型都配有电子邮件支持。
- Lite License: 该许可证费用$999,支持一个开发者,一个位置和一个项目。
- Plus License: 支持三个开发者、三个位置和三个项目,这是比Lite License更高一步的选择,费用为$1,499。 Plus许可证除了电子邮件支持外,还提供聊天支持和电话支持。
- Professional License: 该许可证适用于较大的团队,支持十个开发者、十个位置和十个项目,费用为$2,399。 \u5b83\u63d0\u4f9b\u4e0e\u4e4b\u524d\u5c42\u6b21\u76f8\u540c\u7684\u8054\u7cfb\u652f\u6301\u6e20\u9053\uff0c\u4f46\u4e5f\u63d0\u4f9b\u5c4f\u5e55\u5171\u4eab\u652f\u6301\u3002
- 免版税再分发: IronPDF的许可还为额外的$2,399提供免版税再分发范围。
- **连续产品支持:**IronPDF提供持续的产品更新、安全功能升级以及来自其工程团队的支持,费用为$999/年或一次性购买$1,999即可获得5年覆盖。
- Iron Suite: 费用为$2,998,您可以访问所有Iron Software产品,包括IronPDF、IronOCR、IronWord、IronXL、IronBarcode、IronQR、IronZIP、IronPrint和IronWebScraper。
IronPDF提供灵活的许可选项,带有永久许可证和包括全面支持
Spire.PDF定价和许可
Spire.PDF根据您的需求提供一系列许可证。
- **免费版本:**Spire.PDF提供了一个免费版本,限制为10个PDF页面; 超过此限制,您需要购买付费许可证。
- **开发者订阅:**定价为$999/年,此选项适用于需要构建与PDF相关功能但不需要OEM分发权限的开发者。
- 开发者OEM订阅: 定价为$2,999/年,包含免费升级、优质支持和将应用程序分发给最终用户的能力。
- Site Enterprise Subscription: 定价为$4,599/年,此许可层支持多个地点的多名开发者,并提供更新和在线技术资源。
- Site OEM Subscription: 定价为$13,088/年,旨在满足需要在多个地点部署应用程序的大型企业。
哪款库提供了更好的文档和支持?
IronPDF
IronPDF在提供详细使用文档和支持方面表现突出:
- **全面文档:**提供广泛且用户友好的文档,涵盖所有功能。
- **24/5 支持:**提供工程师的积极支持。
- **视频教程:**在 YouTube 上提供逐步视频指南。
- **社区论坛:**活跃的社区提供额外支持。
- 定期更新: 每月产品更新,以确保最新功能及安全补丁。
- **PDF API参考:**提供API参考,帮助您充分利用我们的工具。
获取更多信息,查看IronPDF的广泛的文档,并访问Iron Software YouTube频道。
Spire.PDF for .NET文档与支持
- 论坛: Spire.PDF 有一个论坛,用户可以在其中互动,分享关于 Spire.PDF 的使用技巧、用法和遇到的问题。
- 代码示例: Spire.PDF 在其网站上提供代码示例,以展示如何在各种用例中使用产品。
- 新闻通讯: Spire.PDF 提供开发者新闻通讯,用于发布更新公告和其他重要信息。
- 支持: 支持主要通过论坛提供,不同许可证版本可以按需支付附加费用获取邮件/电话支持。
常见的开发者体验和反馈是什么?
基于社区反馈和实际使用情况:
IronPDF。 反馈
开发者一致赞扬 IronPDF 能提供"对原始 HTML 页面更全面和精确的呈现"。 该库处理复杂的 CSS3 布局、JavaScript 密集型页面和现代网络框架的能力使其成为需要高保真 PDF 生成的应用程序的首选。
常见的正面反馈包括:
- 直观的 API 设计减少了开发时间
- 出色的渲染质量匹配浏览器输出
- 详尽的文档配有实用示例
- 响应迅速的技术支持
Spire.PDF 反馈
社区反馈表明"Spire生成的PDF文件只是图像。 有些 CSS 甚至不正确,比如忽略粗体字体"。 此外,Spire.PDF的默认HTML转换路径中的JavaScript支持有限,开发者报告动态内容执行不完整。
常见问题包括:
- 对 CSS3 和现代网络标准的支持有限
- 缺乏 JavaScript执行能力
- HTML 转换的复杂线程要求
- 某些功能需要附加库
何时选择每个库?
选择IronPDF当:
- 你的 HTML 包含现代 CSS3、JavaScript 或响应式设计
- 你需要像素完美的渲染匹配浏览器输出
- 需要跨平台部署(Linux, macOS, Docker)
- 你希望许可证中包含全面的支持
- 你需要内置功能如 DOCX 转换无需附加库
- 你的团队重视快速开发并最小化代码量
选择 Spire.PDF 的时机:
- 你的 PDF 仅包含基本 HTML 和简单样式
- 内存使用是一个关键限制
- 你主要在 Windows 环境中工作
- 你的 HTML 不需要 JavaScript 执行
- 你的技术堆栈中已经使用了其他 Spire 产品
结论
总之,IronPDF 和 Spire.PDF for .NET 都是处理 .NET 应用中的 PDF 文档的有力工具。 IronPDF 在使用方便性、跨平台兼容性和对现代网络标准的支持上表现优异,如果你希望在处理 PDF 文档时提升效率,这是首选。 Spire.PDF 功能全面,但可能需要在复杂任务上付出更多努力,且缺乏现代网络应用要求的渲染精度。
对于从事现代网络技术开发、需要准确的 HTML 到 PDF 转换,或需要可靠的跨平台支持的开发者来说,IronPDF 提供了一个更完整的解决方案。 其基于 Chrome 的渲染引擎、直观的 API 和全面的支持使其特别适合企业应用和复杂文档生成场景。
你可以试用 30 天免费试用 来了解他们的可用特性。

Jacob Mellor is Chief Technology Officer at Iron Software and a visionary engineer pioneering C# PDF technology. As the original developer behind Iron Software's core codebase, he has shaped the company's product architecture since its inception, transforming it alongside CEO Cameron Rimington into a 50+ person company serving NASA, Tesla, and global government agencies.
Related Articles

