IronPDF 和 HiQPdf 的比較(C#)
IronPDF 和 HiQPdf 概述
對於使用 .NET 的開發人員來說,找到合適的 PDF 解決方案對於建立功能豐富的應用程式至關重要。在當今時代,隨著提供 PDF 轉換技術的產品數量不斷增加,找到滿足您需求的合適工具可能很困難。 在本比較中,我們將評估IronPDF和HiQPdf ,這是 .NET 專案中使用的兩個流行的 HTML 轉 PDF 庫。 雖然這兩個庫都提供了強大的 PDF 生成功能,但 IronPDF 因其更全面的功能、跨平台相容性和直觀的 API 而脫穎而出。
無論您是在尋找高級編輯選項、跨平台支援還是易用性,IronPDF 和 HiQPdf 的並排比較都將幫助您做出明智的決定。
主要功能概覽
IronPDF是一個功能強大的 C# 和 .NET PDF 庫,可實現無縫的 PDF 生成、編輯和操作。 它支援 .NET 8、7、6 和 Core,並為開發人員配備了一套豐富的工具集,可以處理從 HTML 到 PDF 轉換到加密和數位簽章等高級安全選項的一切事務。 使用 IronPDF,您可以為每個 PDF 頁面添加文本或 HTML 標題,使用 Web 字體進行更好的文本自定義,提取文本,創建時尚的 PDF 文件等等!
而HiQPdf則主要專注於 HTML 到 PDF 的轉換,為 CSS3、JavaScript、SVG 和 Canvas 元素提供強大的支援。 HiQPdf 雖然能夠可靠地產生 PDF 文件,但它缺乏 IronPDF 提供的一些高級功能和靈活性,尤其是在跨平台相容性和詳細文件編輯方面。
主要功能比較:IronPDF 與 HiQPdf 的 PDF 功能
IronPDF 功能
- PDF 轉換: IronPDF 可以將 HTML 轉換為 PDF,它完全支援現代網路標準,您可以放心,IronPDF 將始終從您的 HTML 頁面或內容返回像素完美的 PDF。 IronPDF 也可以將其他格式的檔案(例如 DOCX、圖像、RTF 等)轉換為 PDF 檔案。
- PDF 產生:使用 IronPDF,您可以從 URL、ASPX 檔案或 HTML 字串產生 PDF。 *安全功能:使用 IronPDF 的安全功能,您可以隨時確保任何敏感 PDF 檔案的安全。 使用 IronPDF 加密您的 PDF 文件、設定密碼並設定 PDF 文件的權限。
- PDF 編輯功能:使用 IronPDF,您可以輕鬆處理現有的 PDF 文件、編輯它們以及閱讀 PDF 文件。 IronPDF 提供編輯功能,例如新增頁首和頁尾、在 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 轉換後在 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");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");對於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");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";
}在加密 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");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");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();
}在對 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");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");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");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");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:所有實用類別和響應式修飾符 -基礎:完整的網格和組件系統 現代CSS3: Flexbox、Grid、自訂屬性、動畫、變換
已通過生產實例驗證: Bootstrap 首頁和Bootstrap 模板轉換精度達到像素級。
程式碼範例:使用 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");輸出:一個專業的部落格列表,採用 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 與 HiQPdf 的比較
IronPDF 文件和支持
IronPDF 為開發者提供友善的文件編寫體驗。 其完善的文件確保開發人員,無論是初學者還是高級用戶,都能有效地將 IronPDF 整合到他們的專案中。 IronPDF文件的一些關鍵面向包括:
*逐步指南:每個功能都有全面的教程,確保開發人員從開始到結束都有清晰的路徑。
- 24/5 技術支援:工程師在週一至週五的工作時間內隨時準備協助解決任何問題或疑慮。 *線上聊天:*提供即時支持,解決許可或技術問題。 電子郵件支援:**使用者可以聯絡我們進行詳細諮詢,我們會及時回覆並提供協助。
- API 參考:包含每個方法和屬性的範例的詳細 API 文件。 *程式碼範例:*提供可直接使用的程式碼片段,用於常見任務,例如 HTML 轉 PDF、加密、新增浮水印等。 定期更新:**經常更新文檔,以反映庫的變化和新功能。
有關更多信息,請查看 IronPDF 的詳細文檔,並訪問Iron Software 的 YouTube 頻道。
HiQPdf 文件和支持
HiQPdf 提供支援其大部分核心功能的基本文件。 雖然它提供了 HTML 轉 PDF 和基本 PDF 操作的功能,但其文件缺乏 IronPDF 所提供的深度和全面性。 HiQPdf文件的關鍵面向包括:
*基本 API 參考:*列出 HTML 轉 PDF 和基本 PDF 操作的方法。 程式碼範例: HTML 轉 PDF 轉換和頁面設定的範例程式碼有限。 跨平台指導極少:主要專注於 Windows 環境,對跨平台部署的指導較少。 電子郵件支援:**主要用於授權和基本技術諮詢。 *線上支援有限:即時幫助選項較少。
有關 HiQPdf 的更多技術細節,使用者需要查閱其他資源或外部論壇。
定價與授權:IronPDF 與 HiQPdf
IronPDF定價和許可
IronPDF提供不同等級的許可證和附加功能供用戶購買。 開發者還可以購買Iron Suite ,以兩款產品的價格獲得 Iron Software 的所有產品。 如果您尚未準備好購買許可證,IronPDF 提供免費試用版,以便您在購買許可證之前探索其所有功能。
定價(截至 2025 年):
*永久許可證:根據您的團隊規模、專案需求和地點數量,提供一系列永久許可證,每種許可證類型都附帶電子郵件支援。
- Lite 許可證:此許可證價格為$799 ,支援一名開發者、一個地點和一個專案。
- Plus 授權:支援三個開發者、三個地點和三個項目,這是比精簡版授權更進一步的版本,價格為$1,199 。 Plus 許可證除了提供基本的電子郵件支援外,還提供聊天支援和電話支援。 *專業許可證:*此許可證適用於較大的團隊,支援十名開發人員、十個地點和十個項目,價格為$2,399 。 它提供與前幾個層級相同的聯絡支援管道,但也提供螢幕共享支援。 免版稅再分發:** IronPDF 的授權協議還提供免版稅再分發保障,需額外支付$2,399費用。 *不間斷的產品支援: IronPDF 提供持續的產品更新、安全功能升級以及來自其工程團隊的支持,價格為每年 999 美元,或一次性購買 1,999 美元即可獲得 5 年的保障。
- Iron Suite:只需$1,498 ,即可存取所有 Iron Software 產品,包括IronPDF 、 IronOCR 、 IronWord 、 IronXL 、 IronBarcode 、 IronQR 、 IronZIP 、 IronPrint和IronWebScraper 。

HiQPdf定價和許可
HiQPdf 也提供多種授權選項,但其定價往往較為固定:
*新創企業許可證:*單一開發者使用單一應用程式需支付 245 美元 開發者授權: 495 美元,可供一名開發者使用,應用程式數量不限。 團隊許可證: 795 美元,最多可供五名開發人員開發任意數量的應用程式。 企業版授權:** 1,095 美元,可供無限數量的開發人員使用,應用程式數量不限。
雖然 HiQPdf 的價格很有競爭力,但它提供的價值不如 IronPDF 透過 Iron Suite 提供的套裝包,而且價格中包含的高級功能範圍也遠不及 IronPDF。
結論
對於希望將 PDF 功能整合到應用程式中的 .NET 開發人員來說,IronPDF 和 HiQPdf 都是不錯的選擇。 然而, IronPDF 的優勢在於其豐富的功能集、易用性和強大的文件。 IronPDF 具有跨平台相容性、豐富的程式碼範例和出色的支持,對於需要在不同環境下提供全面 PDF 功能的開發人員來說,它是一個優秀的解決方案。
如果您正在尋找一款性能卓越、靈活且支援完善的解決方案, IronPDF是一個強烈建議的選擇。此外,IronPDF 能夠輕鬆處理加密、密文和數位簽章等高級功能,這使其在 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 參考和程式碼範例。此外,它還提供每週 5 天、每天 24 小時的線上聊天和電子郵件技術支援。
IronPDF 可以用於編輯 PDF 文件中的內容嗎?
是的,IronPDF 提供了一種簡單直接的方法來編輯 PDF 文件中的特定文本,使開發人員能夠有效率地管理敏感資訊。
IronPDF有哪些類型的許可證?
IronPDF 提供多種授權版本,包括 Lite 版、Plus 版、Professional 版以及 Iron Suite 套件(可存取所有 Iron Software 產品)。此外,它還提供免版稅的再分發選項。






