IronPDF 和 PDFCrowd 的比較
IronPDF 和 Accusoft PDF Viewer 都能在 .NET 中將 HTML 轉換為 PDF。 IronPDF 提供簡單的語法、本地處理無需雲端依賴,和無限次的轉換,起始於 $999。 相反地,Accusoft 需要網路連接,且按交易次數收費。
概覽
什麼是 IronPDF 及其運作方式?
IronPDF 是一個C# HTML 到 PDF 的程式庫,讓開發人員能夠從來源建立 PDF 文件,例如HTML 字串、網頁和URL。 它還允許設置屬性,如浮水印、書籤和頁眉和頁腳。 此外,開發人員可以合併多個 PDF 文件為一個,或使用PDF 頁面轉換為圖像,反之亦然可以使用圖片到 PDF 的轉換。
IronPDF 是免費用於開發並為現場項目提供30 天的部署試用。 它提供完整的文件,程式範例和API 參考,以幫助開發人員快速開始。
開發人員可以從此連結下載檔案項目。
什麼是 Accusoft `PrizmDoc` Viewer 及其運作方式?
PrizmDoc Viewer 是一個 REST API,可遠程處理PDF 文件並將其轉換為其他格式。 PrizmDoc 能夠將超過 100 種不同的文件格式轉換為 PDF 和 PDF 再PNG、JPG、TIFF和 SVG。 它還為應用程式提供各種電子簽名選項。
IronPDF 和 `PrizmDoc` Viewer 有何不同?
| IronPDF | `PrizmDoc` Viewer |
|---|---|
| Work with [PDF files programmatically](/how-to/csharp-parse-pdf/). | 程式設計地與 PDF 文件工作。 |
| Supports [.NET Core](/docs/) with [Windows](/get-started/windows/), [Mac](/get-started/macos/), or [Linux](/get-started/linux/). | 使用 Windows、Mac 或 Linux 支援 .NET Core。 |
| [Works Locally](/get-started/installation-overview/) | Sends Documents to a [remote server](/get-started/ironpdfengine/). |
| Work with or without [Asynchronous Programming](/how-to/async/). | 必須使用 `System.Threading.Tasks` 進行非同步程式設計。 |
| Works offline once [installed](/get-started/installation-overview/). | 需要互聯網連接以進行 `PrizmDoc` 伺服器請求。 |
| Provides many [predefined functions](/features/). | 提供部分預定義功能。 |
| Often requires [minimal lines of code](/tutorials/html-to-pdf/). | 通常需要多行程式碼。 |
| [Unlimited conversions](/licensing/) per project in each license. | 雲托管授權中有限的交易量。 |
| [Free for development](/get-started/quickstart/) without time limits. | 試用時有限的交易次數。 |
讓我們安裝兩個程式庫並比較程式碼。
步驟 1:安裝
如何在我的 .NET 專案中安裝 IronPDF?
有兩種方法來安裝 IronPDF於專案中,兩者之間沒有差異。 IronPDF 支援各種環境,包括Azure 部署、AWS Lambda、Docker 容器和Blazor 應用程式。
下載 IronPDF 的不同方式有哪些?
下載 IronPDF.dll 並將其引用加入至專案。 開發人員也可以使用Windows 安裝程式進行系統範圍的安裝。 在此之後,IronPDF 的命名空間可以使用如下:
using IronPdf;
using IronPdf;
Imports IronPdf
現在,開發人員可以輕鬆存取 IronPDF 的提供的函式和類別,包括用於渲染的ChromePdfRenderer、PDF 文件操作和安全功能。
如何透過 NuGet Package Manager 安裝 IronPDF?
-
Package Manager Console:
如果使用 Package Manager Console,請運行以下命令:
_CODEBLOCK1
-
管理解決方案的套件:
如果使用 NuGet 套件管理器 GUI,在搜尋欄中瀏覽 IronPDF 並安裝它。 有關進階安裝選項,包括針對Linux、macOS 或 Windows 的平台專用套件,請參閱安裝指南。
如何安裝 Accusoft 的 `PrizmDoc` Viewer?
PrizmDoc Viewer 有兩個部分:一個稱為 PrizmDoc Server 的伺服器端組件,行為如 RESTful API,與向 API 發送請求並接收回應的客戶端計劃。 與沒有外部依賴的 IronPDF本地運行不同,PrizmDoc 需要網路連接以進行基於雲的操作。
如何存取 `PrizmDoc` 伺服器?
PrizmDoc 伺服器是一個伺服器端應用程式,接受包含文件的基本資訊作為請求(輸入),將文件轉換為PDF 文件,然後將轉換後的 PDF 文件作為回應(輸出)發送回來。 它是該產品的技術核心 — 文件處理和轉換引擎。開發人員可以通過兩種不同的方法使用,兩者具有相同的程式結構和技術:
-
自行託管:
這個選項需要安排一個伺服器。 下載 PrizmDoc 伺服器 並安裝。 瞭解更多有關如何在 Windows 上安裝
PrizmDoc伺服器。註:自行託管 PrizmDoc 伺服器需要大量記憶體和處理資源 — 請諮詢Accusoft的大小指南以獲取當前需求。 相比之下,IronPDF 的系統需求要溫和得多。
-
雲託管:
此基於雲的服務消除了安排伺服器的需求。 如要使用此選項,建立一個帳戶並從首頁的
API key中複製API Key。
首先,讓我們檢查直接與Accusoft server互動來將文件轉換成 PDF 文件的 PrizmDoc Viewer 的基本結構,使用於 C# Console Application 中的 WebClient()。
註:以下範例概念性地展示 PrizmDoc 如何處理 PDF 文件。這是冗長的,因此可以跳過此範例和直接進入比較。
Accusoft 的工作結構如何運作?
此範例將 myWebpage.html 轉換為 sample.pdf。 與IronPDF 直接的 HTML 到 PDF 轉換不同,PrizmDoc 需要多次 API 呼叫。
註:必須安裝Newtonsoft.Json程式庫並在專案中引用。
首先,將以下程式庫新增到專案中:
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq; // Install Newtonsoft.Json via NuGet Package Manager
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq; // Install Newtonsoft.Json via NuGet Package Manager
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Threading.Tasks
Imports Newtonsoft.Json.Linq ' Install Newtonsoft.Json via NuGet Package Manager
然後建立一個公共變數 Accusoft API Key 並將 API 金鑰粘貼在其中:
static string ApiKey = "Your-API-KEY";
static string ApiKey = "Your-API-KEY";
Private Shared ApiKey As String = "Your-API-KEY"
使用 PrizmDoc Viewer 操作 PDF 文件分為三個步驟:
- 將檔案上傳到
PrizmDoc伺服器。 - 轉換上傳的文件。
- 從
PrizmDoc伺服器下載轉換後的文件。
每一步都有一個單獨的功能處理:
static void Main(string[] args)
{
//---Upload file to Server---
JObject uploadResults = UploadToServer("myWebpage.html").Result;
string fileID = (string)uploadResults.SelectToken("fileId");
string affinityToken = (string)uploadResults.SelectToken("affinityToken");
//---Convert the uploaded file to PDF---
JObject convertResults = Convert(affinityToken, fileID).Result;
string processId = (string)convertResults.SelectToken("processId");
affinityToken = (string)convertResults.SelectToken("affinityToken");
//---Check the status that conversion is completed---
JObject convertStatusResults = ConvertStatus(processId, affinityToken).Result;
string convertStatus = (string)convertStatusResults.SelectToken("state");
//---Continuously checking whether conversion completed---
while (!(convertStatus.Equals("complete")))
{
System.Threading.Thread.Sleep(30000);
convertStatusResults = ConvertStatus(processId, affinityToken).Result;
convertStatus = (string)convertStatusResults.SelectToken("state");
}
//---Download the converted file from server---
string newFileID = (string)convertStatusResults.SelectToken("output.results[0].fileId");
DownloadFromServer(affinityToken, newFileID, "sample.pdf").Wait();
Console.WriteLine("PDF file created successfully...!");
Console.ReadKey();
}
static void Main(string[] args)
{
//---Upload file to Server---
JObject uploadResults = UploadToServer("myWebpage.html").Result;
string fileID = (string)uploadResults.SelectToken("fileId");
string affinityToken = (string)uploadResults.SelectToken("affinityToken");
//---Convert the uploaded file to PDF---
JObject convertResults = Convert(affinityToken, fileID).Result;
string processId = (string)convertResults.SelectToken("processId");
affinityToken = (string)convertResults.SelectToken("affinityToken");
//---Check the status that conversion is completed---
JObject convertStatusResults = ConvertStatus(processId, affinityToken).Result;
string convertStatus = (string)convertStatusResults.SelectToken("state");
//---Continuously checking whether conversion completed---
while (!(convertStatus.Equals("complete")))
{
System.Threading.Thread.Sleep(30000);
convertStatusResults = ConvertStatus(processId, affinityToken).Result;
convertStatus = (string)convertStatusResults.SelectToken("state");
}
//---Download the converted file from server---
string newFileID = (string)convertStatusResults.SelectToken("output.results[0].fileId");
DownloadFromServer(affinityToken, newFileID, "sample.pdf").Wait();
Console.WriteLine("PDF file created successfully...!");
Console.ReadKey();
}
Shared Sub Main(ByVal args() As String)
'---Upload file to Server---
Dim uploadResults As JObject = UploadToServer("myWebpage.html").Result
Dim fileID As String = CStr(uploadResults.SelectToken("fileId"))
Dim affinityToken As String = CStr(uploadResults.SelectToken("affinityToken"))
'---Convert the uploaded file to PDF---
Dim convertResults As JObject = Convert(affinityToken, fileID).Result
Dim processId As String = CStr(convertResults.SelectToken("processId"))
affinityToken = CStr(convertResults.SelectToken("affinityToken"))
'---Check the status that conversion is completed---
Dim convertStatusResults As JObject = ConvertStatus(processId, affinityToken).Result
Dim convertStatus As String = CStr(convertStatusResults.SelectToken("state"))
'---Continuously checking whether conversion completed---
Do While Not (convertStatus.Equals("complete"))
System.Threading.Thread.Sleep(30000)
convertStatusResults = ConvertStatus(processId, affinityToken).Result
convertStatus = CStr(convertStatusResults.SelectToken("state"))
Loop
'---Download the converted file from server---
Dim newFileID As String = CStr(convertStatusResults.SelectToken("output.results[0].fileId"))
DownloadFromServer(affinityToken, newFileID, "sample.pdf").Wait()
Console.WriteLine("PDF file created successfully...!")
Console.ReadKey()
End Sub
1. 上傳檔案至伺服器:
public static async Task<JObject> UploadToServer(string fileToUpload)
{
FileInfo input = new FileInfo(fileToUpload);
if (input == null)
{
throw new ArgumentException("Missing parameter input", nameof(input));
}
var fileName = input.Name;
var endpoint = new Uri("___PROTECTED_URL_123___");
using (var client = new WebClient())
{
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Content-Type", "application/octet-stream");
using (var reader = new BinaryReader(input.OpenRead()))
{
var data = reader.ReadBytes((int)reader.BaseStream.Length);
var results = await client.UploadDataTaskAsync(endpoint, "POST", data);
string getResult = Encoding.ASCII.GetString(results);
return JObject.Parse(getResult);
}
}
}
public static async Task<JObject> UploadToServer(string fileToUpload)
{
FileInfo input = new FileInfo(fileToUpload);
if (input == null)
{
throw new ArgumentException("Missing parameter input", nameof(input));
}
var fileName = input.Name;
var endpoint = new Uri("___PROTECTED_URL_123___");
using (var client = new WebClient())
{
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Content-Type", "application/octet-stream");
using (var reader = new BinaryReader(input.OpenRead()))
{
var data = reader.ReadBytes((int)reader.BaseStream.Length);
var results = await client.UploadDataTaskAsync(endpoint, "POST", data);
string getResult = Encoding.ASCII.GetString(results);
return JObject.Parse(getResult);
}
}
}
Public Shared Async Function UploadToServer(fileToUpload As String) As Task(Of JObject)
Dim input As New FileInfo(fileToUpload)
If input Is Nothing Then
Throw New ArgumentException("Missing parameter input", NameOf(input))
End If
Dim fileName = input.Name
Dim endpoint As New Uri("___PROTECTED_URL_123___")
Using client As New WebClient()
client.Headers.Add("acs-api-key", ApiKey)
client.Headers.Add("Content-Type", "application/octet-stream")
Using reader As New BinaryReader(input.OpenRead())
Dim data = reader.ReadBytes(CInt(reader.BaseStream.Length))
Dim results = Await client.UploadDataTaskAsync(endpoint, "POST", data)
Dim getResult As String = Encoding.ASCII.GetString(results)
Return JObject.Parse(getResult)
End Using
End Using
End Function
2. 將上傳的檔案轉換為 PDF:
public static async Task<JObject> Convert(string affinityToken, string fileID)
{
var endpoint = new Uri("___PROTECTED_URL_124___");
using (var client = new WebClient())
{
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Accusoft-Affinity-Token", affinityToken);
JObject myJson =
new JObject(
new JProperty("input",
new JObject(
new JProperty("sources",
new JArray(
new JObject(
new JProperty("fileId", fileID)
)
)
),
new JProperty("dest",
new JObject(
new JProperty("format", "pdf")
)
)
)
)
);
string results = await client.UploadStringTaskAsync(endpoint, "POST", myJson.ToString());
return JObject.Parse(results);
}
}
public static async Task<JObject> Convert(string affinityToken, string fileID)
{
var endpoint = new Uri("___PROTECTED_URL_124___");
using (var client = new WebClient())
{
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Accusoft-Affinity-Token", affinityToken);
JObject myJson =
new JObject(
new JProperty("input",
new JObject(
new JProperty("sources",
new JArray(
new JObject(
new JProperty("fileId", fileID)
)
)
),
new JProperty("dest",
new JObject(
new JProperty("format", "pdf")
)
)
)
)
);
string results = await client.UploadStringTaskAsync(endpoint, "POST", myJson.ToString());
return JObject.Parse(results);
}
}
Public Shared Async Function Convert(affinityToken As String, fileID As String) As Task(Of JObject)
Dim endpoint = New Uri("___PROTECTED_URL_124___")
Using client = New WebClient()
client.Headers.Add("Content-Type", "application/json")
client.Headers.Add("acs-api-key", ApiKey)
client.Headers.Add("Accusoft-Affinity-Token", affinityToken)
Dim myJson As JObject =
New JObject(
New JProperty("input",
New JObject(
New JProperty("sources",
New JArray(
New JObject(
New JProperty("fileId", fileID)
)
)
),
New JProperty("dest",
New JObject(
New JProperty("format", "pdf")
)
)
)
)
)
Dim results As String = Await client.UploadStringTaskAsync(endpoint, "POST", myJson.ToString())
Return JObject.Parse(results)
End Using
End Function
以下 JSON 是 myJson 物件的結果值:
{
"input": {
"sources":
[
{"fileId": "Auto Generated FileId Value"}
],
"dest": {
"format": "pdf"
}
}
}
檢查是否已完成轉換的狀態
public static async Task<JObject> ConvertStatus(string processId, string affinityToken)
{
string endpoint = "___PROTECTED_URL_125___" + processId;
using (var client = new WebClient())
{
client.BaseAddress = endpoint;
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Accusoft-Affinity-Token", affinityToken);
string results = await client.DownloadStringTaskAsync(endpoint);
return JObject.Parse(results);
}
}
public static async Task<JObject> ConvertStatus(string processId, string affinityToken)
{
string endpoint = "___PROTECTED_URL_125___" + processId;
using (var client = new WebClient())
{
client.BaseAddress = endpoint;
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Accusoft-Affinity-Token", affinityToken);
string results = await client.DownloadStringTaskAsync(endpoint);
return JObject.Parse(results);
}
}
Public Shared Async Function ConvertStatus(processId As String, affinityToken As String) As Task(Of JObject)
Dim endpoint As String = "___PROTECTED_URL_125___" & processId
Using client As New WebClient()
client.BaseAddress = endpoint
client.Headers.Add("acs-api-key", ApiKey)
client.Headers.Add("Accusoft-Affinity-Token", affinityToken)
Dim results As String = Await client.DownloadStringTaskAsync(endpoint)
Return JObject.Parse(results)
End Using
End Function
3. 從伺服器下載轉換後的文件
public static async Task DownloadFromServer(string affinityToken, string fileId, string outfile)
{
var endpoint = new Uri("___PROTECTED_URL_126___" + fileId);
using (var client = new WebClient())
{
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Accusoft-Affinity-Token", affinityToken);
FileInfo output = new FileInfo(outfile);
using (var writeStream = output.Create())
{
var results = await client.DownloadDataTaskAsync(endpoint);
await writeStream.WriteAsync(results, 0, results.Length);
}
}
}
public static async Task DownloadFromServer(string affinityToken, string fileId, string outfile)
{
var endpoint = new Uri("___PROTECTED_URL_126___" + fileId);
using (var client = new WebClient())
{
client.Headers.Add("acs-api-key", ApiKey);
client.Headers.Add("Accusoft-Affinity-Token", affinityToken);
FileInfo output = new FileInfo(outfile);
using (var writeStream = output.Create())
{
var results = await client.DownloadDataTaskAsync(endpoint);
await writeStream.WriteAsync(results, 0, results.Length);
}
}
}
Public Shared Async Function DownloadFromServer(affinityToken As String, fileId As String, outfile As String) As Task
Dim endpoint As New Uri("___PROTECTED_URL_126___" & fileId)
Using client As New WebClient()
client.Headers.Add("acs-api-key", ApiKey)
client.Headers.Add("Accusoft-Affinity-Token", affinityToken)
Dim output As New FileInfo(outfile)
Using writeStream As FileStream = output.Create()
Dim results As Byte() = Await client.DownloadDataTaskAsync(endpoint)
Await writeStream.WriteAsync(results, 0, results.Length)
End Using
End Using
End Function
以上範例需要大量努力。 為了減少工作量,Accusoft 引入了一個名為 Accusoft.PrizmDocServerSDK 的 .NET 程式庫,一個 PrizmDoc 伺服器 REST API 的外殼。 讓我們檢查如何在 .NET 專案中安裝和使用此程式庫。
如何安裝 Accusoft.`PrizmDocServer`SDK?
有兩種方式安裝此外殼。
-
Package Manager Console:
如果使用 Package Manager Console,請運行以下命令:
_CODEBLOCK10
-
管理解決方案的套件:
如果使用 NuGet 包管理器 GUI,在搜尋欄中瀏覽
Accusoft.PrizmDocServerSDK並安裝。
現在,開發人員可以輕鬆存取 Accusoft.PrizmDocServer 命名空間並使用它:
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer;
Imports Accusoft.PrizmDocServer
如何操作指南
IronPDF 和 PrizmDoc Viewer 在程式碼範例中如何比較?
在檢查完兩個組件的簡介和安裝後,是時候使用兩者進行操作。 以下使用案例展示使用兩個構件的實施,以幫助理解程式設計結構並確定哪個適合專案要求。
如何使用 IronPDF 和 PrizmDoc Viewer 將 HTML 轉換為 PDF?
在此比較中,讓我們將名為 myWebPage.html 的網頁轉換為PDF 文件並將其保存到目標位置。 IronPDF 的Chrome 渲染引擎可提供像素完美的轉換,全面支援CSS、JavaScript和網頁字型。
IronPDF 如何將 HTML 轉換為 PDF?
using IronPdf;
static void Main(string[] args)
{
// Create rendering converter
var converter = new ChromePdfRenderer();
// Render HTML file to PDF
using var PDF = converter.RenderHTMLFileAsPdf("myWebPage.html");
// Save to target location
PDF.SaveAs("sample.pdf");
}
using IronPdf;
static void Main(string[] args)
{
// Create rendering converter
var converter = new ChromePdfRenderer();
// Render HTML file to PDF
using var PDF = converter.RenderHTMLFileAsPdf("myWebPage.html");
// Save to target location
PDF.SaveAs("sample.pdf");
}
Imports IronPdf
Shared Sub Main(ByVal args() As String)
' Create rendering converter
Dim converter = New ChromePdfRenderer()
' Render HTML file to PDF
Dim PDF = converter.RenderHTMLFileAsPdf("myWebPage.html")
' Save to target location
PDF.SaveAs("sample.pdf")
End Sub
上面的程式碼會建立一個 sample.pdf 文件並將其保存到專案的 bin>debug 文件夾中。 IronPDF 也支援HTML 字串、網址,甚至包含 HTML 的 ZIP 文件作為輸入來源。
開發人員也可以像這樣指定任何路徑:PDF.SaveAs("E:/sample.pdf");,或者保存記憶體流以便進行雲端部署。
閱讀更多有關使用 IronPDF 操作 PDF 文件的資訊。
現在,讓我們使用 PrizmDoc Viewer 執行相同任務以進行比較。
PrizmDoc Viewer 如何將 HTML 轉換為 PDF?
在 PrizmDoc Viewer 安裝部分中,討論了獲取 Accusoft API Key。 這是它的使用方法。
首先,向 PrizmDoc 伺服器發送請求並接收回應。 此過程需要時間,需要非同步程式設計。 IronPDF 也支援非同步方法以提高性能。
註:在使用 PrizmDoc Viewer 的雲服務建立 PDF 文件時,請確保系統已連接到互聯網。
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
ChromePdfRenderer().GetAwaiter().GetResult();
}
private static async Task ChromePdfRenderer()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_127___", "Your-API-KEY");
// Specify HTML file and convert it to a PDF.
ConversionResult result = await prizmDocServer.ConvertToPdfAsync("myWebPage.html");
// Save PDF file to the target location
await result.RemoteWorkFile.SaveAsync("sample.pdf");
}
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
ChromePdfRenderer().GetAwaiter().GetResult();
}
private static async Task ChromePdfRenderer()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_127___", "Your-API-KEY");
// Specify HTML file and convert it to a PDF.
ConversionResult result = await prizmDocServer.ConvertToPdfAsync("myWebPage.html");
// Save PDF file to the target location
await result.RemoteWorkFile.SaveAsync("sample.pdf");
}
Imports Accusoft.PrizmDocServer
Imports Accusoft.PrizmDocServer.Conversion
Module Program
Sub Main(args As String())
ChromePdfRenderer().GetAwaiter().GetResult()
End Sub
Private Async Function ChromePdfRenderer() As Task
' Instantiate PrizmDocServerClient object
Dim prizmDocServer = New PrizmDocServerClient("___PROTECTED_URL_127___", "Your-API-KEY")
' Specify HTML file and convert it to a PDF.
Dim result As ConversionResult = Await prizmDocServer.ConvertToPdfAsync("myWebPage.html")
' Save PDF file to the target location
Await result.RemoteWorkFile.SaveAsync("sample.pdf")
End Function
End Module
閱讀更多有關 PrizmDoc Viewer 的工作方式。
哪個程式庫提供更簡單的 HTML 到 PDF 轉換?
這些範例展示了 IronPDF 提供了一種更簡單的方法來建立 PDF 文件,且需要更少的時間。IronPDF 還提供渲染選項來微調輸出,包括自定義紙張尺寸、邊距和視窗設置。
如何使用 IronPDF 和 PrizmDoc Viewer 將圖像轉換為 PDF?
此比較展示如何從位於 debug 專案文件夾中的
建立 PDF 文件。 開發人員先從 IronPDF 開始。
IronPDF 如何將圖像轉換為 PDF?
using IronPdf;
static void Main(string[] args)
{
// Specify the image to be converted
using var converted = ImageToPdfConverter.ImageToPdf("google.png");
// Save PDF file to the target location
converted.SaveAs("sample.pdf");
}
using IronPdf;
static void Main(string[] args)
{
// Specify the image to be converted
using var converted = ImageToPdfConverter.ImageToPdf("google.png");
// Save PDF file to the target location
converted.SaveAs("sample.pdf");
}
Imports IronPdf
Shared Sub Main(ByVal args() As String)
' Specify the image to be converted
Dim converted = ImageToPdfConverter.ImageToPdf("google.png")
' Save PDF file to the target location
converted.SaveAs("sample.pdf")
End Sub
IronPDF 也支援多框架 TIFF 轉換、從 Azure Blob 儲存嵌入圖像和Base64 圖像嵌入。
輸出:
此螢幕截圖展示了使用上述程式碼建立的新 PDF 文件 sample.pdf:
使用 IronPDF 從圖像建立 PDF 文件很簡單。 現在,讓我們使用 PrizmDoc Viewer 執行相同的任務,並檢查其生成的 PDF 文件。
PrizmDoc Viewer 如何將圖像轉換為 PDF?
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
ImageToPDF().GetAwaiter().GetResult();
}
private static async Task ImageToPDF()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_128___", "Your-API-KEY");
// Specify the image to be converted
ConversionResult results = await prizmDocServer.ConvertToPdfAsync("google.png");
// Save PDF file to the target location
await results.RemoteWorkFile.SaveAsync("sample.pdf");
}
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
ImageToPDF().GetAwaiter().GetResult();
}
private static async Task ImageToPDF()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_128___", "Your-API-KEY");
// Specify the image to be converted
ConversionResult results = await prizmDocServer.ConvertToPdfAsync("google.png");
// Save PDF file to the target location
await results.RemoteWorkFile.SaveAsync("sample.pdf");
}
Imports Accusoft.PrizmDocServer
Imports Accusoft.PrizmDocServer.Conversion
Module Module1
Sub Main()
ImageToPDF().GetAwaiter().GetResult()
End Sub
Private Async Function ImageToPDF() As Task
' Instantiate PrizmDocServerClient object
Dim prizmDocServer As New PrizmDocServerClient("___PROTECTED_URL_128___", "Your-API-KEY")
' Specify the image to be converted
Dim results As ConversionResult = Await prizmDocServer.ConvertToPdfAsync("google.png")
' Save PDF file to the target location
Await results.RemoteWorkFile.SaveAsync("sample.pdf")
End Function
End Module
輸出:此螢幕截圖展示了使用上述程式碼生成的新 PDF 文件 sample.pdf:
哪個程式庫需要更少的程式碼來進行圖像轉換為 PDF?
IronPDF 僅需兩行程式碼。 相反,使用 PrizmDoc 伺服器涉及更多行程式碼以及非同步編程。 IronPDF 的輸出還自動提供了一個可用的全頁面文件。 IronPDF 還提供額外的選項以供圖像定位和多圖像轉換。
如何使用 IronPDF 和 PrizmDoc Viewer 合併多個 PDF 文件?
在此比較中,假設存在三個 PDF 文件,名稱為 B.pdf 和 C.pdf。 任務是將它們合併為一個 PDF 文件。 這兩個具件均可執行此任務。 首先,這個例子展示如何使用 IronPDF 完成這個任務。
IronPDF 如何合併 PDF 文件?
using IronPdf;
using System.Collections.Generic;
static void Main(string[] args)
{
// Create rendering converter
var Renderer = new IronPdf.ChromePdfRenderer();
// Create a list of pdf files
var PDFs = new List<PdfDocument>();
PDFs.Add(PdfDocument.FromFile("A.pdf"));
PDFs.Add(PdfDocument.FromFile("B.pdf"));
PDFs.Add(PdfDocument.FromFile("C.pdf"));
// Merge the list of pdf file
using PdfDocument PDF = PdfDocument.Merge(PDFs);
// Save merged file to the target location
PDF.SaveAs("sample.pdf");
foreach(var pdf in PDFs)
{
pdf.Dispose();
}
}
using IronPdf;
using System.Collections.Generic;
static void Main(string[] args)
{
// Create rendering converter
var Renderer = new IronPdf.ChromePdfRenderer();
// Create a list of pdf files
var PDFs = new List<PdfDocument>();
PDFs.Add(PdfDocument.FromFile("A.pdf"));
PDFs.Add(PdfDocument.FromFile("B.pdf"));
PDFs.Add(PdfDocument.FromFile("C.pdf"));
// Merge the list of pdf file
using PdfDocument PDF = PdfDocument.Merge(PDFs);
// Save merged file to the target location
PDF.SaveAs("sample.pdf");
foreach(var pdf in PDFs)
{
pdf.Dispose();
}
}
Imports IronPdf
Imports System.Collections.Generic
Shared Sub Main(ByVal args() As String)
' Create rendering converter
Dim Renderer = New IronPdf.ChromePdfRenderer()
' Create a list of pdf files
Dim PDFs = New List(Of PdfDocument)()
PDFs.Add(PdfDocument.FromFile("A.pdf"))
PDFs.Add(PdfDocument.FromFile("B.pdf"))
PDFs.Add(PdfDocument.FromFile("C.pdf"))
' Merge the list of pdf file
Using PDF As PdfDocument = PdfDocument.Merge(PDFs)
' Save merged file to the target location
PDF.SaveAs("sample.pdf")
'INSTANT VB NOTE: The variable pdf was renamed since Visual Basic will not allow local variables with the same name as parameters or other local variables:
For Each .pdf_Conflict In PDFs
.pdf_Conflict.Dispose()
Next pdf_Conflict
End Using
End Sub
上面的程式碼建立了一個 sample.pdf 文件,其中合併了 B.pdf 和 C.pdf。 IronPDF 還支援在 PDF 之間新增和複製頁面和拆分 PDF。
現在,讓我們使用 PrizmDoc Viewer 執行相同的任務。
PrizmDoc Viewer 如何合併 PDF 文件?
using System.Threading.Tasks;
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
PdfMerge().GetAwaiter().GetResult();
}
private static async Task PdfMerge()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_129___", "Your-API-KEY");
// Pass the list of pdf files to PrizmDoc Server
ConversionResult result = await prizmDocServer.CombineToPdfAsync(
new []
{
new ConversionSourceDocument("A.pdf"),
new ConversionSourceDocument("B.pdf"),
new ConversionSourceDocument("C.pdf"),
});
// Save merged file to the target location
await result.RemoteWorkFile.SaveAsync("sample.pdf");
}
using System.Threading.Tasks;
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
PdfMerge().GetAwaiter().GetResult();
}
private static async Task PdfMerge()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_129___", "Your-API-KEY");
// Pass the list of pdf files to PrizmDoc Server
ConversionResult result = await prizmDocServer.CombineToPdfAsync(
new []
{
new ConversionSourceDocument("A.pdf"),
new ConversionSourceDocument("B.pdf"),
new ConversionSourceDocument("C.pdf"),
});
// Save merged file to the target location
await result.RemoteWorkFile.SaveAsync("sample.pdf");
}
Imports System.Threading.Tasks
Imports Accusoft.PrizmDocServer
Imports Accusoft.PrizmDocServer.Conversion
Module Module1
Sub Main()
PdfMerge().GetAwaiter().GetResult()
End Sub
Private Async Function PdfMerge() As Task
' Instantiate PrizmDocServerClient object
Dim prizmDocServer = New PrizmDocServerClient("___PROTECTED_URL_129___", "Your-API-KEY")
' Pass the list of pdf files to PrizmDoc Server
Dim result As ConversionResult = Await prizmDocServer.CombineToPdfAsync(
New ConversionSourceDocument() {
New ConversionSourceDocument("A.pdf"),
New ConversionSourceDocument("B.pdf"),
New ConversionSourceDocument("C.pdf")
})
' Save merged file to the target location
Await result.RemoteWorkFile.SaveAsync("sample.pdf")
End Function
End Module
上述程式碼還建立了一個 sample.pdf 文件,其中合併了 B.pdf 和 C.pdf 文件。
如何使用 IronPDF 和 PrizmDoc Viewer 向 PDF 新增頁眉和頁腳?
在此比較中,假設存在一個簡單的 WebPage 名為 myWebPage.html,包含以下 HTML 和 CSS:
<html>
<head>
<style>
li {
font-size: x-large;
color: rgba(156, 89, 13, 0.897);
list-style: square;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Hello World..!</h1>
<h1>Main Menu</h1>
<ul>
<li>SubMenu 1</li>
<li>SubMenu 2</li>
<li>SubMenu 3</li>
<li>SubMenu 4</li>
<li>SubMenu 5</li>
</ul>
</body>
</html>
<html>
<head>
<style>
li {
font-size: x-large;
color: rgba(156, 89, 13, 0.897);
list-style: square;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Hello World..!</h1>
<h1>Main Menu</h1>
<ul>
<li>SubMenu 1</li>
<li>SubMenu 2</li>
<li>SubMenu 3</li>
<li>SubMenu 4</li>
<li>SubMenu 5</li>
</ul>
</body>
</html>
目標是將此 WebPage 轉換為具有以下頁眉和頁腳屬性的 PDF 文件:
- 頁眉左側的
Page Title - 頁眉右側的
DateTime - 頁腳右側的
Page Number of Total Pages
首先,我們來看看 IronPDF 如何處理頁眉和頁腳。
IronPDF 如何處理 PDF 頁眉和頁腳?
IronPDF 提供了一個 ChromePdfRenderer 類的屬性,以處理 PDF 頁眉和頁腳,稱為 RenderingOptions,可以如下使用:
-
頁眉:
_CODEBLOCK19
-
頁腳:
_CODEBLOCK20
在初始化 TextHeaderFooter() 時,可以設置以下屬性:
CenterText用於在頁眉或頁腳中間列印文字LeftText用於在頁眉或頁腳左側列印文字RightText用於在頁眉或頁腳右側列印文字DrawDividerLine繪製線條以分隔頁面內容與頁眉或頁腳FontFamily用於指定頁眉或頁腳的字體FontSize用於指定頁眉或頁腳的字體大小- 間距 調整頁面內容與頁眉或頁腳之間的距離
以下預定義屬性有助於設置頁眉或頁腳的內容。 它們寫在大括號中 { }:
- {page} 在頁眉或頁腳列印當前頁號
- {total-pages} 在頁眉或頁腳列印總頁數
- {url} 在頁眉或頁腳列印渲染頁面的 URL
- {date} 在頁眉或頁腳列印當前日期
- {time} 在頁眉或頁腳列印當前時間
- {html-title} 在頁眉或頁腳列印渲染網頁的標題
- {pdf-title} 在頁眉或頁腳列印文件的標題
詳細閱讀以瞭解如何使用 IronPDF 設定頁眉和頁腳。 IronPDF 也支援HTML 頁眉和頁腳以便進行更複雜的設計。
範例展示了以下需求用例的實現,以演示如何使用上述屬性:
using IronPdf;
static void Main(string[] args)
{
// Create rendering converter
var converter = new ChromePdfRenderer();
// Setting Header properties
converter.RenderingOptions.TextHeader = new TextHeaderFooter()
{
DrawDividerLine = true,
LeftText = "Page Title",
RightText = "{date} {time}",
FontSize = 13
};
// Setting footer properties
converter.RenderingOptions.TextFooter = new TextHeaderFooter()
{
RightText = "Page {page} of {total-pages}",
FontSize = 12
};
// Specify the file to be converted
using var PDF = converter.RenderHTMLFileAsPdf("myWebPage.html");
// Save to target location
PDF.SaveAs("sample.pdf");
}
using IronPdf;
static void Main(string[] args)
{
// Create rendering converter
var converter = new ChromePdfRenderer();
// Setting Header properties
converter.RenderingOptions.TextHeader = new TextHeaderFooter()
{
DrawDividerLine = true,
LeftText = "Page Title",
RightText = "{date} {time}",
FontSize = 13
};
// Setting footer properties
converter.RenderingOptions.TextFooter = new TextHeaderFooter()
{
RightText = "Page {page} of {total-pages}",
FontSize = 12
};
// Specify the file to be converted
using var PDF = converter.RenderHTMLFileAsPdf("myWebPage.html");
// Save to target location
PDF.SaveAs("sample.pdf");
}
Imports IronPdf
Shared Sub Main(ByVal args() As String)
' Create rendering converter
Dim converter = New ChromePdfRenderer()
' Setting Header properties
converter.RenderingOptions.TextHeader = New TextHeaderFooter() With {
.DrawDividerLine = True,
.LeftText = "Page Title",
.RightText = "{date} {time}",
.FontSize = 13
}
' Setting footer properties
converter.RenderingOptions.TextFooter = New TextHeaderFooter() With {
.RightText = "Page {page} of {total-pages}",
.FontSize = 12
}
' Specify the file to be converted
Dim PDF = converter.RenderHTMLFileAsPdf("myWebPage.html")
' Save to target location
PDF.SaveAs("sample.pdf")
End Sub
輸出:以上程式碼建立的 PDF 文件 sample.pdf 的截圖:
使用 IronPDF 設置頁眉和頁腳時,建立 PDF 文件時語言直觀。 現在,此範例展示 PrizmDoc Viewer 如何處理頁眉和頁腳。
PrizmDoc Viewer 如何處理 PDF 頁眉和頁腳?
PrizmDoc Viewer 提供 HeaderFooterOptions 類來處理頁眉和頁腳,具有以下屬性:
- 行 指定頁眉和頁腳的行(s),每行都有以下屬性:
- 左 在頁眉或頁腳行左側列印文字
- 中心 在頁眉或頁腳行中心列印文字
- 右 在頁眉或頁腳行右側列印文字
FontFamily用於指定頁眉或頁腳文字的字體FontSize用於指定頁眉或頁腳文字的字體大小- 顏色 用於指定頁眉或頁腳文字的顏色
瞭解更多有關使用 PrizmDoc 伺服器設置 PDF 頁面頁眉和頁腳的資訊。
此範例展示如何使用上述屬性實現需求用例:
using System.Threading.Tasks;
using System.Collections.Generic;
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
SetHeaderFooter().GetAwaiter().GetResult();
}
private static async Task SetHeaderFooter()
{
// Instantiate PrizmDocServerClient object with Header and footer properties
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_130___", "Your-API-KEY");
ConversionResult result = await prizmDocServer.ConvertToPdfAsync(
"myWebPage.html",
header: new HeaderFooterOptions
{
Lines = new List<HeaderFooterLine>
{
new HeaderFooterLine { Left = "Page Title", Right = DateTime.Now.ToString() }
},
},
footer: new HeaderFooterOptions
{
Lines = new List<HeaderFooterLine>
{
new HeaderFooterLine { Right = "Page {{pageNumber}} of {{pageCount}}" },
},
});
// Save to the target location
await result.RemoteWorkFile.SaveAsync("sample.pdf");
}
using System.Threading.Tasks;
using System.Collections.Generic;
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
SetHeaderFooter().GetAwaiter().GetResult();
}
private static async Task SetHeaderFooter()
{
// Instantiate PrizmDocServerClient object with Header and footer properties
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_130___", "Your-API-KEY");
ConversionResult result = await prizmDocServer.ConvertToPdfAsync(
"myWebPage.html",
header: new HeaderFooterOptions
{
Lines = new List<HeaderFooterLine>
{
new HeaderFooterLine { Left = "Page Title", Right = DateTime.Now.ToString() }
},
},
footer: new HeaderFooterOptions
{
Lines = new List<HeaderFooterLine>
{
new HeaderFooterLine { Right = "Page {{pageNumber}} of {{pageCount}}" },
},
});
// Save to the target location
await result.RemoteWorkFile.SaveAsync("sample.pdf");
}
Imports System.Threading.Tasks
Imports System.Collections.Generic
Imports Accusoft.PrizmDocServer
Imports Accusoft.PrizmDocServer.Conversion
Module Program
Sub Main(args As String())
SetHeaderFooter().GetAwaiter().GetResult()
End Sub
Private Async Function SetHeaderFooter() As Task
' Instantiate PrizmDocServerClient object with Header and footer properties
Dim prizmDocServer = New PrizmDocServerClient("___PROTECTED_URL_130___", "Your-API-KEY")
Dim result As ConversionResult = Await prizmDocServer.ConvertToPdfAsync(
"myWebPage.html",
header:=New HeaderFooterOptions With {
.Lines = New List(Of HeaderFooterLine) From {
New HeaderFooterLine With {.Left = "Page Title", .Right = DateTime.Now.ToString()}
}
},
footer:=New HeaderFooterOptions With {
.Lines = New List(Of HeaderFooterLine) From {
New HeaderFooterLine With {.Right = "Page {{pageNumber}} of {{pageCount}}"}
}
})
' Save to the target location
Await result.RemoteWorkFile.SaveAsync("sample.pdf")
End Function
End Module
輸出:
上面的程式碼建立的 PDF 文件的截圖:
哪個程式庫在設置頁眉和頁腳方面提供更多靈活性?
IronPDF 提供更多功能來設置頁眉和頁腳的屬性,並且程式設計結構較為簡單,與 PrizmDoc Viewer 相比。 IronPDF 生成的 PDF 文件在可讀性和吸引力方面也比 PrizmDoc Viewer 生成的文件要好。IronPDF 還支援頁碼和頁面中斷以改善文件控制。
如何使用 IronPDF 和 PrizmDoc Viewer 將 PDF 頁面轉換為圖像?
在此比較中,假設您有一個名為 Sample_PDF.pdf 的簡單 PDF 文件,其中包含兩頁。
任務是為每個頁面建立圖像。 首先,該例子將如何使用 IronPDF 來執行此操作。
IronPDF 如何將 PDF 頁面轉換為圖像?
using IronPdf;
static void Main(string[] args)
{
// Specify file to be converted
var pdf = PdfDocument.FromFile("Sample_PDF.pdf");
// Save images to the target location
pdf.RasterizeToImageFiles("image_*.png");
}
using IronPdf;
static void Main(string[] args)
{
// Specify file to be converted
var pdf = PdfDocument.FromFile("Sample_PDF.pdf");
// Save images to the target location
pdf.RasterizeToImageFiles("image_*.png");
}
Imports IronPdf
Shared Sub Main(ByVal args() As String)
' Specify file to be converted
Dim pdf = PdfDocument.FromFile("Sample_PDF.pdf")
' Save images to the target location
pdf.RasterizeToImageFiles("image_*.png")
End Sub
IronPDF 還支援將圖像保存到記憶體流和不同的圖像格式,包括 JPEG、TIFF 等。
輸出:
上面的程式碼建立了以下兩個 .png 圖像:
使用 IronPDF 建立 PDF 頁面的圖像很簡單。 現在,讓我們使用 PrizmDoc Viewer 執行相同的任務。
PrizmDoc Viewer 如何將 PDF 頁面轉換為圖像?
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
PdfToImage().GetAwaiter().GetResult();
}
private static async Task PdfToImage()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_131___", "Your-API-KEY");
// Convert PDF file to images
IEnumerable<ConversionResult> results = await prizmDocServer.ConvertAsync("Sample_PDF.pdf", DestinationFileFormat.Png);
// Save each image.
for (int i = 0; i < results.Count(); i++)
{
await results.ElementAt(i).RemoteWorkFile.SaveAsync($"page-{i + 1}.png");
}
}
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer.Conversion;
static void Main(string[] args)
{
PdfToImage().GetAwaiter().GetResult();
}
private static async Task PdfToImage()
{
// Instantiate PrizmDocServerClient object
var prizmDocServer = new PrizmDocServerClient("___PROTECTED_URL_131___", "Your-API-KEY");
// Convert PDF file to images
IEnumerable<ConversionResult> results = await prizmDocServer.ConvertAsync("Sample_PDF.pdf", DestinationFileFormat.Png);
// Save each image.
for (int i = 0; i < results.Count(); i++)
{
await results.ElementAt(i).RemoteWorkFile.SaveAsync($"page-{i + 1}.png");
}
}
Imports System.Linq
Imports System.Collections.Generic
Imports System.Threading.Tasks
Imports Accusoft.PrizmDocServer
Imports Accusoft.PrizmDocServer.Conversion
Module Program
Sub Main(args As String())
PdfToImage().GetAwaiter().GetResult()
End Sub
Private Async Function PdfToImage() As Task
' Instantiate PrizmDocServerClient object
Dim prizmDocServer = New PrizmDocServerClient("___PROTECTED_URL_131___", "Your-API-KEY")
' Convert PDF file to images
Dim results As IEnumerable(Of ConversionResult) = Await prizmDocServer.ConvertAsync("Sample_PDF.pdf", DestinationFileFormat.Png)
' Save each image.
For i As Integer = 0 To results.Count() - 1
Await results.ElementAt(i).RemoteWorkFile.SaveAsync($"page-{i + 1}.png")
Next
End Function
End Module
輸出:
上面的程式碼還建立了以下兩個 .png 圖像:
哪個程式庫讓 PDF 到圖像轉換更容易?
與 PrizmDoc Viewer 相比,IronPDF 允許開發人員輕鬆建立每頁的圖像,甚至不需要遍訪各頁,且使用的程式碼很少。
我可以在 IronPDF 中使用 Bootstrap 5 資料表嗎?
IronPDF 的Chrome V8 渲染引擎為Bootstrap 5 資料表提供了卓越的支援,使開發人員能夠生成具有複雜表格式樣的專業PDF 報告。 此範例展示了漸層頁眉、狀態徽章、分頁控制項和摘要指標 — 這些功能突顯了 IronPDF 相較於傳統 PDF 檢視器如 PrizmDoc 的優勢。 IronPDF 完全支援現代 CSS 功能,包括flexbox 佈局、漸層和響應設計。
using IronPdf;
var renderer = new ChromePdfRenderer();
string dataTableReport = @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='___PROTECTED_URL_132___ rel='stylesheet'>
<style>
.table-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
border-radius: 10px 10px 0 0;
}
.table-container {
background: white;
border-radius: 0 0 10px 10px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
overflow: hidden;
}
.table th {
background: #f8f9fa;
font-weight: 600;
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 0.5px;
}
.status-badge {
padding: 0.35em 0.65em;
border-radius: 0.25rem;
font-weight: 600;
font-size: 0.75rem;
}
.trend-positive { color: #198754; font-weight: 700; }
.trend-negative { color: #dc3545; font-weight: 700; }
@media print {
.table-container { page-break-inside: avoid; }
}
</style>
</head>
<body class='bg-light'>
<div class='container py-5'>
<div class='table-container'>
<div class='table-header'>
<div class='row align-items-center'>
<div class='col-md-8'>
<h2 class='mb-2'>Sales Performance Report</h2>
<p class='mb-0 opacity-75'>Q4 2024 Regional Analysis</p>
</div>
<div class='col-md-4 text-end'>
<div class='btn-group btn-group-sm'>
<button class='btn btn-light'>Export</button>
<button class='btn btn-light'>Filter</button>
<button class='btn btn-light'>Sort</button>
</div>
</div>
</div>
</div>
<div class='p-4'>
<div class='row mb-3'>
<div class='col-md-4'>
<input type='text' class='form-control form-control-sm' placeholder='Search regions...'>
</div>
<div class='col-md-8 text-end'>
<span class='text-muted small'>Showing 1-10 of 48 results</span>
</div>
</div>
<div class='table-responsive'>
<table class='table table-hover align-middle'>
<thead>
<tr>
<th>Region</th>
<th>Revenue</th>
<th>Units Sold</th>
<th>Growth</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>North America</strong><br>
<small class='text-muted'>USA, Canada, Mexico</small>
</td>
<td>$4,280,000</td>
<td>12,450</td>
<td><span class='trend-positive'>↑ 18.5%</span></td>
<td><span class='status-badge bg-success text-white'>Exceeding</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Europe</strong><br>
<small class='text-muted'>EU, UK, Switzerland</small>
</td>
<td>$3,650,000</td>
<td>10,890</td>
<td><span class='trend-positive'>↑ 12.3%</span></td>
<td><span class='status-badge bg-success text-white'>On Track</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Asia Pacific</strong><br>
<small class='text-muted'>Japan, Australia, Singapore</small>
</td>
<td>$2,940,000</td>
<td>8,320</td>
<td><span class='trend-positive'>↑ 24.7%</span></td>
<td><span class='status-badge bg-primary text-white'>Growing</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Latin America</strong><br>
<small class='text-muted'>Brazil, Argentina, Chile</small>
</td>
<td>$1,580,000</td>
<td>4,670</td>
<td><span class='trend-positive'>↑ 8.9%</span></td>
<td><span class='status-badge bg-info text-white'>Stable</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Middle East</strong><br>
<small class='text-muted'>UAE, Saudi Arabia, Israel</small>
</td>
<td>$980,000</td>
<td>2,890</td>
<td><span class='trend-negative'>↓ 3.2%</span></td>
<td><span class='status-badge bg-warning text-dark'>Review</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
</tbody>
<tfoot class='table-light'>
<tr>
<td><strong>Total</strong></td>
<td><strong>$13,430,000</strong></td>
<td><strong>39,220</strong></td>
<td><strong class='trend-positive'>↑ 14.8%</strong></td>
<td colspan='2'></td>
</tr>
</tfoot>
</table>
</div>
<div class='d-flex justify-content-between align-items-center mt-4'>
<div>
<select class='form-select form-select-sm' style='width: auto; display: inline-block;'>
<option>10 per page</option>
<option>25 per page</option>
<option>50 per page</option>
</select>
</div>
<nav>
<ul class='pagination pagination-sm mb-0'>
<li class='page-item disabled'><a class='page-link' href='#'>Previous</a></li>
<li class='page-item active'><a class='page-link' href='#'>1</a></li>
<li class='page-item'><a class='page-link' href='#'>2</a></li>
<li class='page-item'><a class='page-link' href='#'>3</a></li>
<li class='page-item'><a class='page-link' href='#'>Next</a></li>
</ul>
</nav>
</div>
</div>
</div>
<div class='row g-3 mt-4'>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-primary mb-1'>$13.4M</h3>
<small class='text-muted'>Total Revenue</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-success mb-1'>39,220</h3>
<small class='text-muted'>Units Sold</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-info mb-1'>14.8%</h3>
<small class='text-muted'>Growth Rate</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-warning mb-1'>5</h3>
<small class='text-muted'>Active Regions</small>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(dataTableReport);
pdf.SaveAs("data-table-report.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
string dataTableReport = @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='___PROTECTED_URL_132___ rel='stylesheet'>
<style>
.table-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
border-radius: 10px 10px 0 0;
}
.table-container {
background: white;
border-radius: 0 0 10px 10px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
overflow: hidden;
}
.table th {
background: #f8f9fa;
font-weight: 600;
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 0.5px;
}
.status-badge {
padding: 0.35em 0.65em;
border-radius: 0.25rem;
font-weight: 600;
font-size: 0.75rem;
}
.trend-positive { color: #198754; font-weight: 700; }
.trend-negative { color: #dc3545; font-weight: 700; }
@media print {
.table-container { page-break-inside: avoid; }
}
</style>
</head>
<body class='bg-light'>
<div class='container py-5'>
<div class='table-container'>
<div class='table-header'>
<div class='row align-items-center'>
<div class='col-md-8'>
<h2 class='mb-2'>Sales Performance Report</h2>
<p class='mb-0 opacity-75'>Q4 2024 Regional Analysis</p>
</div>
<div class='col-md-4 text-end'>
<div class='btn-group btn-group-sm'>
<button class='btn btn-light'>Export</button>
<button class='btn btn-light'>Filter</button>
<button class='btn btn-light'>Sort</button>
</div>
</div>
</div>
</div>
<div class='p-4'>
<div class='row mb-3'>
<div class='col-md-4'>
<input type='text' class='form-control form-control-sm' placeholder='Search regions...'>
</div>
<div class='col-md-8 text-end'>
<span class='text-muted small'>Showing 1-10 of 48 results</span>
</div>
</div>
<div class='table-responsive'>
<table class='table table-hover align-middle'>
<thead>
<tr>
<th>Region</th>
<th>Revenue</th>
<th>Units Sold</th>
<th>Growth</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>North America</strong><br>
<small class='text-muted'>USA, Canada, Mexico</small>
</td>
<td>$4,280,000</td>
<td>12,450</td>
<td><span class='trend-positive'>↑ 18.5%</span></td>
<td><span class='status-badge bg-success text-white'>Exceeding</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Europe</strong><br>
<small class='text-muted'>EU, UK, Switzerland</small>
</td>
<td>$3,650,000</td>
<td>10,890</td>
<td><span class='trend-positive'>↑ 12.3%</span></td>
<td><span class='status-badge bg-success text-white'>On Track</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Asia Pacific</strong><br>
<small class='text-muted'>Japan, Australia, Singapore</small>
</td>
<td>$2,940,000</td>
<td>8,320</td>
<td><span class='trend-positive'>↑ 24.7%</span></td>
<td><span class='status-badge bg-primary text-white'>Growing</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Latin America</strong><br>
<small class='text-muted'>Brazil, Argentina, Chile</small>
</td>
<td>$1,580,000</td>
<td>4,670</td>
<td><span class='trend-positive'>↑ 8.9%</span></td>
<td><span class='status-badge bg-info text-white'>Stable</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Middle East</strong><br>
<small class='text-muted'>UAE, Saudi Arabia, Israel</small>
</td>
<td>$980,000</td>
<td>2,890</td>
<td><span class='trend-negative'>↓ 3.2%</span></td>
<td><span class='status-badge bg-warning text-dark'>Review</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
</tbody>
<tfoot class='table-light'>
<tr>
<td><strong>Total</strong></td>
<td><strong>$13,430,000</strong></td>
<td><strong>39,220</strong></td>
<td><strong class='trend-positive'>↑ 14.8%</strong></td>
<td colspan='2'></td>
</tr>
</tfoot>
</table>
</div>
<div class='d-flex justify-content-between align-items-center mt-4'>
<div>
<select class='form-select form-select-sm' style='width: auto; display: inline-block;'>
<option>10 per page</option>
<option>25 per page</option>
<option>50 per page</option>
</select>
</div>
<nav>
<ul class='pagination pagination-sm mb-0'>
<li class='page-item disabled'><a class='page-link' href='#'>Previous</a></li>
<li class='page-item active'><a class='page-link' href='#'>1</a></li>
<li class='page-item'><a class='page-link' href='#'>2</a></li>
<li class='page-item'><a class='page-link' href='#'>3</a></li>
<li class='page-item'><a class='page-link' href='#'>Next</a></li>
</ul>
</nav>
</div>
</div>
</div>
<div class='row g-3 mt-4'>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-primary mb-1'>$13.4M</h3>
<small class='text-muted'>Total Revenue</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-success mb-1'>39,220</h3>
<small class='text-muted'>Units Sold</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-info mb-1'>14.8%</h3>
<small class='text-muted'>Growth Rate</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-warning mb-1'>5</h3>
<small class='text-muted'>Active Regions</small>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(dataTableReport);
pdf.SaveAs("data-table-report.pdf");
Imports IronPdf
Dim renderer = New ChromePdfRenderer()
Dim dataTableReport As String = "
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='___PROTECTED_URL_132___ rel='stylesheet'>
<style>
.table-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
border-radius: 10px 10px 0 0;
}
.table-container {
background: white;
border-radius: 0 0 10px 10px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
overflow: hidden;
}
.table th {
background: #f8f9fa;
font-weight: 600;
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 0.5px;
}
.status-badge {
padding: 0.35em 0.65em;
border-radius: 0.25rem;
font-weight: 600;
font-size: 0.75rem;
}
.trend-positive { color: #198754; font-weight: 700; }
.trend-negative { color: #dc3545; font-weight: 700; }
@media print {
.table-container { page-break-inside: avoid; }
}
</style>
</head>
<body class='bg-light'>
<div class='container py-5'>
<div class='table-container'>
<div class='table-header'>
<div class='row align-items-center'>
<div class='col-md-8'>
<h2 class='mb-2'>Sales Performance Report</h2>
<p class='mb-0 opacity-75'>Q4 2024 Regional Analysis</p>
</div>
<div class='col-md-4 text-end'>
<div class='btn-group btn-group-sm'>
<button class='btn btn-light'>Export</button>
<button class='btn btn-light'>Filter</button>
<button class='btn btn-light'>Sort</button>
</div>
</div>
</div>
</div>
<div class='p-4'>
<div class='row mb-3'>
<div class='col-md-4'>
<input type='text' class='form-control form-control-sm' placeholder='Search regions...'>
</div>
<div class='col-md-8 text-end'>
<span class='text-muted small'>Showing 1-10 of 48 results</span>
</div>
</div>
<div class='table-responsive'>
<table class='table table-hover align-middle'>
<thead>
<tr>
<th>Region</th>
<th>Revenue</th>
<th>Units Sold</th>
<th>Growth</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>North America</strong><br>
<small class='text-muted'>USA, Canada, Mexico</small>
</td>
<td>$4,280,000</td>
<td>12,450</td>
<td><span class='trend-positive'>↑ 18.5%</span></td>
<td><span class='status-badge bg-success text-white'>Exceeding</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Europe</strong><br>
<small class='text-muted'>EU, UK, Switzerland</small>
</td>
<td>$3,650,000</td>
<td>10,890</td>
<td><span class='trend-positive'>↑ 12.3%</span></td>
<td><span class='status-badge bg-success text-white'>On Track</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Asia Pacific</strong><br>
<small class='text-muted'>Japan, Australia, Singapore</small>
</td>
<td>$2,940,000</td>
<td>8,320</td>
<td><span class='trend-positive'>↑ 24.7%</span></td>
<td><span class='status-badge bg-primary text-white'>Growing</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Latin America</strong><br>
<small class='text-muted'>Brazil, Argentina, Chile</small>
</td>
<td>$1,580,000</td>
<td>4,670</td>
<td><span class='trend-positive'>↑ 8.9%</span></td>
<td><span class='status-badge bg-info text-white'>Stable</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
<tr>
<td>
<strong>Middle East</strong><br>
<small class='text-muted'>UAE, Saudi Arabia, Israel</small>
</td>
<td>$980,000</td>
<td>2,890</td>
<td><span class='trend-negative'>↓ 3.2%</span></td>
<td><span class='status-badge bg-warning text-dark'>Review</span></td>
<td><button class='btn btn-sm btn-outline-primary'>Details</button></td>
</tr>
</tbody>
<tfoot class='table-light'>
<tr>
<td><strong>Total</strong></td>
<td><strong>$13,430,000</strong></td>
<td><strong>39,220</strong></td>
<td><strong class='trend-positive'>↑ 14.8%</strong></td>
<td colspan='2'></td>
</tr>
</tfoot>
</table>
</div>
<div class='d-flex justify-content-between align-items-center mt-4'>
<div>
<select class='form-select form-select-sm' style='width: auto; display: inline-block;'>
<option>10 per page</option>
<option>25 per page</option>
<option>50 per page</option>
</select>
</div>
<nav>
<ul class='pagination pagination-sm mb-0'>
<li class='page-item disabled'><a class='page-link' href='#'>Previous</a></li>
<li class='page-item active'><a class='page-link' href='#'>1</a></li>
<li class='page-item'><a class='page-link' href='#'>2</a></li>
<li class='page-item'><a class='page-link' href='#'>3</a></li>
<li class='page-item'><a class='page-link' href='#'>Next</a></li>
</ul>
</nav>
</div>
</div>
</div>
<div class='row g-3 mt-4'>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-primary mb-1'>$13.4M</h3>
<small class='text-muted'>Total Revenue</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-success mb-1'>39,220</h3>
<small class='text-muted'>Units Sold</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-info mb-1'>14.8%</h3>
<small class='text-muted'>Growth Rate</small>
</div>
</div>
</div>
<div class='col-md-3'>
<div class='card text-center'>
<div class='card-body'>
<h3 class='text-warning mb-1'>5</h3>
<small class='text-muted'>Active Regions</small>
</div>
</div>
</div>
</div>
</div>
</body>
</html>"
Dim pdf = renderer.RenderHtmlAsPdf(dataTableReport)
pdf.SaveAs("data-table-report.pdf")
此程式碼生成了一個複雜的資料表報告,具有漸變頁眉、響應桌、狀態徽章和摘要指標。 IronPDF 的 Chrome 渲染引擎保存了所有 Bootstrap 樣式,包含桌子懸停效果、徽章顏色和分頁控制項 — 能力超出了傳統 PDF 檢視器的應用範圍。 該引擎還支持動態內容的JavaScript 渲染,自訂字型和UTF-8 國際字元。
相對於 PrizmDoc 檢視器的主要優勢:
- 直接 HTML 表格渲染無需轉換
- 全面支持 Bootstrap 元件
- 漸層背景和現代 CSS
- 具有正確分頁的響應式表格佈局
- 支持複雜的 JavaScript 圖表
- 列印媒體 CSS 處理
欲了解更多 Bootstrap PDF 生成的詳細資訊,請參閱完整的渲染文件。 開發人員還可以探索Angular 到 PDF 的轉換以及其他JavaScript 框架支援。## IronPDF 和 PrizmDoc 檢視器之間的授權費用如何比較?
在審查了這兩個元件的技術結構和可用功能後,下述內容概述了授權價格。 這很重要,因為開發人員旨在在預算限制內滿足需求。
IronPDF 的授權選項有哪些?
IronPDF 的授權起價為$999,適用於單一開發者。 IronPDF 提供靈活的授權選項,包括開發授權、部署授權和擴展選項,以獲得持續的支持和更新。
對於在為多個客戶服務的公司或代理工作的開發人員,IronPDF 提供分級授權,可以根據團隊規模和專案數量進行調整。 隨著需求的演變,IronPDF 提供授權升級路徑。
所有 IronPDF 的授權包都包括1 年的支持和更新。 閱讀更多有關授權包、級別和價格的資訊。 開發人員還可以以各種方式應用授權金鑰,包括Web.config和環境變數。
PrizmDoc 檢視器的授權選項有哪些?
自我託管 `PrizmDoc` 的成本是多少?
自我託管的 PrizmDoc 伺服器提供年度授權。 聯絡 Accusoft 以獲取 PrizmDoc 檢視器的當前價格和可用套件。
基於雲的 `PrizmDoc` 的成本是多少?
此授權涵蓋基於雲的 PrizmDoc 檢視器服務,並根據交易量進行縮放。
術語:
Transaction 指的是向 PrizmDoc 檢視器伺服器發送請求並接收輸出(生成的文件)。
Prepaid Buckets 意味著支付一次並接收不會過期的交易。
雲定價是基於使用情況,並隨著交易量的增長而擴大。 聯絡 Accusoft 查詢當前雲定價級別和費率。
教程快速存取
獲取 C# IronPDF 快速入門手冊
免費的 PDF 資源指導,簡化了 .NET 的 PDF 開發,內含操作指南,展示如何在 C# 和 VB.NET 專案中操縱、編輯、生成和儲存 PDF。
下載指南PrizmDoc 檢視器是其各自所有者的註冊商標。 本網站與 Accusoft 的 PrizmDoc 檢視器無關聯、未獲其認可或贊助。 所有產品名稱、徽標和品牌均為其各自所有者的財產。 比較僅供資訊參考,並反映了撰寫時的公開可用資訊。常見問題
如何在C#中將HTML轉換為PDF?
您可以使用IronPDF的RenderHtmlAsPdf方法將HTML字串轉換成PDF。也可以使用RenderHtmlFileAsPdf將HTML文件轉換為PDF。
使用IronPDF進行PDF轉換有何優勢?
IronPDF提供一個簡單的本地PDF呈現解決方案,支援離線工作且不需要非同步編程。而PrizmDoc Viewer則透過REST API運行,需要網路連接以進行遠端伺服器互動。
我可以使用PDF程式庫合併多個PDF文件嗎?
可以,使用IronPDF,您可以使用MergePdf方法合併多個PDF,使您能夠無縫地合併文件。
IronPDF如何處理PDF到圖像的轉換?
IronPDF允許您利用其內建方法輕鬆將PDF頁面轉換為圖像,提供一種較其他軟體更簡便的方法。
IronPDF中的頁首和頁尾自訂選項有哪些?
IronPDF提供廣泛的功能來設定頁首和頁尾屬性,使用簡單的程式結構使您能輕鬆自訂文件。
IronPDF適合用於離線PDF處理嗎?
是的,IronPDF支援離線PDF處理,意味著您可以在不需要網路連接的情況下工作,而這是一些必需遠端伺服器互動的方案所不具備的。
IronPDF授權的成本結構是什麼?
IronPDF授權起價$699,適用於單個專案和一名開發者,並提供針對公司和SaaS服務的可擴展選項,是一種具成本效益的一次性付款解決方案。
我可以免費使用IronPDF進行開發嗎?
是的,IronPDF提供無時間限制的免費開發,並提供30天的部署試用以便為您的專案上線。
PrizmDoc Viewer如何處理HTML到PDF的轉換?
PrizmDoc Viewer使用REST API進行HTML到PDF轉換,需要非同步編程及網路連接以進行遠端伺服器互動。
託管PrizmDoc伺服器的系統要求是什麼?
自我託管PrizmDoc伺服器至少需要32GB RAM和4核CPU,以滿足其處理需求。
IronPDF完全相容於.NET 10嗎?
是的,IronPDF支援.NET 10(以及.NET 9, 8, 7, 6, .NET Core, .NET Standard和.NET Framework)。它透過NuGet安裝,適用於Windows、Linux和macOS,使用其原生的基於Chrome的渲染器在.NET 10應用程式中提供像素完美的HTML到PDF渲染。












