IronPDF與Docraptor - 全面比較
在當今快速發展的環境中,選擇正確的工具來從HTML生成PDF可以在效率和輸出質量上產生顯著的差異。 這項任務的兩個主要競爭者是IronPDF和DocRaptor。 儘管這兩個工具都旨在簡化將HTML轉換為PDF的過程,但它們提供不同的功能、定價模式和.NET及其他平台的整合等級。
在本文中,我們將深入比較IronPDF和DocRaptor,強調它們的優勢、限制,以及每個的最佳使用案例,幫助您決定哪個解決方案最適合您的專案需求。
IronPDF和DocRaptor概述
IronPDF提供了廣泛的功能,用於在.NET應用程式中建立、編輯和管理PDF。 借助對HTML、CSS、JavaScript和C#的全面支援,它為開發人員提供了一個高度可定制且強大的工具來處理PDF。 這個程式庫設計為開發者友好,具備出色的文件,確保在.NET環境中的快速部署和易用性。
DocRaptor是一個基於雲的解決方案,提供PDF和Excel生成,側重於Web應用程式和API整合。 使用Prince PDF引擎,DocRaptor支持多種程式語言,包括.NET,並能將HTML轉換為PDF。 儘管該平台在基本的PDF生成方面表現出色,但它需要網路連接才能存取其API,並缺乏IronPDF所提供的相同定製和靈活性等級。
跨平台相容性
IronPDF
IronPDF因其廣泛的跨平台相容性而脫穎而出。 它支持.NET框架中的多種環境,確保在不同平台間的無縫運行。 以下是IronPDF平台相容性的概要:
-
.NET版本:
- 完全用C#、VB.NET和F#編寫,並支持這些語言
- .NET Core (8, 7, 6, 5, and 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 Compatibility。
DocRaptor
DocRaptor提供穩健的跨平台相容性和.NET版本支持,包括以下內容:
- Windows: DocRaptor在Windows環境中無縫運行,與.NET及其他常見開發堆棧整合良好。
- Linux: DocRaptor可用於基於Linux的環境,使其適合伺服器端PDF生成任務。
- macOS: 使用macOS的開發人員可以將DocRaptor整合到他們的開發管道中,無需任何問題。
- .NET Core: DocRaptor支持.NET Core,為在最新.NET生態系統中工作的開發人員提供現代、跨平台的能力。
- .NET Framework: 它還與傳統的.NET Framework相容,允許建於遺留系統的專案從中受益的PDF生成功能。
- .NET 5及更高版本: DocRaptor與.NET 5及更高版本相容,確保在更新的.NET版本上工作的開發人員在使用該庫時不會遇到相容性問題。
關鍵功能比較:IronPDF vs. DocRaptor的PDF功能
IronPDF
-
PDF轉換: IronPDF可以將HTML轉換為PDF。 憑藉對現代Web標準的全面支持,您可以放心,IronPDF將一貫從您的HTML內容返回像素完美的PDFs。 IronPDF還可以從其他格式(如DOCX、圖像、RTF等)轉換PDF文件。
-
PDF生成: 使用IronPDF,您可以從URL、ASPX文件或HTML字串生成PDF。
-
安全功能: 使用IronPDF,您可以放心任何敏感的PDF文件都是安全的,這是由於其安全功能。 使用IronPDF來加密您的PDF文件,設定密碼,並為您的PDF文件設定權限。
-
PDF編輯功能: 使用IronPDF,您可以輕鬆地處理現有的PDF文件,編輯它們,並閱讀PDF文件。 IronPDF提供編輯功能,如新增橫幅和頁腳,在PDF頁面上蓋上文字和圖像,在PDF中新增自定義水印,處理PDF表單,並拆分或合併PDF文件。
-
整合: 無縫整合ASP.NET和MVC應用程式。
- PDF版本支持: 能支持PDF版本1.2-1.7
欲獲得IronPDF功能的完整列表,請存取IronPDF Features。
DocRaptor
DocRaptor提供了一套設計用於可靠的HTML到PDF和HTML到Excel轉換的全面功能。 以下是其中一些關鍵功能:
-
準確渲染: 支援HTML5、CSS3、JavaScript和SVG,確保現代網頁的準確PDF渲染。
-
JavaScript執行: 在轉換之前處理JavaScript,允許動態內容在生成的PDF中正確顯示。
-
響應式設計支持: 支援媒體查詢,允許響應式設計適應PDF的大小。
-
Excel導出: 將HTML表轉換為Excel電子表格(.xlsx),適用於報告生成或導出結構化資料。
- 單元格格式化: 保留Excel輸出的單元格樣式、字體和其他格式選項。
IronPDF與DocRaptor的頂級亮點功能與程式碼範例比較
1. 將HTML轉換為PDF
IronPDF:
// Convert HTML to PDF using IronPDF
using IronPdf;
// Enable web security to prevent local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate the PDF renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string
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");
// Convert HTML to PDF using IronPDF
using IronPdf;
// Enable web security to prevent local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate the PDF renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string
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");
' Convert HTML to PDF using IronPDF
Imports IronPdf
' Enable web security to prevent local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate the PDF renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from an HTML string
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:
using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System;
using System.IO;
// Example of using DocRaptor to convert HTML and JavaScript to PDF
DocApi docraptor = new DocApi();
docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
try
{
Doc doc = new Doc(
name: "html-and-javascript",
test: true, // Test flag to indicate trial mode
documentType: Doc.DocumentTypeEnum.Pdf, // Specify document type
documentContent: System.IO.File.ReadAllText(@"html-and-javascript-content.html"), // Load HTML content from file
javascript: true // Enable JavaScript execution
);
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);
}
using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System;
using System.IO;
// Example of using DocRaptor to convert HTML and JavaScript to PDF
DocApi docraptor = new DocApi();
docraptor.Configuration.Username = "YOUR_API_KEY_HERE";
try
{
Doc doc = new Doc(
name: "html-and-javascript",
test: true, // Test flag to indicate trial mode
documentType: Doc.DocumentTypeEnum.Pdf, // Specify document type
documentContent: System.IO.File.ReadAllText(@"html-and-javascript-content.html"), // Load HTML content from file
javascript: true // Enable JavaScript execution
);
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);
}
Imports DocRaptor.Client
Imports DocRaptor.Model
Imports DocRaptor.Api
Imports System
Imports System.IO
' Example of using DocRaptor to convert HTML and JavaScript to PDF
Private 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的轉換,並對現代Web標準的全面支持確保所有的PDF文件都是像素完美的。 DocRaptor採用基於API的方法,需要API密鑰和基於雲的執行來將HTML轉換為PDF。
2. 加密PDF文件
IronPDF:
using IronPdf;
using System;
// Load an existing PDF with a password
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;
// Load an existing PDF with a password
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
' Load an existing PDF with a password
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加密功能。
3. 編輯PDF內容
IronPDF:
using IronPdf;
// Load the PDF and redact specified text
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
using IronPdf;
// Load the PDF and redact specified text
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
Imports IronPdf
' Load the PDF and redact specified text
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
pdf.RedactTextOnAllPages("are")
pdf.SaveAs("redacted.pdf")
DocRaptor不支持編輯功能。
IronPDF提供原生編輯,這是法律和機密文件的重要功能,DocRaptor無法提供。
4. 為PDF文件進行數位簽名
IronPDF:
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Initialize PDF renderer and create a PDF document
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Load the certificate for signing
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create a PdfSignature object
var sig = new PdfSignature(cert);
// Sign the PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Initialize PDF renderer and create a PDF document
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Load the certificate for signing
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create a PdfSignature object
var sig = new PdfSignature(cert);
// Sign the PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
' Initialize PDF renderer and create a PDF document
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>")
' Load the certificate for signing
Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create a PdfSignature object
Private sig = New PdfSignature(cert)
' Sign the PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")
DocRaptor本身不支持PDF簽名。
IronPDF提供內建的機制來數位簽名PDF,這使得它在身份驗證和法律文件上更為優越。 DocRaptor缺乏這個關鍵功能,因此其使用者需要下載額外的庫來執行這項任務。
5. 應用自定義水印
IronPDF:
using IronPdf;
// Stamper to apply a watermark on a 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;
// Stamper to apply a watermark on a 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
' Stamper to apply a watermark on a 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新增水印。
6. 蓋印文字和圖像
IronPDF:
using IronPdf;
using IronPdf.Editing;
// Initialize PDF renderer and create a basic HTML-based PDF
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create a text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Apply the text stamper to the PDF
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
using IronPdf;
using IronPdf.Editing;
// Initialize PDF renderer and create a basic HTML-based PDF
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create a text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Apply the text stamper to the PDF
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
Imports IronPdf
Imports IronPdf.Editing
' Initialize PDF renderer and create a basic HTML-based PDF
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create a 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
}
' Apply the text stamper to the PDF
pdf.ApplyStamp(textStamper)
pdf.SaveAs("stampText.pdf")
DocRaptor缺乏在PDF上蓋印文字和圖像的原生功能。
IronPDF允許在蓋印文字和圖像時進行詳細自定義,使其在文件註釋和品牌化方面是一個更好的選擇。 DocRaptor無法提供任何蓋印文字和圖像的原生支持,水印是與之最接近的功能。
7. DOCX to PDF
IronPDF:
using IronPdf;
// Instantiate a renderer specifically for DOCX files
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render a PDF document from a DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the resulting PDF
pdf.SaveAs("pdfFromDocx.pdf");
using IronPdf;
// Instantiate a renderer specifically for DOCX files
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render a PDF document from a DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the resulting PDF
pdf.SaveAs("pdfFromDocx.pdf");
Imports IronPdf
' Instantiate a renderer specifically for DOCX files
Private renderer As New DocxToPdfRenderer()
' Render a PDF document from a DOCX file
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
' Save the resulting PDF
pdf.SaveAs("pdfFromDocx.pdf")
DocRaptor:
沒有本地支持DOCX轉PDF的功能。
IronPDF提供了一個更流暢和本地的DOCX轉PDF的過程,無需任何外部庫,而DocRaptor無法為此任務提供本地支持。
程式碼範例比較總結

要了解IronPDF提供的豐富功能,並看到它們的實際應用,請查看IronPDF的如何開始指南,深入探討每個功能,探索它們的工作原理,並賦予您成為PDF專家的技能。
Bootstrap和現代CSS框架渲染支持
用CSS框架如Bootstrap、Tailwind和Foundation構建的現代Web應用程式需要PDF生成工具來準確保留這些框架的佈局。 這種能力對於在Web和PDF產出間保持設計一致性至關重要。
IronPDF:本地Bootstrap和框架支持
IronPDF的Chromium引擎提供對所有現代CSS框架的完整支持:
- Bootstrap 5: 提供完整彈性盒和CSS網格支持,以及所有響應式工具
- Bootstrap 4: 提供完整卡片系統、導航和表單組件
- Tailwind CSS: 所有實用類和響應式修飾符
- Foundation: 全面支持網格和組件系統
- 現代CSS3: 提供彈性盒、網格、自定義屬性、動畫和變換
- JavaScript支持: 提供完整執行以實現框架互動性
真實世界驗證:Bootstrap首頁和官方模板均已按照瀏覽器準確轉換。
程式碼範例:FAQ手風琴與Bootstrap
using IronPdf;
var renderer = new ChromePdfRenderer();
string bootstrapFAQ = @"
<!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'>Frequently Asked Questions</h1>
<div class='row'>
<div class='col-lg-8 mx-auto'>
<div class='accordion' id='faqAccordion'>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button' type='button'>
What file formats do you support?
</button>
</h2>
<div class='accordion-collapse collapse show'>
<div class='accordion-body'>
<strong>We support a wide range of formats:</strong> HTML, URL-based conversion, image to PDF,
DOCX to PDF, and more. Our Chromium engine ensures accurate rendering of modern web standards.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
Do you support responsive designs?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
Yes! Our rendering engine fully supports responsive CSS frameworks including Bootstrap, Tailwind,
and custom responsive designs. You can specify viewport dimensions and paper sizes to control output.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
What about JavaScript rendering?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
<div class='alert alert-info mb-3'>
<strong>Full JavaScript Support:</strong> IronPDF executes JavaScript before PDF generation.
</div>
You can configure render delays to ensure dynamic content loads completely. This includes AJAX calls,
React/Vue/Angular components, and dynamic chart libraries.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
How does pricing work?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
We offer transparent per-developer licensing starting at competitive rates. No per-document fees,
no hidden costs. Pricing includes all features, updates, and support for one year.
<a href='/licensing/' class='btn btn-sm btn-primary mt-2'>View Pricing Details</a>
</div>
</div>
</div>
</div>
<div class='card mt-5 bg-light'>
<div class='card-body'>
<h5 class='card-title'>Still have questions?</h5>
<p class='card-text'>Our support team is here to help you get started.</p>
<a href='#' class='btn btn-primary'>Contact Support</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(bootstrapFAQ);
pdf.SaveAs("faq-page.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
string bootstrapFAQ = @"
<!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'>Frequently Asked Questions</h1>
<div class='row'>
<div class='col-lg-8 mx-auto'>
<div class='accordion' id='faqAccordion'>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button' type='button'>
What file formats do you support?
</button>
</h2>
<div class='accordion-collapse collapse show'>
<div class='accordion-body'>
<strong>We support a wide range of formats:</strong> HTML, URL-based conversion, image to PDF,
DOCX to PDF, and more. Our Chromium engine ensures accurate rendering of modern web standards.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
Do you support responsive designs?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
Yes! Our rendering engine fully supports responsive CSS frameworks including Bootstrap, Tailwind,
and custom responsive designs. You can specify viewport dimensions and paper sizes to control output.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
What about JavaScript rendering?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
<div class='alert alert-info mb-3'>
<strong>Full JavaScript Support:</strong> IronPDF executes JavaScript before PDF generation.
</div>
You can configure render delays to ensure dynamic content loads completely. This includes AJAX calls,
React/Vue/Angular components, and dynamic chart libraries.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
How does pricing work?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
We offer transparent per-developer licensing starting at competitive rates. No per-document fees,
no hidden costs. Pricing includes all features, updates, and support for one year.
<a href='/licensing/' class='btn btn-sm btn-primary mt-2'>View Pricing Details</a>
</div>
</div>
</div>
</div>
<div class='card mt-5 bg-light'>
<div class='card-body'>
<h5 class='card-title'>Still have questions?</h5>
<p class='card-text'>Our support team is here to help you get started.</p>
<a href='#' class='btn btn-primary'>Contact Support</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(bootstrapFAQ);
pdf.SaveAs("faq-page.pdf");
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim bootstrapFAQ 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 my-5'>
<h1 class='text-center mb-5'>Frequently Asked Questions</h1>
<div class='row'>
<div class='col-lg-8 mx-auto'>
<div class='accordion' id='faqAccordion'>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button' type='button'>
What file formats do you support?
</button>
</h2>
<div class='accordion-collapse collapse show'>
<div class='accordion-body'>
<strong>We support a wide range of formats:</strong> HTML, URL-based conversion, image to PDF,
DOCX to PDF, and more. Our Chromium engine ensures accurate rendering of modern web standards.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
Do you support responsive designs?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
Yes! Our rendering engine fully supports responsive CSS frameworks including Bootstrap, Tailwind,
and custom responsive designs. You can specify viewport dimensions and paper sizes to control output.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
What about JavaScript rendering?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
<div class='alert alert-info mb-3'>
<strong>Full JavaScript Support:</strong> IronPDF executes JavaScript before PDF generation.
</div>
You can configure render delays to ensure dynamic content loads completely. This includes AJAX calls,
React/Vue/Angular components, and dynamic chart libraries.
</div>
</div>
</div>
<div class='accordion-item'>
<h2 class='accordion-header'></h2>
<button class='accordion-button collapsed' type='button'>
How does pricing work?
</button>
</h2>
<div class='accordion-collapse collapse'>
<div class='accordion-body'>
We offer transparent per-developer licensing starting at competitive rates. No per-document fees,
no hidden costs. Pricing includes all features, updates, and support for one year.
<a href='/licensing/' class='btn btn-sm btn-primary mt-2'>View Pricing Details</a>
</div>
</div>
</div>
</div>
<div class='card mt-5 bg-light'>
<div class='card-body'>
<h5 class='card-title'>Still have questions?</h5>
<p class='card-text'>Our support team is here to help you get started.</p>
<a href='#' class='btn btn-primary'>Contact Support</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>"
Dim pdf = renderer.RenderHtmlAsPdf(bootstrapFAQ)
pdf.SaveAs("faq-page.pdf")
輸出: 一個專業的FAQ頁面,配上Bootstrap的手風琴組件、警示框、卡片樣式及響應式網格—all準確地在PDF中渲染。
DocRaptor:良好的Bootstrap支持及API複雜度
DocRaptor是一個基於雲的服務,使用Prince XML渲染引擎,具有良好的CSS支持:
- Bootstrap 4/5支持: 一般對Bootstrap佈局的支持都很好
- Prince XML引擎: 專業級的HTML/CSS渲染引擎
- CSS3特性: 強大的彈性盒和現代CSS支持
- JavaScript限制: 相對於完整瀏覽器,JavaScript執行有限
- 雲依賴性: 需透過網路連通性及API呼叫來進行所有轉換
DocRaptor的關鍵考量點:
- 基於API: 所有轉換皆透過HTTP API呼叫至DocRaptor伺服器進行
- 需要網路: 無法在離線或氣隙環境中生成PDF
- 按文件定價: 不同於IronPDF的每開發者授權,DocRaptor按文件計費
- 資料隱私: 將HTML內容傳送至外部伺服器進行處理
- 大量成本: 高流量應用程式可能產生顯著的持續API成本
發展影響: 儘管DocRaptor處理Bootstrap良好,但基於雲的架構引入了操作考量: 1.所有PDF生成依賴於外部服務可用性 2.以文件為基數的成本可能隨著高流量迅速上升 3.敏感內容需要評估資料處理政策 4.為每次轉換進行的網路往返引入了延遲
對於需要本地處理、離線能力或高流量文件生成的應用程式,IronPDF的本地處理模型可能在長期價值和控制上提供更佳的選擇。
對於Bootstrap框架的最佳實踐,請參見Bootstrap & Flexbox CSS指南。
價格與授權:IronPDF vs. DocRaptor
IronPDF
IronPDF提供不同層次和額外功能的授權購買選項。 開發人員還可以購買Iron Suite,使您能以兩份的價格獲得Iron Software所有產品的使用權。 如果您尚未準備購買授權,IronPDF提供免費試用,使您能在購買授權前,探索其提供的所有功能。
定價(截至2026年4月):
-
永久授權: 提供根據您的員工規模、專案需求和位置數量的範圍廣泛的永久授權。 每種授權型別都附有電子郵件支援。
-
Lite License: 該授權支持一位開發者、一個地點和一個專案。 價格按要求提供。
-
Plus License: 支持三名開發者、三個地點和三個專案,是從Lite License的下一步升級,費用是 $1,499。 Plus授權除了基本的電子郵件支援外,還提供聊天支援和電話支援。
-
Professional License: 該授權適合較大的團隊,支持10名開發者、10個地點和10個專案,費用是 $2,399。 它提供與上一層級相同的聯絡支援渠道,但也提供螢幕共享支援。
-
免版稅再分發: IronPDF的授權還提供免版稅再分發範圍,需額外支付 $2,399
-
不中斷的產品支援: IronPDF提供持續的產品更新、安全功能升級存取權限,以及來自其技術團隊的支援,可以選擇 $1,499/年或一次性購買5年保障的 $2,399。
- Iron Suite: For $2,998, you get access to all Iron Software products including IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint, and IronWebScraper.

DocRaptor
DocRaptor提供幾個基於使用的定價選項。 起始價格為 $15/月,是基於使用量的,意味著隨著您生成的文件數量增加,成本會按比例增加。 他們還提供免費試用,以便在選擇付費計畫前測試服務。
文件和支援:IronPDF vs. DocRaptor
IronPDF
IronPDF在提供廣泛的文件和支援方面表現出色:
- 全面文件: 涵蓋所有功能的全面且使用者友好的文件。
- 24/5支援: 提供全天候工程師支援。
- 影片教程: 可在YouTube上找到分步影片指南。
- 社群論壇: 參與的社群提供額外支援。
- 定期更新: 每月產品更新以確保最新功能和安全修補。
- PDF API參考: 提供API參考,以便您能充分利用我們的工具。
欲了解更多資訊,請查看IronPDF的詳盡文件,並存取Iron Software YouTube Channel。
DocRaptor
- API參考: 提供詳細的指南,用於將DocRaptor與多種程式語言整合,涵蓋PDF和Excel生成。
- 快速入門指南: 提供分步教程,幫助新使用者設置和使用DocRaptor將HTML轉換為PDF。
- 客戶端程式庫: 提供流行語言的程式碼範例和程式庫,包括Java、C#、Python、PHP、Ruby和Node.js。
- 電子郵件支援: 提供技術協助或與服務相關的詢問。
結論
總結來說,IronPDF和DocRaptor都提供了可靠的解決方案來從HTML生成PDF,但它們針對不同的受眾和專案需求。 IronPDF在與.NET環境的無縫整合方面表現出色,提供廣泛的定制選項和離線處理能力。 它對於在.NET框架內工作的開發人員而言是理想的選擇,需要對PDF建立和操作進行精確控制。 另一方面,DocRaptor因其基於雲端的模式而突出,確保符合PDF/A標準,並提供簡單的API以進行跨平台的使用,這使其成為需要可靠、可擴展的文件生成解決方案的首選。
最終,您在IronPDF與DocRaptor之間的選擇應取決於您的開發技術堆棧、所需的控制等級,以及您是否偏好雲端或本地解決方案。
常見問題
如何在C#中將HTML轉換為PDF?
您可以使用IronPDF的RenderHtmlAsPdf方法將HTML字串轉換成PDF。也可以使用RenderHtmlFileAsPdf將HTML文件轉換為PDF。
使用.NET程式庫進行PDF生成的優勢是什麼?
使用類似IronPDF的.NET程式庫進行PDF生成可以與.NET應用程式無縫整合。它提供了全面的PDF建立、編輯和管理功能,並支持各種.NET版本和操作系統。
我可以使用.NET PDF工具編輯現有的PDF嗎?
可以,使用IronPDF,您可以通過其豐富的API集編輯現有的PDF,新增內容、修改文字、插入圖片或應用註釋。
可以使用.NET PDF程式庫來保護PDF嗎?
IronPDF允許您使用加密和數位簽名來保護PDF,提供增強的文件安全性和真實性。
雲端和離線PDF處理有何不同?
基於雲端的PDF處理(如DocRaptor)需要互聯網連接,並通過雲端的API執行任務。離線處理,如IronPDF,則允許您直接在本地環境中生成和操作PDF,無需依賴互聯網。
DocRaptor如何處理網路應用中的PDF生成?
DocRaptor採用基於雲端的API方法,需要開發者使用API金鑰來將HTML轉換為PDF,其處理通過Prince PDF引擎完成。
IronPDF支持哪些平台來進行PDF生成?
IronPDF相容於多種平台,包括Windows、Linux、macOS、Docker、Azure和AWS。它支持.NET Core、.NET Standard和.NET Framework應用程式。
我可以使用.NET PDF程式庫將DOCX文件轉換為PDF嗎?
可以,IronPDF提供簡便的程式,無需外部程式庫即可將DOCX文件轉換為PDF,為.NET開發者提供無縫體驗。
IronPDF在.NET開發中有哪些主要功能?
IronPDF的主要功能包括HTML到PDF的轉換、PDF編輯、加密文件安全、數位簽名、詳細的蓋章和與ASP.NET應用程式的整合。
IronPDF適合高容量的PDF處理嗎?
適合,IronPDF被設計為可高效處理高容量的PDF處理,非常適合需要穩健且具延展性文件管理解決方案的企業應用。



