IronPDF與NReco .NET Core之間的比較
當您處理 PDF 時,您一定希望使用最適合您專案需求的工具,對吧? 但市面上有這麼多不同的 PDF 函式庫,您很難決定哪一個最適合您。 今天,我們將進一步了解兩個著名的 PDF 函式庫:IronPDF 和 NReco.PdfGenerator。
我們會比較它們的功能、相容性和整體效能,以協助您做出明智的決定,決定哪一個函式庫可能最適合您。
IronPDF。 和 NReco.PdfGenerator 的概述
IronPDF是一個全面的 .NET 函式庫,擅長將 HTML 轉換為 PDF,並提供廣泛的功能來處理 PDF 檔案。 IronPDF 支援現代網路標準,包括 HTML5、CSS3 和 JavaScript,可確保高逼真度的 PDF 生成。 它的設計也要方便使用者,提供可與 .NET 應用程式無縫整合的直覺式 API。
NReco.PdfGenerator for .NET 是一個專注於 HTML 至 PDF 轉換的函式庫。 它以 WkHtmlToPdf 指令列工具為基礎,並依賴傳統的 Qt WebKit 渲染引擎,從 HTML 內容建立 PDF 文件。 請注意,Qt WebKit 已不再積極維護,且對現代 HTML5、CSS3 與 JavaScript 功能的支援有限。 這個函式庫以易用和快速整合至 .NET 專案而聞名,只需要一個已包含 WkHtmlToPdf 二進位檔的 .NET 程序集。
跨平台相容性
IronPDF。
IronPDF 以其廣泛的跨平台相容性脫穎而出。 它支援 .NET Framework 內的多種環境,確保在不同平台上的無縫操作。 以下是 IronPDF 的平台兼容性摘要:
-
.NET版本:
- 完全以 C#、VB.NET 和 F# 撰寫,並支援這些語言。
- .NET Core(8、7、6、5 和 3.1+)
- .NET 標準 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.PdfGenerator
-
.NET版本:
- .NET 標準 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 完全支援現代網路標準,因此您可以放心,IronPDF 將持續從您的 HTML 內容傳回像素完美的 PDF。 IronPDF 也可以轉換其他格式的 PDF 檔案,例如 DOCX、圖片、RTF 等。
- PDF 生成:使用 IronPDF,您可以從 URL、ASPX 文件或 HTML 字符串生成 PDF 文件。
- 安全功能:借助 IronPDF 的安全功能,您可以始终确保任何敏感 PDF 文件的安全。 使用 IronPDF 加密您的 PDF 檔案、設定密碼,以及為 PDF 檔案設定權限。
- PDF 編輯功能:使用 IronPDF,您可以處理現有的 PDF 文件、編輯文件,並輕鬆讀取 PDF 文件。 IronPDF 提供的編輯功能包括新增頁首和頁尾,在 PDF 頁面上印製文字和圖片,在 PDF 上新增自訂水印,處理 PDF 表單,以及分割或合併 PDF 檔案。
- 整合:與 ASP.NET 和 MVC 應用程式無縫整合。
如需 IronPDF 功能的完整清單,請造訪 IronPDF功能。
NReco.PdfGenerator 功能
- HTML 至 PDF 轉換: 使用 WkHtmlToPdf 和傳統 Qt WebKit 引擎(對現代 Web 標準的支援有限)將 HTML、CSS 和基本 JavaScript 轉換為 PDF。
- PDF 選項:支援各種 PDF 選項,如頁面方向、大小、邊緣和縮放。
- 範本:頁眉、頁腳和頁碼的 HTML 範本。
- 內容合併:將多個 HTML 頁面合併為單一 PDF。
- 輸出自訂:使用自訂字型和樣式自訂 PDF 的外觀。
- 部署:可使用 NReco.PdfGenerator.LT 進行 Windows 和非 Windows 部署。
IronPDF vs. 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範例:
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 為 加密 PDFs 提供了一個簡單直接但功能強大的工具。 使用 IronPDF,您可以完全控制整個過程,包括設定安全設定。 然而,NReco.PdfGenerator 缺乏原生加密功能,因此如果您想在使用 NReco.PdfGenerator 轉換 PDF 檔案後對其進行加密,則需要使用其他可處理 PDF 加密的函式庫。
如需更多加密範例,請造訪此主題的 IronPDF How-To Guide 。
重制 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 有關此主題的 How-To 指南。
簽署 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 數位簽章的支援,但您可以利用第三方函式庫,例如 iTextSharp 來進行簽章。
如需更多簽名範例,請造訪 IronPDF How-To 相關指南。
將水印套用至 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 本身不支援水印。
在使用 IronPDF 的 水印工具時,熟悉 HTML 和 CSS 可以提升您的使用體驗。 您可以完全控制水印製作過程。 水印控制的直覺性和易學性將讓您在短時間內感到精通。
如果您正在使用 NReco.PdfGenerator,並且想要在新轉換的 PDF 檔案上加上水印,您將需要安裝一個外部函式庫,例如 PDFSharp。
如需瞭解更多水印範例,請造訪 IronPDF How-To 相關指南。
在 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 需要使用 iTextSharp 或 PDFSharp 等外部函式庫,才能在新轉換的 PDF 文件上標示文字和影像。
如需更多圖章範例,請造訪 IronPDF How-To 相關指南。
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 的轉換。
使用 IronPDF,您只需幾行程式碼就能將 DOCX 檔案轉換成 PDF 格式。 此工具可簡化實作流程,確保有效率的工作空間,且不會犧牲所產生 PDF 檔案的品質。 使用 NReco.PdfGenerator,您無法執行 DOCX 至 PDF 的轉換,因為該函式庫主要著重於 HTML 至 PDF 的轉換。 您將需要一個額外的函式庫,例如 Apsose.Words 來處理 DOCX 到 PDF 的轉換。
如需更多 DOCX 轉 PDF 的範例,請造訪 IronPDF How-To 相關指南。
功能比較摘要
。
定價與授權:IronPDF vs. NReco.PdfGenerator
IronPDF。 定價與授權
IronPDF 有不同等級和購買授權的附加功能。 開發人員也可以購買 Iron Suite,以兩件產品的價格即可使用 Iron Software 的所有產品。 如果您尚未準備好購買授權,IronPDF 提供 免費試用,為期 30 天。
-
永久授權:根據您的團隊規模、專案需求和地點數量,提供一系列永久授權。 每種授權類型都附有電子郵件支援。
-
Lite 許可證:此許可證價格為 $999,支援一名開發者、一個地點和一個專案。
- Plus 許可證:支援三個開發者、三個地點和三個項目,這是比精簡版許可證更高一級的許可證,費用為 $1,499。 Plus License 除了提供基本的電子郵件支援外,還提供聊天支援和電話支援。
-專業許可證:適用於更大的團隊,支援十名開發人員、十個地點和十個項目,適用於 $2,999。 它提供與前幾層相同的聯絡支援管道,但也提供螢幕分享支援。
-免版稅再分發: IronPDF 的許可提供免版稅再分發保障,需額外支付 $2,999。
-不間斷的產品支援:可獲得持續的產品更新、安全功能升級以及工程團隊的支持,費用為每年 $1,499,或一次性購買 $2,999 即可獲得 5 年的保障。
- Iron Suite:對於 $1,498,您可以存取所有 Iron Software 產品,包括 IronPDF、IronOCR、IronWord、IronXL、IronBarcode、IronQR、IronZIP、IronPrint 和 IronWebScraper。
。
NReco.PdfGenerator
-
免費版本: NReco.PdfGenerator 提供免費的線上 HTML 至 PDF 轉換器。
- 企業級原始碼包: NReco 以 199 美元的價格提供 PDF Generator 企業級原始碼包,其中包括一份用於再散佈的商業授權、進階 API/NReco.PdfGenerator LT NuGet 套件版本的授權金鑰、一年的電子郵件支援,以及存取原始碼 ZIP 檔案的權限。
文件和支援:IronPDF vs. NReco.PdfGenerator
IronPDF。
IronPDF 擅長於提供廣泛的文件和支援:
- 全面的說明文件: 涵蓋所有功能的廣泛且易於使用的說明文件。
- 24/5支援:提供積極的工程師支援。
- 視訊教學:YouTube 上提供了分步視訊指南。
- 社群論壇:提供額外支援的參與社群。
- 定期更新:每月進行產品更新,以確保提供最新的功能和安全修補程式。
如需更多資訊,請參閱 IronPDF 廣泛的 說明文件,並造訪 Iron Software YouTube 頻道。
NReco.PdfGenerator
- API Reference: 提供有關其 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 依賴 WkHtmlToPdf 與傳統的 Qt WebKit 引擎,此引擎在現代 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 功能全面、易學易用,並廣泛支援現代網路標準和跨平台相容性,將成為您工作區的強大補充品。 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 Software 產品訪問權限的 Iron Suite,並提供 30 天免費試用供評估。
NReco.PdfGenerator 有免費版本嗎?
是的,NReco.PdfGenerator 提供免費的在線 HTML 到 PDF 轉換器。對於更廣泛的使用,可購買企業源代碼包。
哪個庫提供更好的支持和文檔?
IronPDF 提供廣泛的文檔、視頻教程、24/5 客戶支持、社區論壇和軟件定期更新。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 加密、數位簽名以及編輯現有 PDFs。NReco.PdfGenerator 主要用於將 HTML 內容轉換為 PDF 格式。

