IronPDF與NReco .NET Core之間的比較
當您在處理PDF時,您會想要使用最適合您的專案需求的最佳工具,對吧? 但由於市場上有這麼多不同的PDF程式庫,選擇最適合您的可能很難。 今天,我們將仔細檢視兩個知名的PDF程式庫:IronPDF 和 NReco.PdfGenerator。
我們將比較其功能、相容性和整體性能,以幫助您做出明智的決定,選擇最適合您的程式庫。
IronPDF 和 NReco.PdfGenerator 簡介
IronPDF 是一個全面的 .NET 程式庫,擅長將HTML轉換為PDF,並提供豐富的功能集來處理PDF文件。 IronPDF 支援現代網頁標準,包括HTML5、CSS3和JavaScript,確保高保真的PDF生成。 它還旨在易於使用,提供直觀的API,能夠無縫整合到 .NET 應用程式中。
NReco.PdfGenerator for .NET 是一個專注於HTML到PDF轉換的程式庫。 它基於wkhtmltopdf命令行工具,依賴於舊版Qt WebKit渲染引擎從HTML內容建立PDF文件。 注意,Qt WebKit不再積極維護,對現代HTML5、CSS3和JavaScript功能的支援有限。 該程式庫因易於使用和快速整合到 .NET 項目中而聞名,只需一個已包含wkhtmltopdf二進制文件的 .NET 程式集。
跨平台相容性
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。
- IDEs: 支援如 Microsoft Visual Studio 和 JetBrains Rider & ReSharper 等 IDE。
- 作業系統和處理器: 支援多個不同的作業系統和處理器,包括Windows、Mac、Linux、x64、x86、ARM。
欲了解更多有關IronPDF相容性的資訊,請存取 IronPDF 功能頁面。
NReco.PdfGenerator
-
.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。 憑藉對現代Web標準的全面支持,您可以放心,IronPDF將一貫從您的HTML內容返回像素完美的PDFs。 IronPDF還可以從其他格式(如DOCX、圖像、RTF等)轉換PDF文件。
- PDF 生成: 使用 IronPDF,您可以從 URLs、ASPX 文件或 HTML 字串生成 PDF 文件。
- 安全功能: 使用 IronPDF,您可以始終確保任何敏感的 PDF 文件是安全的,得益於其安全功能。 使用IronPDF來加密您的PDF文件,設定密碼,並為您的PDF文件設定權限。
- PDF 編輯功能: 使用 IronPDF,您可以處理現有的 PDF 文件,輕鬆編輯和讀取 PDF 文件。 IronPDF提供編輯功能,如新增橫幅和頁腳,在PDF頁面上蓋上文字和圖像,在PDF中新增自定義水印,處理PDF表單,並拆分或合併PDF文件。
- 整合: 能夠無縫整合 ASP.NET 和 MVC 應用程式。
欲獲得IronPDF功能的完整列表,請存取IronPDF Features。
NReco.PdfGenerator 功能
- HTML 到 PDF 轉換: 使用 wkhtmltopdf 和舊版 Qt WebKit 引擎(對現代網頁標準支援有限)將 HTML、CSS 和基本的 JavaScript 轉換為 PDF。
- PDF 選項: 支援多種 PDF 選項,如頁面方向、大小、邊距和縮放。
- 範本: 支援頁眉、頁腳和頁碼的HTML範本。
- 內容合併: 將多個 HTML 頁面合併為單個 PDF。
- 輸出自訂化: 使用自訂字體和樣式自訂化 PDFs 的外觀。
- 部署: 使用 NReco.PdfGenerator.LT 可用於 Windows 和非 Windows 部署。
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");
Imports IronPdf
' Enable web security settings such as disabling local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate the renderer for creating PDFs
Dim renderer = New ChromePdfRenderer()
' Create a PDF from an HTML string using C#
Dim 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
Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "c:\site\assets\")
myAdvancedPdf.SaveAs("html-with-assets.pdf")
NReco.PdfGenerator Example:
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);
Imports System
Imports NReco.PdfGenerator
' Format HTML content with the current date and time
Private htmlContent = String.Format("<body>Hello world: {0}</body>", DateTime.Now)
' Instantiate the HTML to PDF converter
Private htmlToPdf = New HtmlToPdfConverter()
' Generate the PDF from the HTML content
Private pdfBytes = htmlToPdf.GeneratePdf(htmlContent)
IronPDF 感謝現代 Chromium 渲染引擎(Blink),提供高保真渲染,並完全支援 HTML5、CSS3 和 JavaScript。 使用 IronPDF 進行 HTML 到 PDF 轉換 時,您將能夠從 HTML 文件、網頁等建立像素完美的 PDF。 NReco.PdfGenerator 使用 wkhtmltopdf 與舊版 Qt WebKit 引擎,提供基本的 HTML 渲染,但對現代網頁標準的支援有限,可能無法達到 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");
Imports IronPdf
Imports System
' Open an encrypted file or 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
' 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");
Imports IronPdf
' Load the PDF document
Private pdf As PdfDocument = 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");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
' Instantiate the Chrome PDF Renderer
Private renderer As New ChromePdfRenderer()
' Render HTML as PDF
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>")
' Create X509Certificate2 object with the Exportable flag set
Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create PdfSignature object and sign the PDF document
Private 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的功能,但您可以使用第三方程式庫如iText來完成這一操作。
要獲取更多簽署範例,請參閱該主題的 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");
Imports IronPdf
' Instantiate the renderer and render a PDF from a URL
Private renderer = New ChromePdfRenderer()
Private 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");
Imports IronPdf
Imports IronPdf.Editing
' Instantiate the renderer and render a PDF from HTML
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create a text stamper and customize its settings
Private textStamper As New TextStamper() With {
.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");
Imports IronPdf
Imports IronPdf.Editing
Imports System
' Instantiate the renderer and render a PDF from HTML
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create an image stamper with specific settings
Private imageStamper As New ImageStamper(New Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg")) With {.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 需要外部程式庫,如 iText 或 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");
Imports IronPdf
' Instantiate the DOCX to PDF Renderer
Private renderer As New DocxToPdfRenderer()
' Render a DOCX file as PDF
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
' Save the converted PDF
pdf.SaveAs("pdfFromDocx.pdf")
NReco.PdfGenerator 範例: NReco.PdfGenerator 本身不支援 DOCX 至 PDF 的轉換。
using IronPDF,您可以只需幾行程式碼將您的 DOCX 文件轉換為 PDF 格式。 此工具簡化了實施過程,確保工作空間的高效而不犧牲所生成的PDF文件的質量。 使用 NReco.PdfGenerator 時無法執行 DOCX 到 PDF 的轉換,因該程式庫主要聚焦於 HTML 到 PDF 的轉換。 需要使用額外的程式庫如 Aspose.Words 來處理 DOCX 到 PDF 的轉換。
欲獲得更多 DOCX 到 PDF 的範例,請參閱該主題的 IronPDF 如何指南。
功能比較概要

定價與授權:IronPDF 與 NReco.PdfGenerator
IronPDF定價和許可
IronPDF 有不同的等級和額外功能來購買許可證。 開發者還可以購買 Iron Suite,該套件以兩個的價格提供存取 Iron Software 的所有產品。 如果您還沒準備好購買許可證,IronPDF 提供持續 30 天的免費試用。
-
永久授權:提供一系列永久授權,具體取決於您的團隊規模、專案需求和地點數量。 每種授權型別都附有電子郵件支援。
-
Lite 許可證: 此許可證費用為 $999,支持一名開發者、一個地點和一個項目。
-
Plus 許可證: 支援三名開發者、三個地點和三個項目,此許可證在 Lite 許可證的基礎上向上升級,費用為 $1,499。 Plus授權除了基本的電子郵件支援外,還提供聊天支援和電話支援。
-
Professional 許可證: 適合較大的團隊,支援十名開發者、十個地點和十個項目,費用為 $2,399。 與之前級別相同,該許可證提供了相同的聯繫支援通道,但還提供螢幕分享支援。
-
免版稅再分發: IronPDF 的授權提供免版稅再分發保障,額外費用為 $2,399。
-
不間斷產品支援: 存取待續的產品更新、安全功能升級以及來自工程團隊的支持,費用為 $1,499/年或一次性購買的 $2,399 五年保障。
- Iron Suite: 以 $2,998 的價格,您可以存取所有 Iron Software 產品,包括 IronPDF、IronOCR、IronWord、IronXL、IronBarcode、IronQR、IronZIP、IronPrint 和 IronWebScraper。

NReco.PdfGenerator
-
免費版本: NReco.PdfGenerator 提供免費的在線 HTML 到 PDF 轉換。
- Enterprise 源程式碼包: NReco 為 $199 提供 PDF Generator 企業源程式碼包,其中包括再分發的商業許可證、一年的電子郵件支援以及源程式碼 ZIP 文件的存取。
文件與支援:IronPDF 與 NReco.PdfGenerator
IronPDF
IronPDF在提供廣泛的文件和支援方面表現出色:
- 全面的文件:涵蓋所有功能的廣泛且使用者友好型文件。
- 24/5支持:提供活躍的工程師支援。
- 影片教程:提供循序漸進的YouTube影片指南。
- 社區論壇: 提供活躍的社區以獲得附加支援。
- 定期更新:每月產品更新以確保最新功能和安全補丁。
欲獲取更多資訊,請查看 IronPDF 的豐富 文件並存取 Iron Software YouTube 頻道。
NReco.PdfGenerator
- API 參考: 提供有關其API 的文件,以便您了解其不同方面如何運作。
- 聯繫方式: 在他們的網站上能輕鬆找到 NReco 團隊的所有聯繫資訊,以便在您有任何問題或疑問時輕鬆與他們取得聯繫。
現代CSS框架支持
IronPDF和NReco.PdfGenerator 之間的一個重要區別在於它們對現代 CSS 框架的支援,比如 Bootstrap,Tailwind CSS 和 Foundation。
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");
Imports IronPdf
' Render a Bootstrap 5 layout
Dim renderer As New ChromePdfRenderer()
' Example: Bootstrap responsive card grid
Dim bootstrapHtml 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 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>"
Dim pdf = renderer.RenderHtmlAsPdf(bootstrapHtml)
pdf.SaveAs("bootstrap-catalog.pdf")
以上程式碼在使用 IronPDF 時完美呈現,保留所有 Bootstrap 樣式、flexbox 佈局、陰影和響應式網格系統。
NReco.PdfGenerator:有限的 Bootstrap 支援
NReco.PdfGenerator 依賴於具有顯著的現代 CSS 框架限制的 wkhtmltopdf 和舊版 Qt WebKit 引擎:
- 無 flexbox 支持: Bootstrap 4+ 大量依賴 flexbox,而 Qt WebKit 並不完全支持
- 有限 CSS Grid:現代網格佈局將無法正確渲染
- 過時: Qt WebKit 最後一次更新是在2016年,缺乏對現代 CSS3 功能的支援
- 需要變通方法: 開發者必須使用較舊的 Bootstrap 版本(Bootstrap 3 或更早)或者實施基於表格的替代方案
有關CSS框架支援和Flexbox/Bootstrap渲染問題的故障排除的更多細節,參見Bootstrap & Flexbox CSS指導。
結論
IronPDF 和 NReco.PdfGenerator 都是滿足您所有 HTML 到PDF轉換需求的有力競爭者。 但是,如果您需要一個工具,除了 HTML 到 PDF 的轉換之外,還擁有豐富的內建功能集,那麼 IronPDF 就適合您。
憑藉全面的功能集、簡易的學習曲線以及擴展的現代網頁標準支持和跨平台相容性,IronPDF 將成為您工作空間中的強力附加。 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 提供廣泛的文件、影片教程、24/5 客戶支持、社區論壇以及定期的軟體更新。NReco.PdfGenerator 提供 API 文件和支持聯繫方式。
IronPDF 能夠將 DOCX 文件轉換為 PDF 嗎?
是的,IronPDF 可以將 DOCX 文件轉換為 PDF 格式,確保高質量並在轉換過程中保留文件的完整性。
使用IronPDF進行HTML到PDF轉換有什麼優勢?
IronPDF 支持現代網路標準的高仿真 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 格式。



