IronPDF 和 NReco .NET Core 的比較
處理 PDF 文件時,您肯定希望使用最適合您專案需求的工具,對嗎? 但市面上有很多不同的 PDF 函式庫,很難決定哪一個最適合你。 今天我們將仔細研究兩個著名的 PDF 庫:IronPDF 和 NReco.PdfGenerator。
我們將比較它們的功能、相容性和整體效能,以幫助您做出明智的決定,選擇最適合您的程式庫。
IronPDF 和 NReco.PdfGenerator 概述
IronPDF是一個功能全面的 .NET 函式庫,擅長將 HTML 轉換為 PDF,並提供一套用於處理 PDF 檔案的功能。 IronPDF 支援現代 Web 標準,包括 HTML5、CSS3 和 JavaScript,確保高保真 PDF 生成。 它還設計得非常人性化,提供了一個直覺的 API,可以與 .NET 應用程式無縫整合。
NReco.PdfGenerator for .NET 是一個專注於 HTML 到 PDF 轉換的函式庫。 它基於 WkHtmlToPdf 命令列工具,並依賴傳統的 Qt WebKit 渲染引擎,從 HTML 內容建立 PDF 文件。 請注意,Qt WebKit 已停止積極維護,並且對現代 HTML5、CSS3 和 JavaScript 功能的支援有限。 該程式庫以其易用性和快速整合到 .NET 專案中而聞名,只需要一個 .NET 程式集,其中已經包含了 WkHtmlToPdf 二進位檔案。
跨平台相容性
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:可與 Microsoft Visual Studio 和 JetBrains Rider & ReSharper 等 IDE 搭配使用。 -作業系統與處理器:支援多種不同的作業系統和處理器,包括 Windows、Mac、Linux、x64、x86、ARM。
有關 IronPDF 相容性的更多詳細信息,請訪問IronPDF 功能頁面。
NReco.Pdf產生器
- .NET 版本:
- .NET Standard 2.0+
- .NET Framework 4.5+
- .NET Core 2.0+
-應用環境: NReco.PdfGenerator 可在 Windows、Linux 和 macOS 等各種環境下運作。 在 Linux 或 macOS 系統上運作時,您需要確保已安裝所有必要的依賴項才能使其正常運作。 在 Windows 系統中部署後,它可以用於 .NET Core 應用程式。
主要功能比較:IronPDF 與 NReco.PdfGenerator 的 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 應用程式無縫整合。
如需查看 IronPDF 功能的完整列表,請造訪IronPDF 功能頁面。
NReco.Pdf產生器 功能
- HTML 轉 PDF 轉換:使用 WkHtmlToPdf 和舊版 Qt WebKit 引擎將 HTML、CSS 和基本 JavaScript 轉換為 PDF(對現代 Web 標準的支援有限)。
- PDF 選項:支援各種 PDF 選項,如頁面方向、大小、邊距和縮放。 -範本:用於頁首、頁尾和頁碼的 HTML 範本。 -內容合併:將多個 HTML 頁面合併成一個 PDF 檔案。 -輸出自訂:使用自訂字體和樣式自訂 PDF 的外觀。 -部署:適用於 Windows 和非 Windows 部署,使用 NReco.PdfGenerator.LT。
IronPDF 與 NReco.PdfGenerator 的主要亮點功能比較及程式碼範例
現在,讓我們仔細看看處理 PDF 文件時的一些常見用例,以及這兩個庫是如何處理它們的。
HTML 轉 PDF
IronPDF 範例:
using IronPdf;
// Enable web security settings such as disabling local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate the renderer for creating PDFs
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export the PDF to a file
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external HTML assets: images, CSS, and JavaScript.
// Example uses 'c:\site\assets\' as the base path for loading assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"c:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");using IronPdf;
// Enable web security settings such as disabling local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate the renderer for creating PDFs
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export the PDF to a file
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external HTML assets: images, CSS, and JavaScript.
// Example uses 'c:\site\assets\' as the base path for loading assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"c:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");NReco.PdfGenerator 範例:
using System;
using NReco.PdfGenerator;
// Format HTML content with the current date and time
var htmlContent = String.Format("<body>Hello world: {0}</body>", DateTime.Now);
// Instantiate the HTML to PDF converter
var htmlToPdf = new HtmlToPdfConverter();
// Generate the PDF from the HTML content
var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);using System;
using NReco.PdfGenerator;
// Format HTML content with the current date and time
var htmlContent = String.Format("<body>Hello world: {0}</body>", DateTime.Now);
// Instantiate the HTML to PDF converter
var htmlToPdf = new HtmlToPdfConverter();
// Generate the PDF from the HTML content
var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);IronPDF採用現代 Chromium 渲染引擎 (Blink),並完全支援 HTML5、CSS3 和 JavaScript,從而提供高保真渲染效果。 使用 IronPDF 進行HTML 轉 PDF 轉換時,您可以從 HTML 文件、網頁等建立像素級完美的 PDF。 NReco.PdfGenerator 使用 WkHtmlToPdf 和傳統的 Qt WebKit 引擎,雖然可以為簡單的 HTML 提供基本的渲染,但對現代 Web 標準的支援有限,並且可能無法達到 IronPDF 基於 Chromium 的渲染功能的精度。
有關使用 IronPDF 進行 HTML 到 PDF 轉換的更多範例,請造訪IronPDF HTML 到 PDF 。
加密 PDF 文件
IronPDF 範例:
using IronPdf;
using System;
// Open an encrypted file or 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
// Make the PDF read-only, disallow copying & pasting, and disallow printing
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;
// Change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");using IronPdf;
using System;
// Open an encrypted file or 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
// Make the PDF read-only, disallow copying & pasting, and disallow printing
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;
// Change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");NReco.PdfGenerator 範例: NReco.PdfGenerator 本身不支援 PDF 加密,因為該程式庫的重點主要是處理 HTML 到 PDF 的轉換。
IronPDF 提供了一個簡單且強大的PDF 加密工具。 使用 IronPDF,您可以完全控制整個過程,包括設定安全設定。 然而,NReco.PdfGenerator 缺乏原生加密功能,因此,如果您在使用 NReco.PdfGenerator 轉換 PDF 檔案後想要對其進行加密,則需要其他能夠處理 PDF 加密的程式庫。
如需更多加密範例,請造訪IronPDF 的相關主題操作指南。
編輯 PDF 內容
IronPDF 範例:
using IronPdf;
// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact the word 'are' on all pages of the document
pdf.RedactTextOnAllPages("are");
// Save the redacted PDF
pdf.SaveAs("redacted.pdf");using IronPdf;
// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact the word 'are' on all pages of the document
pdf.RedactTextOnAllPages("are");
// Save the redacted PDF
pdf.SaveAs("redacted.pdf");NReco.PdfGenerator 範例: NReco.PdfGenerator 本身不支援文字編輯。
IronPDF 只需幾行程式碼即可提供您簡潔易用的編輯工具。 由於其簡單易用,您可以確信,透過使用 IronPDF 的編輯功能,您將能夠立即提高工作效率。 另一方面,NReco.PdfGenerator 需要一個額外的外部程式庫來處理編輯過程,因為它本身沒有對 PDF 編輯的原生支援。
如需更多編輯範例,請造訪 IronPDF 關於此主題的操作指南。
簽署PDF文檔
IronPDF 範例:
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Instantiate the Chrome PDF Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render HTML as PDF
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with the Exportable flag set
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object and sign the PDF document
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;
// Instantiate the Chrome PDF Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render HTML as PDF
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with the Exportable flag set
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object and sign the PDF document
var sig = new PdfSignature(cert);
pdf.Sign(sig);
// Save the signed PDF
pdf.SaveAs("signed.pdf");NReco.PdfGenerator 範例: NReco.PdfGenerator 本身不支援數位簽章。
IronPDF 的數位簽章功能為您提供了一種輕鬆實現 PDF 自動簽名的方法。 它簡潔明了的 API 讓您可以完全控制簽名流程,而其易於實現的特性意味著如果您經常需要簽署 PDF 文件,則可以減少您的工作量。
NReco.PdfGenerator 不提供對 PDF 進行數位簽章的任何支持,但您可以使用 iTextSharp 等第三方函式庫來完成此操作。
如需更多簽名範例,請造訪IronPDF 關於此主題的操作指南。
在PDF頁面上新增浮水印
IronPDF 範例:
using IronPdf;
// Instantiate the renderer and render a PDF from a URL
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Apply an HTML-based watermark to the PDF
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
// Save the watermarked PDF
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");using IronPdf;
// Instantiate the renderer and render a PDF from a URL
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Apply an HTML-based watermark to the PDF
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
// Save the watermarked PDF
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");NReco.PdfGenerator 範例: NReco.PdfGenerator 本身不支援浮水印。
熟悉 HTML 和 CSS 可以提升您在使用 IronPDF浮水印工具時的體驗。 您將完全掌控水印添加過程。 水印控制功能直覺易學,讓您很快就能熟練掌握。
如果您正在使用 NReco.PdfGenerator 並且想要為新轉換的 PDF 檔案新增浮水印,則需要安裝外部程式庫,例如 PDFSharp。
有關更多浮水印範例,請造訪IronPDF 的相關主題操作指南。
在 PDF 檔案上新增文字和圖像
IronPDF 範例:
using IronPdf;
using IronPdf.Editing;
// Instantiate the renderer and render a PDF from HTML
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create a text stamper and customize its settings
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Apply text stamp to the PDF
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");using IronPdf;
using IronPdf.Editing;
// Instantiate the renderer and render a PDF from HTML
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create a text stamper and customize its settings
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Apply text stamp to the PDF
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");using IronPdf;
using IronPdf.Editing;
using System;
// Instantiate the renderer and render a PDF from HTML
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create an image stamper with specific settings
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Apply image stamp to the PDF
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");using IronPdf;
using IronPdf.Editing;
using System;
// Instantiate the renderer and render a PDF from HTML
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create an image stamper with specific settings
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Apply image stamp to the PDF
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");NReco.PdfGenerator 範例: NReco.PdfGenerator 本身不支援 HTML 時間戳記。
IronPDF 提供強大的文字和圖像加蓋工具。 透過與 HTML 和 CSS 非常相似的技術,您可以完全控製印章過程。 相較之下,NReco.PdfGenerator 需要 iTextSharp 或 PDFSharp 等外部庫才能將文字和圖像新增至新轉換的 PDF 文件中。
有關更多沖壓範例,請造訪IronPDF 的相關主題操作指南。
DOCX 轉 PDF 轉換
IronPDF 範例:
using IronPdf;
// Instantiate the DOCX to PDF Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render a DOCX file as PDF
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the converted PDF
pdf.SaveAs("pdfFromDocx.pdf");using IronPdf;
// Instantiate the DOCX to PDF Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render a DOCX file as PDF
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the converted PDF
pdf.SaveAs("pdfFromDocx.pdf");NReco.PdfGenerator 範例: NReco.PdfGenerator 本身不支援 DOCX 到 PDF 的轉換。
使用 IronPDF,只需幾行程式碼即可將 DOCX 檔案轉換為 PDF 格式。 該工具簡化了實施過程,確保了高效的工作空間,同時又不犧牲生成的 PDF 文件的品質。 使用 NReco.PdfGenerator,您無法執行 DOCX 到 PDF 的轉換,因為該程式庫主要專注於 HTML 到 PDF 的轉換。 您需要像 Apsose.Words 這樣的額外程式庫來處理 DOCX 到 PDF 的轉換。
有關更多 DOCX 轉 PDF 的範例,請造訪IronPDF 的相關主題操作指南。
功能對比總結
定價與授權:IronPDF 與 NReco.PdfGenerator
IronPDF定價和許可
IronPDF提供不同等級的許可證和附加功能供用戶購買。 開發者還可以購買Iron Suite ,只需支付兩份產品的價格即可獲得 Iron Software 的所有產品。 如果您尚未準備好購買許可證,IronPDF 提供 30 天的免費試用期。
-永久許可證:根據您的團隊規模、專案需求和地點數量,提供一系列永久許可證。 每種許可證類型都包含電子郵件支援服務。
Lite 許可證:此許可證價格為$799 ,支援一名開發者、一個地點和一個專案。
- Plus 授權:支援三個開發者、三個地點和三個項目,這是比精簡版授權更進一步的版本,價格為$1,199 。 Plus 許可證除了提供基本的電子郵件支援外,還提供聊天支援和電話支援。
-專業許可證:適用於較大的團隊,支援十名開發人員、十個地點和十個項目,價格為$2,399 。 它提供與前幾個層級相同的聯絡支援管道,但也提供螢幕共享支援。
-免版稅再分發: IronPDF 的許可提供免版稅再分發保障,只需額外支付$2,399即可。
-不間斷的產品支援:您可以每年支付$1,199或一次性購買$2,399以獲得 5 年的持續產品更新、安全功能升級以及工程團隊的支援。
- Iron Suite:只需$1,498 ,即可存取所有 Iron Software 產品,包括 IronPDF、IronOCR、IronWord、IronXL、IronBarcode、IronQR、IronZIP、IronPrint 和 IronWebScraper。
NReco.Pdf產生器
-免費版: NReco.PdfGenerator 提供免費的線上 HTML 轉 PDF 轉換器。
-企業原始碼包: NReco 提供售價 199 美元的 PDF 生成器企業原始碼包,其中包括用於再分發的商業許可證、高級 API/NReco.PdfGenerator LT NuGet 包版本的許可證密鑰、一年的電子郵件支援以及對源代碼 ZIP 文件的訪問權限。
文件與支援:IronPDF 與 NReco.PdfGenerator 對比
IronPDF
IronPDF 在提供全面的文件和支援方面表現出色:
-全面的文件:涵蓋所有功能的詳盡且用戶友好的文件。
- 24/5 支援:提供線上工程師支援。 -影片教學: YouTube 上提供逐步影片指南。 -社區論壇:一個活躍的社區,可提供更多支援。 -定期更新:每月進行產品更新,以確保最新功能和安全性修補程式。
有關更多信息,請查看 IronPDF 的詳細文檔並訪問Iron Software YouTube 頻道。
NReco.Pdf產生器
- API 參考:提供有關其 API 的文檔,以便您可以了解其各個方面是如何運作的。 -聯絡方式:您可以在 NReco 團隊的網站上輕鬆找到所有聯絡方式,如果您有任何問題或疑問,都可以很方便地與他們聯繫。
現代 CSS 框架支持
IronPDF 和 NReco.PdfGenerator 的一個關鍵區別在於它們支援 Bootstrap、Tailwind CSS 和 Foundation 等現代 CSS 框架。
IronPDF:完全支援 Bootstrap
IronPDF 的 Chromium 渲染引擎為現代 CSS 框架提供全面支援:
- Bootstrap 5:全面支援 flexbox 和 CSS Grid,實現響應式佈局 -複雜版面:以像素級精確度渲染Bootstrap 首頁和Bootstrap 範本。 -現代特色: CSS3 動畫、變換、過渡和媒體查詢
- CSS框架: Bootstrap、Tailwind CSS、Foundation、Bulma 都能無縫協作
程式碼範例:渲染 Bootstrap 內容
using IronPdf;
// Render a Bootstrap 5 layout
var renderer = new ChromePdfRenderer();
// Example: Bootstrap responsive card grid
string bootstrapHtml = @"
<!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 mt-5'>
<h1 class='mb-4'>Product Catalog</h1>
<div class='row g-4'>
<div class='col-lg-4 col-md-6'>
<div class='card h-100 shadow'>
<div class='card-body d-flex flex-column'>
<h5 class='card-title'>Product A</h5>
<p class='card-text flex-grow-1'>Modern flexbox-based card layout with Bootstrap 5.</p>
<button class='btn btn-primary mt-auto'>Learn More</button>
</div>
</div>
</div>
<div class='col-lg-4 col-md-6'>
<div class='card h-100 shadow'>
<div class='card-body d-flex flex-column'>
<h5 class='card-title'>Product B</h5>
<p class='card-text flex-grow-1'>Responsive grid adapts to screen size.</p>
<button class='btn btn-primary mt-auto'>Learn More</button>
</div>
</div>
</div>
<div class='col-lg-4 col-md-6'>
<div class='card h-100 shadow'>
<div class='card-body d-flex flex-column'>
<h5 class='card-title'>Product C</h5>
<p class='card-text flex-grow-1'>CSS3 features fully supported.</p>
<button class='btn btn-primary mt-auto'>Learn More</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(bootstrapHtml);
pdf.SaveAs("bootstrap-catalog.pdf");using IronPdf;
// Render a Bootstrap 5 layout
var renderer = new ChromePdfRenderer();
// Example: Bootstrap responsive card grid
string bootstrapHtml = @"
<!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 mt-5'>
<h1 class='mb-4'>Product Catalog</h1>
<div class='row g-4'>
<div class='col-lg-4 col-md-6'>
<div class='card h-100 shadow'>
<div class='card-body d-flex flex-column'>
<h5 class='card-title'>Product A</h5>
<p class='card-text flex-grow-1'>Modern flexbox-based card layout with Bootstrap 5.</p>
<button class='btn btn-primary mt-auto'>Learn More</button>
</div>
</div>
</div>
<div class='col-lg-4 col-md-6'>
<div class='card h-100 shadow'>
<div class='card-body d-flex flex-column'>
<h5 class='card-title'>Product B</h5>
<p class='card-text flex-grow-1'>Responsive grid adapts to screen size.</p>
<button class='btn btn-primary mt-auto'>Learn More</button>
</div>
</div>
</div>
<div class='col-lg-4 col-md-6'>
<div class='card h-100 shadow'>
<div class='card-body d-flex flex-column'>
<h5 class='card-title'>Product C</h5>
<p class='card-text flex-grow-1'>CSS3 features fully supported.</p>
<button class='btn btn-primary mt-auto'>Learn More</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(bootstrapHtml);
pdf.SaveAs("bootstrap-catalog.pdf");上述程式碼使用 IronPDF 渲染效果完美,保留了所有 Bootstrap 樣式、flexbox 佈局、陰影和響應式網格系統。
NReco.Pdf產生器:Bootstrap 支援有限
NReco.PdfGenerator 依賴使用舊版 Qt WebKit 引擎的 WkHtmlToPdf,而該引擎與現代 CSS 框架存在重大相容性問題:
-不支援 Flexbox: Bootstrap 4+ 嚴重依賴 Flexbox,而 Qt WebKit 不完全支援 Flexbox。
- CSS Grid 功能受限:現代網格佈局將無法正確渲染。 -已過時: Qt WebKit 上次更新是在 2016 年,缺乏對現代 CSS3 功能的支援。 -需要採取的變通方法:開發者必須使用舊版的 Bootstrap(Bootstrap 3 或更早版本)或實作基於表格的回退方案。
有關 CSS 框架支援和 flexbox/Bootstrap 渲染問題故障排除的更多詳細信息,請參閱Bootstrap 和 Flexbox CSS 指南。
結論
IronPDF 和 NReco.PdfGenerator 都是滿足您所有 HTML 轉 PDF 需求的有力競爭者。 但是,如果您需要一款除了 HTML 轉 PDF 之外還具有豐富內建功能的工具,那麼 IronPDF 就是您的理想之選。
IronPDF 擁有全面的功能集、簡單的學習曲線以及對現代 Web 標準和跨平台相容性的廣泛支持,將成為您工作空間的強大補充。 NReco.PdfGenerator 雖然能夠可靠地進行基本的 HTML 到 PDF 轉換,但它缺少 IronPDF 提供的許多高級功能。
您可以嘗試30 天免費試用,以了解其可用功能。
常見問題解答
如何在C#中將HTML轉換為PDF?
您可以使用 IronPDF 的RenderHtmlAsPdf方法將 HTML 字串轉換為 PDF。此外,IronPDF 還允許您使用RenderHtmlFileAsPdf方法將 HTML 檔案轉換為 PDF。
IronPDF 和 NReco.PdfGenerator 的主要差異是什麼?
IronPDF 提供豐富的功能,包括 HTML 轉 PDF、PDF 編輯、安全選項和數位簽名,是一款功能全面的 PDF 處理工具。相較之下,NReco.PdfGenerator 主要專注於使用 WkHtmlToPdf 工具進行 HTML 轉 PDF,高級功能較少。
我可以在不同的作業系統上使用這些PDF庫嗎?
是的,IronPDF 和 NReco.PdfGenerator 都支援跨平台相容性。 IronPDF 可在 Windows、Linux 和 macOS 上使用,並支援 .NET Core、.NET Standard 和 .NET Framework。同樣,NReco.PdfGenerator 也支援 Windows、Linux 和 macOS 平台。
IronPDF是否支援PDF加密和數位簽章?
是的,IronPDF 提供強大的 PDF 加密和數位簽章功能。這使得開發人員能夠保護其 PDF 文件並添加數位簽章以進行身份驗證。
IronPDF有哪些授權許可選項?
IronPDF 提供多種授權選項,包括 Lite 版、Plus 版和 Professional 版。此外,還有 Iron Suite 套件,可存取所有 Iron Software 產品,並提供 30 天免費試用期供用戶評估。
NReco.PdfGenerator 是否有免費版本?
是的,NReco.PdfGenerator 提供免費的線上 HTML 轉 PDF 轉換器。如需更進階的功能,可購買企業版原始碼套件。
哪個庫提供更好的支援和文件?
IronPDF 提供豐富的文件、影片教學、每週 5 天、每天 24 小時的客戶支援、社群論壇以及定期軟體更新。 NReco.PdfGenerator 提供 API 文件和支援聯絡方式。
IronPDF 能否將 DOCX 檔案轉換為 PDF 檔案?
是的,IronPDF 可以將 DOCX 檔案轉換為 PDF 格式,確保高品質並在轉換過程中保持文件的完整性。
使用 IronPDF 進行 HTML 轉 PDF 轉換有哪些優勢?
IronPDF 支援現代 Web 標準,可實現高保真 PDF 渲染,確保產生像素級精準的 PDF 檔案。它還包含 HTML 資源加載和全面的 PDF 安全設定等功能,使其成為 HTML 轉 PDF 的可靠選擇。
NReco.PdfGenerator 是否支援 PDF 內容編輯或浮水印等功能?
不,NReco.PdfGenerator 本身並不支援 PDF 內容編輯或浮水印功能。但是,IronPDF 內建了這些功能的支持,可以輕鬆地對 PDF 文件進行內容編輯和添加浮水印。
IronPDF 和 NReco.PdfGenerator 有哪些常見用例?
IronPDF 通常用於 HTML 轉 PDF、PDF 加密、數位簽章和編輯現有 PDF 檔案。 NReco.PdfGenerator 主要用於將 HTML 內容轉換為 PDF 格式。






