产品比较 IronPDF 与 HiQPdf C# 的比较 Curtis Chau 已更新:八月 31, 2025 Download IronPDF NuGet 下载 DLL 下载 Windows 安装程序 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article IronPDF 和 HiQPdf 概述 对于使用 .NET 的开发人员,找到合适的 PDF 解决方案对构建功能丰富的应用程序至关重要。在当今现代时代,随着提供 PDF 转换技术的产品数量的增加,找到适合您需求的工具可能很困难。 在这次比较中,我们将评估 IronPDF 和 HiQPdf,这两个在 .NET 项目中常用的 HTML 到 PDF 库。 虽然这两个库都提供强大的 PDF 生成功能,但 IronPDF 因其更全面的功能、跨平台兼容性和直观的 API 而脱颖而出。 无论您是 looking for advanced editing options,cross-platform support,还是 ease of use,这个 IronPDF 和 HiQPdf 的并排比较将帮助您做出明智的决定。 关键特性一览 IronPDF 是一款用于 C# 和 .NET 的多功能 PDF 库,支持无缝的 PDF 生成、编辑和操作。 支持 .NET 8、7、6 和 Core,提供丰富的工具集,供开发人员处理从 HTML 到 PDF 转换到高级安全选项如加密和数字签名的所有内容。 使用 IronPDF,您可以为每个 PDF 页面添加文本或 HTML 页眉,使用网络字体进行更好的文本自定义,提取文本,创建时尚的 PDF 文档等! 相比之下,HiQPdf 主要专注于 HTML 到 PDF 转换,提供对 CSS3、JavaScript、SVG 和 Canvas 元素的强大支持。 虽然它提供可靠的 PDF 生成功能,但 HiQPdf 缺乏一些 IronPDF 提供的高级功能和灵活性,特别是在跨平台兼容性和详细文档编辑方面。 关键功能比较:IronPDF 与 HiQPdf 的 PDF 功能 IronPDF 功能 PDF 转换:IronPDF 可以将 HTML 转换为 PDF,它完全支持现代 Web 标准,您可以放心,IronPDF 将始终如一地从您的 HTML 页面或内容返回像素完美的 PDF。 IronPDF还可以将其他格式的文件转换为PDF,如DOCX、图像、RTF等。 PDF生成:使用IronPDF,您可以从URLs、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功能。 HiQPdf 功能: HTML 到 PDF 转换:支持 HTML5、CSS3、JavaScript、SVG 和 canvas 元素。 HiQPdf 能够以精确的保真度处理复杂的页面布局。 PDF 中的 JavaScript 执行:在 PDF 转换后运行 JavaScript,启用交互功能。 注释和书签:添加标准 PDF 注释,如评论和高亮。 自定义纸张尺寸支持:在 PDF 创建期间提供定义自定义纸张尺寸的选项。 基本密码保护:使用基本密码选项保护 PDF,以限制访问和修改。 页面分隔 CSS 属性:使用 CSS 属性 'page-break-before:always' 控制生成的 PDF 文档中的页面分隔。 合并和拆分 PDF:将多个 PDF 合并为一个文档,或将大型 PDF 拆分为更小的文件以便更好地管理。 IronPDF 拥有更广泛的功能集,提供更高级的 PDF 编辑、安全性和跨平台兼容性,使其在 HiQPdf 之上占据优势。 跨平台兼容性 IronPDF 和 HiQPdf 之间的关键区别之一是跨平台兼容性。 IronPDF 提供对 Windows、Linux 和 macOS 的无缝支持,成为在多样化环境中工作的开发人员的绝佳选择。 它还与 Docker、Azure、AWS 以及主要 .NET 版本兼容,包括 .NET 8、7、6 和 .NET Core。 HiQPdf 虽然功能完整,但在平台支持方面更有限,主要专注于 Windows 环境。 IronPDF 与 HiQPdf 的顶级亮点功能对比和代码示例 HTML 到 PDF 转换 IronPDF: using IronPdf; // Create a new PDF renderer var renderer = new ChromePdfRenderer(); // Render HTML to PDF var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>"); pdf.SaveAs("output.pdf"); // Render HTML to PDF with assets var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\"); myAdvancedPdf.SaveAs("html-with-assets.pdf"); using IronPdf; // Create a new PDF renderer var renderer = new ChromePdfRenderer(); // Render HTML to PDF var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>"); pdf.SaveAs("output.pdf"); // Render HTML to PDF with assets var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\"); myAdvancedPdf.SaveAs("html-with-assets.pdf"); Imports IronPdf ' Create a new PDF renderer Private renderer = New ChromePdfRenderer() ' Render HTML to PDF Private pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>") pdf.SaveAs("output.pdf") ' Render HTML to PDF with assets Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\") myAdvancedPdf.SaveAs("html-with-assets.pdf") $vbLabelText $csharpLabel HiQPdf: // Create the HTML to PDF converter HtmlToPdf htmlToPdfConverter = new HtmlToPdf(); // Convert HTML code to a PDF file htmlToPdfConverter.ConvertHtmlToFile("<b>Hello World</b>", null, "result.pdf"); // Create the HTML to PDF converter HtmlToPdf htmlToPdfConverter = new HtmlToPdf(); // Convert HTML code to a PDF file htmlToPdfConverter.ConvertHtmlToFile("<b>Hello World</b>", null, "result.pdf"); ' Create the HTML to PDF converter Dim htmlToPdfConverter As New HtmlToPdf() ' Convert HTML code to a PDF file htmlToPdfConverter.ConvertHtmlToFile("<b>Hello World</b>", Nothing, "result.pdf") $vbLabelText $csharpLabel 对于 HTML 到 PDF 转换,IronPDF 通过使用 ChromePdfRenderer 将 HTML 内容渲染为 PDF 提供了一种简单的方法,无论您是在处理 HTML 文档、字符串还是 URL。 IronPDF 还支持高级场景,例如渲染带有本地资源(如图像)的 HTML。 另一方面,HiQPdf 使用 HtmlToPdf 类,其中 HTML 内容直接转换为 PDF 文件,设置更为基本。这两个库都有效地处理 HTML 到 PDF 转换,但 IronPDF 提供了处理资产的额外灵活性。 加密 PDF 文档 IronPDF 示例: using IronPdf; // Load an existing PDF var pdf = PdfDocument.FromFile("encrypted.pdf", "password"); // Set metadata and remove existing passwords pdf.MetaData.Author = "Satoshi Nakamoto"; pdf.MetaData.Keywords = "SEO, Friendly"; pdf.MetaData.ModifiedDate = DateTime.Now; // Update 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 = IronPdf.Security.PdfPrintSecurity.FullPrintRights; // Set a new password and save the document pdf.Password = "my-password"; pdf.SaveAs("secured.pdf"); using IronPdf; // Load an existing PDF var pdf = PdfDocument.FromFile("encrypted.pdf", "password"); // Set metadata and remove existing passwords pdf.MetaData.Author = "Satoshi Nakamoto"; pdf.MetaData.Keywords = "SEO, Friendly"; pdf.MetaData.ModifiedDate = DateTime.Now; // Update 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 = IronPdf.Security.PdfPrintSecurity.FullPrintRights; // Set a new password and save the document pdf.Password = "my-password"; pdf.SaveAs("secured.pdf"); Imports IronPdf ' Load an existing PDF Private pdf = PdfDocument.FromFile("encrypted.pdf", "password") ' Set metadata and remove existing passwords pdf.MetaData.Author = "Satoshi Nakamoto" pdf.MetaData.Keywords = "SEO, Friendly" pdf.MetaData.ModifiedDate = DateTime.Now ' Update 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 = IronPdf.Security.PdfPrintSecurity.FullPrintRights ' Set a new password and save the document pdf.Password = "my-password" pdf.SaveAs("secured.pdf") $vbLabelText $csharpLabel HiQPdf: // Create the HTML to PDF converter HtmlToPdf htmlToPdfConverter = new HtmlToPdf(); // Set encryption mode and level htmlToPdfConverter.Document.Security.EncryptionMode = GetSelectedEncryptionMode(); htmlToPdfConverter.Document.Security.EncryptionLevel = GetSelectedEncryptionLevel(); // Set open and permissions passwords htmlToPdfConverter.Document.Security.OpenPassword = textBoxOpenPassword.Text; htmlToPdfConverter.Document.Security.PermissionsPassword = textBoxPermissionsPassword.Text; // Set PDF document permissions htmlToPdfConverter.Document.Security.AllowPrinting = checkBoxAllowPrint.Checked; htmlToPdfConverter.Document.Security.AllowCopyContent = checkBoxAllowCopy.Checked; htmlToPdfConverter.Document.Security.AllowEditContent = checkBoxAllowEdit.Checked; htmlToPdfConverter.Document.Security.AllowEditAnnotations = checkBoxAllowEditAnnotations.Checked; htmlToPdfConverter.Document.Security.AllowFormFilling = checkBoxAllowFillForms.Checked; // Set default permissions password if necessary if (htmlToPdfConverter.Document.Security.PermissionsPassword == string.Empty && (htmlToPdfConverter.Document.Security.OpenPassword != string.Empty || !IsDefaultPermission(htmlToPdfConverter.Document.Security))) { htmlToPdfConverter.Document.Security.PermissionsPassword = "admin"; } // Create the HTML to PDF converter HtmlToPdf htmlToPdfConverter = new HtmlToPdf(); // Set encryption mode and level htmlToPdfConverter.Document.Security.EncryptionMode = GetSelectedEncryptionMode(); htmlToPdfConverter.Document.Security.EncryptionLevel = GetSelectedEncryptionLevel(); // Set open and permissions passwords htmlToPdfConverter.Document.Security.OpenPassword = textBoxOpenPassword.Text; htmlToPdfConverter.Document.Security.PermissionsPassword = textBoxPermissionsPassword.Text; // Set PDF document permissions htmlToPdfConverter.Document.Security.AllowPrinting = checkBoxAllowPrint.Checked; htmlToPdfConverter.Document.Security.AllowCopyContent = checkBoxAllowCopy.Checked; htmlToPdfConverter.Document.Security.AllowEditContent = checkBoxAllowEdit.Checked; htmlToPdfConverter.Document.Security.AllowEditAnnotations = checkBoxAllowEditAnnotations.Checked; htmlToPdfConverter.Document.Security.AllowFormFilling = checkBoxAllowFillForms.Checked; // Set default permissions password if necessary if (htmlToPdfConverter.Document.Security.PermissionsPassword == string.Empty && (htmlToPdfConverter.Document.Security.OpenPassword != string.Empty || !IsDefaultPermission(htmlToPdfConverter.Document.Security))) { htmlToPdfConverter.Document.Security.PermissionsPassword = "admin"; } ' Create the HTML to PDF converter Dim htmlToPdfConverter As New HtmlToPdf() ' Set encryption mode and level htmlToPdfConverter.Document.Security.EncryptionMode = GetSelectedEncryptionMode() htmlToPdfConverter.Document.Security.EncryptionLevel = GetSelectedEncryptionLevel() ' Set open and permissions passwords htmlToPdfConverter.Document.Security.OpenPassword = textBoxOpenPassword.Text htmlToPdfConverter.Document.Security.PermissionsPassword = textBoxPermissionsPassword.Text ' Set PDF document permissions htmlToPdfConverter.Document.Security.AllowPrinting = checkBoxAllowPrint.Checked htmlToPdfConverter.Document.Security.AllowCopyContent = checkBoxAllowCopy.Checked htmlToPdfConverter.Document.Security.AllowEditContent = checkBoxAllowEdit.Checked htmlToPdfConverter.Document.Security.AllowEditAnnotations = checkBoxAllowEditAnnotations.Checked htmlToPdfConverter.Document.Security.AllowFormFilling = checkBoxAllowFillForms.Checked ' Set default permissions password if necessary If htmlToPdfConverter.Document.Security.PermissionsPassword = String.Empty AndAlso (htmlToPdfConverter.Document.Security.OpenPassword <> String.Empty OrElse Not IsDefaultPermission(htmlToPdfConverter.Document.Security)) Then htmlToPdfConverter.Document.Security.PermissionsPassword = "admin" End If $vbLabelText $csharpLabel 对于 加密 PDF 文档,IronPDF 通过其 API 提供了一种简单的方法。 开发人员可以删除现有密码,设置新的安全设置,限制用户操作,如注释、复制粘贴和表单数据输入,并使文档只读。 IronPDF 允许修改元数据、密码保护以及对打印权限的精细控制。 HiQPdf 也提供 PDF 加密,但流程略有不同,主要关注设置加密模式、级别、打开密码和权限密码。 它允许对文档权限进行细粒度控制,如打印、内容复制和编辑,未明确设置时提供默认权限。 这两个库都提供全面的安全设置,但 IronPDF 提供了额外的功能,如元数据定制和更容易处理文档只读模式。 编辑 PDF 文档内容 IronPDF 示例: using IronPdf; // Load an existing PDF PdfDocument pdf = PdfDocument.FromFile("novel.pdf"); // Redact specific text pdf.RedactTextOnAllPages("are"); // Save the updated PDF pdf.SaveAs("redacted.pdf"); using IronPdf; // Load an existing PDF PdfDocument pdf = PdfDocument.FromFile("novel.pdf"); // Redact specific text pdf.RedactTextOnAllPages("are"); // Save the updated PDF pdf.SaveAs("redacted.pdf"); Imports IronPdf ' Load an existing PDF Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf") ' Redact specific text pdf.RedactTextOnAllPages("are") ' Save the updated PDF pdf.SaveAs("redacted.pdf") $vbLabelText $csharpLabel HiQPdf 在其列出的功能中没有提供明确的编辑功能。 它主要关注于 PDF 生成、转换和操作,如从 HTML 创建 PDF。 IronPDF 提供了一种简单的方法来 编辑您的 PDF 文档页面中的内容。 例如,开发人员可以轻松使用几行代码在整个文档中编辑特定文本,如上面的代码片段所示。 相比之下,HiQPdf 在其功能集中缺乏显式的编辑功能,主要专注于 PDF 生成、转换和操作,如从 HTML 创建 PDF。 为 PDF 文件添加数字签名 IronPDF 示例: using IronPdf; using IronPdf.Signing; using System.Security.Cryptography.X509Certificates; // Create a PDF from HTML ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>"); // Load a digital certificate and sign the PDF X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable); var sig = new PdfSignature(cert); pdf.Sign(sig); // Save the signed PDF pdf.SaveAs("signed.pdf"); using IronPdf; using IronPdf.Signing; using System.Security.Cryptography.X509Certificates; // Create a PDF from HTML ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>"); // Load a digital certificate and sign the PDF X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable); var sig = new PdfSignature(cert); pdf.Sign(sig); // Save the signed PDF pdf.SaveAs("signed.pdf"); Imports IronPdf Imports IronPdf.Signing Imports System.Security.Cryptography.X509Certificates ' Create a PDF from HTML Private renderer As New ChromePdfRenderer() Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>") ' Load a digital certificate and sign the PDF Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable) Private sig = New PdfSignature(cert) pdf.Sign(sig) ' Save the signed PDF pdf.SaveAs("signed.pdf") $vbLabelText $csharpLabel HiQPdf: // Create a PDF document PdfDocument document = new PdfDocument(); // Add a page to the document PdfPage page1 = document.AddPage(); // Create fonts for text Font sysFont = new Font("Times New Roman", 10, System.Drawing.GraphicsUnit.Point); PdfFont pdfFontEmbed = document.CreateFont(sysFont, true); // Add a title to the PDF document PdfText titleTextTransImage = new PdfText(5, 20, "Click the image below to open the digital signature", pdfFontEmbed); titleTextTransImage.ForeColor = Color.Navy; PdfLayoutInfo textLayoutInfo = page1.Layout(titleTextTransImage); // Layout a PNG image with alpha transparency PdfImage transparentPdfImage = new PdfImage(5, 50, Server.MapPath("~") + @"\DemoFiles\Images\HiQPdfLogo_small.png"); PdfLayoutInfo imageLayoutInfo = page1.Layout(transparentPdfImage); // Apply digital signature PdfCertificatesCollection pdfCertificates = PdfCertificatesCollection.FromFile(Server.MapPath("~") + @"\DemoFiles\Pfx\hiqpdf.pfx", "hiqpdf"); PdfDigitalSignature digitalSignature = new PdfDigitalSignature(pdfCertificates[0]); digitalSignature.SigningReason = "My signing reason"; digitalSignature.SigningLocation = "My signing location"; digitalSignature.SignerContactInfo = "My contact info"; document.AddDigitalSignature(digitalSignature, imageLayoutInfo.LastPdfPage, imageLayoutInfo.LastPageRectangle); try { // Write the PDF document to a memory buffer byte[] pdfBuffer = document.WriteToMemory(); // Inform the browser about the binary data format HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf"); // Let the browser know how to open the PDF document and the file name HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=DigitalSignatures.pdf; size={0}", pdfBuffer.Length.ToString())); // Write the PDF buffer to HTTP response HttpContext.Current.Response.BinaryWrite(pdfBuffer); // End the HTTP response HttpContext.Current.Response.End(); } finally { document.Close(); } // Create a PDF document PdfDocument document = new PdfDocument(); // Add a page to the document PdfPage page1 = document.AddPage(); // Create fonts for text Font sysFont = new Font("Times New Roman", 10, System.Drawing.GraphicsUnit.Point); PdfFont pdfFontEmbed = document.CreateFont(sysFont, true); // Add a title to the PDF document PdfText titleTextTransImage = new PdfText(5, 20, "Click the image below to open the digital signature", pdfFontEmbed); titleTextTransImage.ForeColor = Color.Navy; PdfLayoutInfo textLayoutInfo = page1.Layout(titleTextTransImage); // Layout a PNG image with alpha transparency PdfImage transparentPdfImage = new PdfImage(5, 50, Server.MapPath("~") + @"\DemoFiles\Images\HiQPdfLogo_small.png"); PdfLayoutInfo imageLayoutInfo = page1.Layout(transparentPdfImage); // Apply digital signature PdfCertificatesCollection pdfCertificates = PdfCertificatesCollection.FromFile(Server.MapPath("~") + @"\DemoFiles\Pfx\hiqpdf.pfx", "hiqpdf"); PdfDigitalSignature digitalSignature = new PdfDigitalSignature(pdfCertificates[0]); digitalSignature.SigningReason = "My signing reason"; digitalSignature.SigningLocation = "My signing location"; digitalSignature.SignerContactInfo = "My contact info"; document.AddDigitalSignature(digitalSignature, imageLayoutInfo.LastPdfPage, imageLayoutInfo.LastPageRectangle); try { // Write the PDF document to a memory buffer byte[] pdfBuffer = document.WriteToMemory(); // Inform the browser about the binary data format HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf"); // Let the browser know how to open the PDF document and the file name HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=DigitalSignatures.pdf; size={0}", pdfBuffer.Length.ToString())); // Write the PDF buffer to HTTP response HttpContext.Current.Response.BinaryWrite(pdfBuffer); // End the HTTP response HttpContext.Current.Response.End(); } finally { document.Close(); } ' Create a PDF document Dim document As New PdfDocument() ' Add a page to the document Dim page1 As PdfPage = document.AddPage() ' Create fonts for text Dim sysFont As New Font("Times New Roman", 10, System.Drawing.GraphicsUnit.Point) Dim pdfFontEmbed As PdfFont = document.CreateFont(sysFont, True) ' Add a title to the PDF document Dim titleTextTransImage As New PdfText(5, 20, "Click the image below to open the digital signature", pdfFontEmbed) titleTextTransImage.ForeColor = Color.Navy Dim textLayoutInfo As PdfLayoutInfo = page1.Layout(titleTextTransImage) ' Layout a PNG image with alpha transparency Dim transparentPdfImage As New PdfImage(5, 50, Server.MapPath("~") & "\DemoFiles\Images\HiQPdfLogo_small.png") Dim imageLayoutInfo As PdfLayoutInfo = page1.Layout(transparentPdfImage) ' Apply digital signature Dim pdfCertificates As PdfCertificatesCollection = PdfCertificatesCollection.FromFile(Server.MapPath("~") & "\DemoFiles\Pfx\hiqpdf.pfx", "hiqpdf") Dim digitalSignature As New PdfDigitalSignature(pdfCertificates(0)) digitalSignature.SigningReason = "My signing reason" digitalSignature.SigningLocation = "My signing location" digitalSignature.SignerContactInfo = "My contact info" document.AddDigitalSignature(digitalSignature, imageLayoutInfo.LastPdfPage, imageLayoutInfo.LastPageRectangle) Try ' Write the PDF document to a memory buffer Dim pdfBuffer() As Byte = document.WriteToMemory() ' Inform the browser about the binary data format HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf") ' Let the browser know how to open the PDF document and the file name HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=DigitalSignatures.pdf; size={0}", pdfBuffer.Length.ToString())) ' Write the PDF buffer to HTTP response HttpContext.Current.Response.BinaryWrite(pdfBuffer) ' End the HTTP response HttpContext.Current.Response.End() Finally document.Close() End Try $vbLabelText $csharpLabel 在 为 PDF 文件添加数字签名方面,IronPDF 提供了一种简单的方法,允许开发人员从 HTML 内容创建 PDF 文档,使用数字证书进行签名,并以最少的代码将其保存。 另一方面,HiQPdf 需要更复杂的设置,其中通过程序创建 PDF 文档,添加页面并嵌入字体。 一个标题和一个图像被包括在内,随后是使用指定证书应用数字签名,以及详细的元数据,如签名原因和位置。 应用自定义水印 IronPDF 示例: using IronPdf; // Create a PDF renderer and render URL var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf"); // Apply a watermark to the PDF pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center); // Save the PDF pdf.SaveAs(@"C:\Path\To\Watermarked.pdf"); using IronPdf; // Create a PDF renderer and render URL var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf"); // Apply a watermark to the PDF pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center); // Save the PDF pdf.SaveAs(@"C:\Path\To\Watermarked.pdf"); Imports IronPdf ' Create a PDF renderer and render URL Private renderer = New ChromePdfRenderer() Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf") ' Apply a watermark to the PDF pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center) ' Save the PDF pdf.SaveAs("C:\Path\To\Watermarked.pdf") $vbLabelText $csharpLabel HiQPdf: 没有内置的专用水印工具。 在 应用自定义水印时,IronPDF 提供了一种简单的解决方案,支持在 PDF 上添加内置水印。 在示例中,URL 被渲染为 PDF,并在页面中心应用具有 HTML 样式的可定制水印。 这允许轻松修改水印的内容、样式和位置。 相比之下,HiQPdf 缺少内置的专用水印工具,使得需要此功能的开发人员在库中直接实现该功能时不太方便。 向 PDF 中添加图像和文本印章 IronPDF 示例(文本印章): using IronPdf; using IronPdf.Editing; // Create a PDF from HTML ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>"); // Create and apply a text stamp TextStamper textStamper = new TextStamper() { Text = "Text Stamper!", FontFamily = "Bungee Spice", UseGoogleFont = true, FontSize = 30, IsBold = true, IsItalic = true, VerticalAlignment = VerticalAlignment.Top }; pdf.ApplyStamp(textStamper); pdf.SaveAs("stampText.pdf"); using IronPdf; using IronPdf.Editing; // Create a PDF from HTML ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>"); // Create and apply a text stamp TextStamper textStamper = new TextStamper() { Text = "Text Stamper!", FontFamily = "Bungee Spice", UseGoogleFont = true, FontSize = 30, IsBold = true, IsItalic = true, VerticalAlignment = VerticalAlignment.Top }; pdf.ApplyStamp(textStamper); pdf.SaveAs("stampText.pdf"); Imports IronPdf Imports IronPdf.Editing ' Create a PDF from HTML Private renderer As New ChromePdfRenderer() Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>") ' Create and apply a text stamp Private textStamper As New TextStamper() With { .Text = "Text Stamper!", .FontFamily = "Bungee Spice", .UseGoogleFont = True, .FontSize = 30, .IsBold = True, .IsItalic = True, .VerticalAlignment = VerticalAlignment.Top } pdf.ApplyStamp(textStamper) pdf.SaveAs("stampText.pdf") $vbLabelText $csharpLabel IronPDF 示例(图像印章): using IronPdf; using IronPdf.Editing; // Create a PDF from HTML ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>"); // Create and apply an image stamp ImageStamper imageStamper = new ImageStamper(new Uri("/img/svgs/iron-pdf-logo.svg")) { VerticalAlignment = VerticalAlignment.Top }; pdf.ApplyStamp(imageStamper, 0); pdf.SaveAs("stampImage.pdf"); using IronPdf; using IronPdf.Editing; // Create a PDF from HTML ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>"); // Create and apply an image stamp ImageStamper imageStamper = new ImageStamper(new Uri("/img/svgs/iron-pdf-logo.svg")) { VerticalAlignment = VerticalAlignment.Top }; pdf.ApplyStamp(imageStamper, 0); pdf.SaveAs("stampImage.pdf"); Imports IronPdf Imports IronPdf.Editing ' Create a PDF from HTML Private renderer As New ChromePdfRenderer() Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>") ' Create and apply an image stamp Private imageStamper As New ImageStamper(New Uri("/img/svgs/iron-pdf-logo.svg")) With {.VerticalAlignment = VerticalAlignment.Top} pdf.ApplyStamp(imageStamper, 0) pdf.SaveAs("stampImage.pdf") $vbLabelText $csharpLabel HiQPdf: HiQPdf 没有专用的工具来直接将文本或图像作为印章添加到 PDF 文档中。 然而,它允许您向 PDF 添加文本、图像和图形对象,这可以起到类似的作用。 这可以通过使用库中可用的功能在 PDF 中创建文本对象和图像对象来实现。 IronPDF 提供专用的类,用于直接在任何现有或新创建的 PDF 文档上 添加图像和文本,使开发人员的过程变得简单。 相比之下,HiQPdf 缺乏专用的印章工具; 相反,它允许用户在 PDF 中添加文本和图像对象,需要更手动的方法来实现类似的结果。 DOCX 到 PDF 转换 IronPDF 示例: using IronPdf; // Render DOCX to PDF DocxToPdfRenderer renderer = new DocxToPdfRenderer(); PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx"); // Save the converted PDF pdf.SaveAs("pdfFromDocx.pdf"); using IronPdf; // Render DOCX to PDF DocxToPdfRenderer renderer = new DocxToPdfRenderer(); PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx"); // Save the converted PDF pdf.SaveAs("pdfFromDocx.pdf"); Imports IronPdf ' Render DOCX to PDF Private renderer As New DocxToPdfRenderer() Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx") ' Save the converted PDF pdf.SaveAs("pdfFromDocx.pdf") $vbLabelText $csharpLabel HiQPdf: 由于 HiQPdf 主要是一个 HTML 到 PDF 转换库,它没有提供任何内置的 DOCX 到 PDF 工具。 IronPDF 通过其 DocxToPdfRenderer 类提供 DOCX 到 PDF 转换的直接支持,而 HiQPdf 缺乏将 DOCX 文件转换为 PDF 的内置工具,而是专注于 HTML 到 PDF 转换。 代码示例比较总结 要了解 IronPDF 提供的丰富功能,并在实际工作中看到它们,请查看 IronPDF 的如何操作指南,深度挖掘每个功能,探索其工作原理,并给您成为 PDF 专家的技能。 现代 CSS 框架和 Bootstrap 渲染 随着现代 Web 应用程序日益采用 Bootstrap 等 CSS 框架进行快速开发和一致的 UI 设计,PDF 生成库必须准确保留这些框架布局以维持专业质量。 IronPDF:完整的 Bootstrap 和框架支持 IronPdf 的 Chromium 渲染引擎全面支持所有现代 CSS 框架: Bootstrap 5:完整的 flexbox 和 CSS Grid,以及所有响应式实用程序 Bootstrap 4:完整的卡片系统、导航和表单组件 Tailwind CSS:所有实用类和响应式修饰符 Foundation:完整的网格和组件系统 现代 CSS3:Flexbox、Grid、自定义属性、动画、变换 Validated with production examples: Bootstrap homepage and Bootstrap templates convert with pixel-perfect accuracy. 代码示例:具有 Bootstrap 的博客文章列表 using IronPdf; var renderer = new ChromePdfRenderer(); string bootstrapBlog = @" <!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'>Latest Blog Posts</h1> <article class='card mb-4 shadow-sm'> <div class='row g-0'> <div class='col-md-4'> <img src='https://via.placeholder.com/400x300' class='img-fluid rounded-start' alt='Blog post'> </div> <div class='col-md-8'> <div class='card-body d-flex flex-column h-100'> <div class='d-flex justify-content-between align-items-center mb-2'> <span class='badge bg-primary'>Technology</span> <small class='text-muted'>March 15, 2025</small> </div> <h2 class='card-title h4'>The Future of Web Development</h2> <p class='card-text flex-grow-1'>Exploring emerging trends in web development including serverless architecture, edge computing, and the evolution of JavaScript frameworks...</p> <div class='mt-auto'> <a href='#' class='btn btn-outline-primary'>Read More</a> </div> </div> </div> </div> </article> <article class='card mb-4 shadow-sm'> <div class='row g-0'> <div class='col-md-4'> <img src='https://via.placeholder.com/400x300' class='img-fluid rounded-start' alt='Blog post'> </div> <div class='col-md-8'> <div class='card-body d-flex flex-column h-100'> <div class='d-flex justify-content-between align-items-center mb-2'> <span class='badge bg-success'>Tutorial</span> <small class='text-muted'>March 10, 2025</small> </div> <h2 class='card-title h4'>Mastering Docker Containerization</h2> <p class='card-text flex-grow-1'>A comprehensive guide to Docker containerization, from basics to advanced deployment strategies for production environments...</p> <div class='mt-auto'> <a href='#' class='btn btn-outline-primary'>Read More</a> </div> </div> </div> </div> </article> <nav aria-label='Blog pagination'> <ul class='pagination justify-content-center'> <li class='page-item disabled'> <a class='page-link'>Previous</a> </li> <li class='page-item active'><a class='page-link' href='#'>1</a></li> <li class='page-item'><a class='page-link' href='#'>2</a></li> <li class='page-item'><a class='page-link' href='#'>3</a></li> <li class='page-item'> <a class='page-link' href='#'>Next</a> </li> </ul> </nav> </div> </body> </html>"; var pdf = renderer.RenderHtmlAsPdf(bootstrapBlog); pdf.SaveAs("blog-posts.pdf"); using IronPdf; var renderer = new ChromePdfRenderer(); string bootstrapBlog = @" <!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'>Latest Blog Posts</h1> <article class='card mb-4 shadow-sm'> <div class='row g-0'> <div class='col-md-4'> <img src='https://via.placeholder.com/400x300' class='img-fluid rounded-start' alt='Blog post'> </div> <div class='col-md-8'> <div class='card-body d-flex flex-column h-100'> <div class='d-flex justify-content-between align-items-center mb-2'> <span class='badge bg-primary'>Technology</span> <small class='text-muted'>March 15, 2025</small> </div> <h2 class='card-title h4'>The Future of Web Development</h2> <p class='card-text flex-grow-1'>Exploring emerging trends in web development including serverless architecture, edge computing, and the evolution of JavaScript frameworks...</p> <div class='mt-auto'> <a href='#' class='btn btn-outline-primary'>Read More</a> </div> </div> </div> </div> </article> <article class='card mb-4 shadow-sm'> <div class='row g-0'> <div class='col-md-4'> <img src='https://via.placeholder.com/400x300' class='img-fluid rounded-start' alt='Blog post'> </div> <div class='col-md-8'> <div class='card-body d-flex flex-column h-100'> <div class='d-flex justify-content-between align-items-center mb-2'> <span class='badge bg-success'>Tutorial</span> <small class='text-muted'>March 10, 2025</small> </div> <h2 class='card-title h4'>Mastering Docker Containerization</h2> <p class='card-text flex-grow-1'>A comprehensive guide to Docker containerization, from basics to advanced deployment strategies for production environments...</p> <div class='mt-auto'> <a href='#' class='btn btn-outline-primary'>Read More</a> </div> </div> </div> </div> </article> <nav aria-label='Blog pagination'> <ul class='pagination justify-content-center'> <li class='page-item disabled'> <a class='page-link'>Previous</a> </li> <li class='page-item active'><a class='page-link' href='#'>1</a></li> <li class='page-item'><a class='page-link' href='#'>2</a></li> <li class='page-item'><a class='page-link' href='#'>3</a></li> <li class='page-item'> <a class='page-link' href='#'>Next</a> </li> </ul> </nav> </div> </body> </html>"; var pdf = renderer.RenderHtmlAsPdf(bootstrapBlog); pdf.SaveAs("blog-posts.pdf"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 输出:一个专业的博客列表,带有 Bootstrap 的卡片布局、flexbox 对齐方式、徽章组件和分页,所有这些都在 PDF 中准确呈现。 HiQPdf:有限的现代框架支持 HiQPdf 使用基于 WebKit 的 HTML 渲染,对现代 CSS 框架的支持存在显著限制: WebKit 引擎:旧版 WebKit,仅支持不完整的 CSS3 有限的 Flexbox:Bootstrap 4/5 的 flexbox 布局可能无法正确渲染 不支持 CSS Grid:不支持现代网格系统 Bootstrap 3 限制:仅旧的基于表格的 Bootstrap 版本可靠工作 JavaScript 限制:JavaScript 执行能力较现代浏览器减少 开发人员报告 HiQPdf 的问题: Bootstrap 导航组件以对齐问题渲染 基于 Flexbox 的卡片布局无法正确显示 PDF 导出中忽略响应式实用程序和断点 复杂的 Bootstrap 组件需要大量 CSS 解决方法 开发影响:使用 Bootstrap 4+ 的应用程序在 HiQPdf 需进行大量额外工作。 团队必须维护用于 PDF 生成的并行简化 CSS(双重维护负担),将 UI 限制在 Bootstrap 3(牺牲现代功能),或进行广泛测试并手动修复组件(费时且脆弱)。 有关全面的 Bootstrap 兼容性指导,请参见 Bootstrap & Flexbox CSS 指南。 文档和支持:IronPDF vs. HiQPdf IronPDF 文档和支持 IronPDF 提供了一个开发者友好的文档体验。 其强大的文档确保了开发者,无论是初学者还是高级用户,都可以有效地将 IronPDF 集成到他们的项目中。 IronPDF 文档的一些关键方面包括: 逐步指南:为每个功能提供全面的教程,确保开发人员从头到尾都有清晰的路径。 24/5 技术支持:工程师在工作时间(星期一至星期五)提供支持,处理任何问题和问题。 实时聊天:提供实时支持,解决许可或技术问题。 电子邮件支持:用户可以通过电子邮件进行详细咨询,响应迅速且具有帮助性。 API 参考:提供详细的 API 文档,并为每个方法和属性提供示例。 代码示例:提供可直接使用的代码片段,用于常见任务如 HTML 到 PDF、加密、水印等。 定期更新:频繁更新文档以反映库的更改和新功能。 For more information, check out IronPDF's extensive documentation, and visit the Iron Software YouTube Channel. HiQPdf 文档和支持 HiQPdf 提供支持其大部分核心功能的基本文档。 虽然它提供了 HTML 到 PDF 转换和基本 PDF 操作的功能,但文档缺乏 IronPDF 提供的深度和全面性。 HiQPdf 文档的一些关键方面包括: 基本 API 参考:列出 HTML 到 PDF 和基本 PDF 操作的方法。 代码示例:有限的示例代码,用于 HTML 到 PDF 转换和页面设置。 有限的跨平台指导:主要专注于 Windows 环境,跨平台部署的指导较少。 电子邮件支持:主要涉及许可和基本技术查询。 有限的实时支持:实时支持选项较少。 对于 HiQPdf 的更多技术细节,用户需要在额外的资源或外部论坛中进行搜索。 定价和许可:IronPDF vs. HiQPdf IronPDF 定价和许可 IronPDF 为购买许可证提供了不同级别和附加功能。 开发人员还可以购买 Iron Suite,以两个软件的价格访问所有 Iron Software 的产品。 如果您尚未准备好购买许可证,IronPDF 提供了 免费试用版,让您在正式注册许可证前体验所有功能。 价格(截至2025年): 永久许可证:根据您的团队规模、项目需求和地点数量提供多种永久许可证类型,每个许可证类型都附带电子邮件支持。 Lite License:此许可证费用为 $799,支持一名开发人员、一个地点和一个项目。 Plus License:支持三名开发者,三处地点,和三个项目,这是lite许可证的下一步,费用$1,199。 Plus许可证除了电子邮件支持外,还提供聊天支持和电话支持。 Professional License:此许可证适合更大的团队,支持十名开发者,十个地点和十个项目,费用$2,399。 该许可证提供与之前的层级相同的联系方式支持渠道,并额外支持屏幕共享。 免版税再分配:IronPDF的许可还提供免版税再分配覆盖,额外$2,399 持续产品支持:IronPDF 提供持续的产品更新,安全功能升级,及其工程团队的支持,费用为 $999/年或一次性支付 $1,999,覆盖五年。 Iron Suite: For $1,498, you get access to all Iron Software products including IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint, and IronWebScraper. HiQPdf 定价和许可 HiQPdf 也提供多种许可选项,但其定价往往更为严格: 启动许可证: 单一开发人员的单个应用程序费用为 $245 开发人员许可:费用为 $495,一名开发人员可以用于任意数量的应用程序。 团队许可:费用为 $795,适用于最多五名开发人员,任何数量的应用程序。 企业许可证:费用为 $1,095,适用于无限数量的开发人员和任意数量的应用程序。 虽然 HiQPdf 的定价具有竞争力,但它没有通过 Iron Suite 提供的捆绑式 IronPDF 那样的价值,也没有价格中附带的丰富高级功能。 结论 IronPDF 和 HiQPdf 均为需要在其应用程序中集成 PDF 功能的 .NET 开发人员的不错选择。 然而,IronPDF 凭借其广泛的功能集、易用性和完善的文档而脱颖而出。 凭借其跨平台兼容性、丰富的代码示例和出色的支持,对于需要在不同环境中享受全面 PDF 功能的开发人员而言,IronPDF 是一个优秀的解决方案。 如果您正在寻找一个提供出色性能、灵活性和支持的完整解决方案,IronPDF 是强烈推荐的选择。此外,IronPDF 能够轻松处理高级功能,如加密、编辑和数字签名,使其在 HiQPdf 中具有独特的优势。 [{i:(HiQPdf 是其各自所有者的注册商标。 本网站与 HiQPdf 无关、未经 HiQPdf 官方确认或赞助。 所有产品名称、徽标和品牌均为其各自所有者的财产。 比较仅供参考,反映的是撰写时的公开信息。] 常见问题解答 如何在C#中将HTML转换为PDF? 你可以使用IronPDF的RenderHtmlAsPdf方法将HTML字符串转换为PDF。你还可以使用RenderHtmlFileAsPdf将HTML文件转换为PDF。 IronPDF支持哪些平台? IronPDF兼容Windows、Linux、macOS、Docker、Azure、AWS以及主要.NET版本,包括.NET 8、7、6和.NET Core。 我可以在C#中对PDF应用数字签名吗? 可以,IronPDF允许您使用其API对PDF文档应用数字签名。您可以指定证书和元数据,如签名原因和位置。 我如何为PDF文档添加水印? IronPDF内置支持为PDF添加自定义水印。您可以轻松地使用IronPDF的API将水印集成到PDF文档中。 IronPDF提供了哪些安全功能? IronPDF提供了高级安全功能,包括加密、密码保护、权限设置以及将文档设为只读的能力。 IronPDF支持将DOCX转换为PDF吗? 是的,IronPDF支持DOCX到PDF的转换。您可以使用DocxToPdfRenderer类无缝转换DOCX文档为PDF。 IronPDF如何处理HTML到PDF的转换? IronPDF使用ChromePdfRenderer将HTML内容渲染为PDF,支持HTML文档、字符串、URL以及包含本地资产如图像的场景。 IronPDF提供了什么支持和文档? IronPDF提供全面的文档,包括分步指南、广泛的API参考和代码示例。它还通过在线聊天和电子邮件提供24/5的技术支持。 IronPDF可以用于PDF文档中的内容编辑吗? 是的,IronPDF提供了一个简单的方式来编辑整个PDF文档中的特定文本,允许开发人员有效管理敏感信息。 有哪些类型的IronPDF许可证可用? IronPDF提供各种许可证,包括Lite、Plus、Professional,以及提供对所有Iron Software产品访问的Iron Suite。它还提供免版税的再分发选项。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 相关文章 已发布十一月 13, 2025 比较 C# HTML 到 PDF 开源与 IronPDF 比较开源 HTML 到 PDF 库与 IronPDF for C#。发现哪个解决方案为您的 .NET 项目提供最佳的 PDF 生成能力。 阅读更多 已发布十月 27, 2025 哪种 ASP.NET Core PDF 库性价比最高? 发现适合ASP.NET Core应用程序的最佳PDF库。比较IronPDF的Chrome引擎与Aspose和Syncfusion的替代品。 阅读更多 已发布十月 27, 2025 如何使用 Aspose C# 与 IronPDF 创作 PDF 通过此逐步指南,学习如何使用 Aspose C# 与 IronPDF 创建 PDF,专为开发人员设计。 阅读更多 IronPDF 与 PDFTron (Apryse):2025 年完整的 C# PDF 库比较
已发布十一月 13, 2025 比较 C# HTML 到 PDF 开源与 IronPDF 比较开源 HTML 到 PDF 库与 IronPDF for C#。发现哪个解决方案为您的 .NET 项目提供最佳的 PDF 生成能力。 阅读更多
已发布十月 27, 2025 哪种 ASP.NET Core PDF 库性价比最高? 发现适合ASP.NET Core应用程序的最佳PDF库。比较IronPDF的Chrome引擎与Aspose和Syncfusion的替代品。 阅读更多
已发布十月 27, 2025 如何使用 Aspose C# 与 IronPDF 创作 PDF 通过此逐步指南,学习如何使用 Aspose C# 与 IronPDF 创建 PDF,专为开发人员设计。 阅读更多