在生產環境中測試,無水印。
在任何需要的地方都能運行。
獲得 30 天的全功能產品。
在幾分鐘內上手運行。
試用產品期間完全訪問我們的支援工程團隊
在當今快速發展的環境中,選擇合適的工具從 HTML 生成 PDF,對於效率和輸出質量都可以產生顯著的影響。 此任務的兩個主要競爭者是 IronPDF 和 DocRaptor。 雖然兩個工具都旨在簡化將HTML轉換為PDF的過程,但它們提供不同的功能、定價模式以及與.NET和其他平台的整合水平。
在本文中,我們將深入比較IronPDF和DocRaptor,突顯其優勢、限制以及各自的最佳使用案例,幫助您決定哪個解決方案最適合您的專案需求。
IronPDF 提供廣泛的功能,用於在 .NET 應用程式中建立、編輯和管理 PDF 文件。 全面支持 HTML、CSS、JavaScript 和 C#,它为开发人员提供了一个高度可定制且强大的工具来处理 PDF。 該庫的設計以開發者友好為宗旨,提供優秀的文件記錄,確保在 .NET 環境中的快速部署和易於使用。
DocRaptor是一個基於雲端的解決方案,專注於提供PDF和Excel生成,並著重於網路應用程式和API整合。 使用Prince PDF引擎,DocRaptor支持多種程式語言,包括 .NET,並能夠將HTML轉換為PDF。 雖然該平台在基本的 PDF 生成方面表現出色,但需要網路連線以訪問其 API,並且缺乏 IronPDF 提供的相同級別的自訂和靈活性。
IronPDF 因其廣泛的跨平台相容性而脫穎而出。 它支持 .NET 框架內的多種環境,確保在不同平台上流暢運行。 以下是IronPDF平台相容性的摘要:
.NET 版本:
完全用 C# 編寫並支援 VB.NET 和 F#
.NET Core (8, 7, 6, 5, 和 3.1+)
作業系統和處理器:支援多種不同的作業系統和處理器,包括 Windows、Mac、Linux、x64、x86、ARM
如需有關 IronPDF 相容性的更多詳細資訊,請造訪IronPDF 相容性。
DocRaptor 提供強大的跨平台相容性和 .NET 版本支持,其中包括以下內容:
PDF 版本支持:可以支持 PDF 版本 1.2-1.7
如需完整的 IronPDF 功能列表,請造訪 IronPDF 功能。
DocRaptor 提供了一套全面的功能,用於可靠的 HTML 到 PDF 和 HTML 到 Excel 的轉換。 以下是其一些主要功能:
IronPDF:
// Html to pdf c# code
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
// Html to pdf c# code
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
' Html to pdf c# code
Imports IronPdf
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from an HTML string using C#
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>")
' Export to a file or Stream
pdf.SaveAs("output.pdf")
' Advanced Example with HTML Assets
Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
myAdvancedPdf.SaveAs("html-with-assets.pdf")
DocRaptor:
DocApi docraptor = new DocApi();
docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
try
{
Doc doc = new Doc(
name: "html-and-javascript",
test: true,
documentType: Doc.DocumentTypeEnum.Pdf,
documentContent: System.IO.File.ReadAllText(@"html-and-javascript-content.html"),
javascript: true
);
byte[] document = docraptor.CreateDoc(doc);
File.WriteAllBytes("html-and-javascript.pdf", document);
Console.WriteLine("Successfully created html-and-javascript.pdf!");
} catch (DocRaptor.Client.ApiException error) {
Console.Write(error.ErrorContent);
}
DocApi docraptor = new DocApi();
docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
try
{
Doc doc = new Doc(
name: "html-and-javascript",
test: true,
documentType: Doc.DocumentTypeEnum.Pdf,
documentContent: System.IO.File.ReadAllText(@"html-and-javascript-content.html"),
javascript: true
);
byte[] document = docraptor.CreateDoc(doc);
File.WriteAllBytes("html-and-javascript.pdf", document);
Console.WriteLine("Successfully created html-and-javascript.pdf!");
} catch (DocRaptor.Client.ApiException error) {
Console.Write(error.ErrorContent);
}
Dim docraptor As New DocApi()
docraptor.Configuration.Username = "YOUR_API_KEY_HERE"
Try
Dim doc As New Doc(name:= "html-and-javascript", test:= True, documentType:= Doc.DocumentTypeEnum.Pdf, documentContent:= System.IO.File.ReadAllText("html-and-javascript-content.html"), javascript:= True)
Dim document() As Byte = docraptor.CreateDoc(doc)
File.WriteAllBytes("html-and-javascript.pdf", document)
Console.WriteLine("Successfully created html-and-javascript.pdf!")
Catch [error] As DocRaptor.Client.ApiException
Console.Write([error].ErrorContent)
End Try
IronPDF 輕鬆處理HTML 到 PDF 的轉換,完全支援現代網頁標準,確保所有的 PDF 文件都達到像素完美。 DocRaptor 使用基於 API 的方法,需要 API 密鑰和基於雲的執行來將 HTML 轉換為 PDF。
IronPDF:
using IronPdf;
using System;
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
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;
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
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
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
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")
DocRaptor:DocRaptor 原生不支援 PDF 加密功能。
IronPDF 提供內建的加密功能、元數據和安全控制,而 DocRaptor 則需要第三方工具才能實現類似功能。
IronPDF:
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
pdf.RedactTextOnAllPages("are")
pdf.SaveAs("redacted.pdf")
DocRaptor不支援遮蔽功能。
IronPDF 提供原生遮罩,這是一個 DocRaptor 缺乏的重要功能,特別適用於法律和機密文件。
IronPDF:
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>")
Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create PdfSignature object
Private sig = New PdfSignature(cert)
' Sign PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")
DocRaptor 不原生支援 PDF 簽名。
IronPDF 提供內建機制來數位簽署PDF,使其在驗證和法律文件方面具有優勢。 DocRaptor 缺少此關鍵功能,因此使用此庫的用戶需要下載其他庫才能執行此任務。
IronPDF:
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
Imports IronPdf
' Stamps a Watermark onto a new or existing PDF
Private renderer = New ChromePdfRenderer()
Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
pdf.SaveAs("C:\Path\To\Watermarked.pdf")
DocRaptor:
using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System;
using System.IO;
class DocRaptorExample
{
static void Main(string[] args)
{
DocApi docraptor = new DocApi();
docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
try
{
Doc doc = new Doc(
name: "text-based-watermark",
test: false, // test documents are free but watermarked
documentType: Doc.DocumentTypeEnum.Pdf,
documentContent: System.IO.File.ReadAllText(@"text-based-watermark-content.html")
);
byte[] document = docraptor.CreateDoc(doc);
File.WriteAllBytes("text-based-watermark.pdf", document);
Console.WriteLine("Successfully created text-based-watermark.pdf!");
} catch (DocRaptor.Client.ApiException error) {
Console.Write(error.ErrorContent);
}
}
}
using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System;
using System.IO;
class DocRaptorExample
{
static void Main(string[] args)
{
DocApi docraptor = new DocApi();
docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
try
{
Doc doc = new Doc(
name: "text-based-watermark",
test: false, // test documents are free but watermarked
documentType: Doc.DocumentTypeEnum.Pdf,
documentContent: System.IO.File.ReadAllText(@"text-based-watermark-content.html")
);
byte[] document = docraptor.CreateDoc(doc);
File.WriteAllBytes("text-based-watermark.pdf", document);
Console.WriteLine("Successfully created text-based-watermark.pdf!");
} catch (DocRaptor.Client.ApiException error) {
Console.Write(error.ErrorContent);
}
}
}
Imports DocRaptor.Client
Imports DocRaptor.Model
Imports DocRaptor.Api
Imports System
Imports System.IO
Friend Class DocRaptorExample
Shared Sub Main(ByVal args() As String)
Dim docraptor As New DocApi()
docraptor.Configuration.Username = "YOUR_API_KEY_HERE"
Try
Dim doc As New Doc(name:= "text-based-watermark", test:= False, documentType:= Doc.DocumentTypeEnum.Pdf, documentContent:= System.IO.File.ReadAllText("text-based-watermark-content.html"))
Dim document() As Byte = docraptor.CreateDoc(doc)
File.WriteAllBytes("text-based-watermark.pdf", document)
Console.WriteLine("Successfully created text-based-watermark.pdf!")
Catch [error] As DocRaptor.Client.ApiException
Console.Write([error].ErrorContent)
End Try
End Sub
End Class
IronPDF 提供完整的浮水印功能,使您只需幾行代碼即可創建和應用自訂浮水印,且這些浮水印可應用於新的或現有的 PDF 文件。 然而,DocRaptor 要求在將 HTML 內容轉換為 PDF 之前,使用 HTML 和 CSS 添加浮水印。
IronPDF:
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create text stamper
Private textStamper As New TextStamper() With {
.Text = "Text Stamper!",
.FontFamily = "Bungee Spice",
.UseGoogleFont = True,
.FontSize = 30,
.IsBold = True,
.IsItalic = True,
.VerticalAlignment = VerticalAlignment.Top
}
' Stamp the text stamper
pdf.ApplyStamp(textStamper)
pdf.SaveAs("stampText.pdf")
DocRaptor 缺乏在 PDF 上添加文字和图像水印的本地功能。
IronPDF 在進行文字和圖像加蓋時允許詳細的自訂,使其成為文件註釋和品牌標識的上佳選擇。 DocRaptor lacks any native support for text and image stamping, with watermarks being the closest thing to this.
IronPDF:
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
Imports IronPdf
' Instantiate Renderer
Private renderer As New DocxToPdfRenderer()
' Render from DOCX file
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
' Save the PDF
pdf.SaveAs("pdfFromDocx.pdf")
DocRaptor:
原生不支援DOCX轉換為PDF。
IronPDF 提供了更順暢且更原生的DOCX 到 PDF轉換過程,無需使用像 DocRaptor 這樣不具備內建支持此任務的外部庫。
要了解 IronPDF 提供的豐富功能集並查看其實際操作,請查看 IronPDF 操作指南,深入探索每個功能,瞭解其運作原理,助您掌握成為 PDF 專家的技能。
IronPDF 有不同的等級和附加功能可供購買授權。 開發人員還可以購買Iron Suite,這使您能以兩個產品的價格訪問 Iron Software 的所有產品。 如果您尚未準備好購買許可,IronPDF 提供免費試用,讓您在決定購買許可之前探索其所有功能。
Iron Suite:只需 $1,498,即可獲得所有 Iron Software 產品的使用權,包括IronPDF、IronOCR、IronWord、IronXL、IronBarcode、IronQR、IronZIP、IronPrint,以及IronWebScraper。
DocRaptor 根據使用情況提供多種定價選項。 起始價格為每月 15 美元,這是基於用量的,也就是說,隨著您生成文件的數量增加,成本會相應增加。 他們還提供免費試用,讓您在承諾付費計劃之前測試服務。
IronPDF 在提供廣泛的文檔和支援方面表現出色:
PDF API 參考: 提供 API 參考資料,讓您可以充分利用我們工具的所有功能。
如需更多資訊,請查看 IronPDF 詳細的文件,並訪問Iron Software YouTube 頻道。
總之,IronPDF 和 DocRaptor 都提供了強大的從 HTML 生成 PDF 的解決方案,但它們面向不同的受眾和專案需求。 IronPDF 在與 .NET 環境的無縫整合方面表現出色,提供多種自訂選項和離線處理功能。 這是針對在 .NET 框架內工作的開發人員設計的,這些開發人員需要對 PDF 的創建和操作進行精確控制。 另一方面,DocRaptor以其基於雲端的模型脫穎而出,確保符合PDF/A標準,並提供簡單的API以供跨平台使用,這使其成為需要在多個編程語言中進行可靠且可擴展的文檔生成項目的絕佳選擇。
最終,您在選擇 IronPDF 和 DocRaptor 時,應考慮您的開發技術棧、所需的控制程度,以及您偏好使用雲端解決方案還是本地部署解決方案。