跳過到頁腳內容
產品比較

Accusoft Prizmdoc PDF Viewer教程和比較

Accusoft PDF Viewer 為 .NET 提供 HTML 至 PDF 的功能以及其他 PDF 編輯與操作任務。 IronPDF 也能以程式化的方式完成這些相同的任務,為您的 C# 專案節省時間與精力。

讓我們比較兩者,找出最適合您專案的譯文。

比較 IronPDF 與 Accusoft PDF Viewer

  • 將 HTML 轉換為 PDF
  • 為 PDF 設定頁首與頁尾
  • 將 PDF 轉換為影像檔案
  • 比較授權、免費試用選項等

概述

關於 IronPdf

IronPDF 是一個 C# HTML 轉 PDF 函式庫。 它使工程師能夠執行的任務包括從 HTML 字串、WebPage、URL 等來源建立 PDF 檔案,以及設定水印、書籤、頁首和頁尾等屬性。我們還可以將多個 PDF 檔案合併為一個,或將 PDF 頁面轉換為影像,反之亦然。

它對於開發是免費的,並提供 30 天的部署試用,讓您的專案可以正式啟用。

You can download a file project from this link.

關於 Accusoft PrizmDoc 檢視器

PrizmDoc 檢視器 是一個 REST API,用來處理 PDF 檔案並將其遠端轉換成其他格式。 PrizmDoc 可以將 100 種以上不同格式的檔案轉換成 PDF,並將 PDF 轉換成 PNG、JPG、TIFF 和 SVG。 它也可用於在應用程式中加入不同類型的電子簽章選項。

對照表

IronPDF PrizmDoc 檢視器
程式化處理 PDF 檔案。 程式化處理 PDF 檔案。
支援使用 Windows、Mac 或 Linux 的 .NET Core。 支援使用 Windows、Mac 或 Linux 的 .NET Core。
在本地工作 將文件傳送至遠端伺服器。
使用或不使用異步程式設計。 Must use Asynchronous Programming using `System.Threading.Tasks`.
一旦我們在系統中安裝 IronPDF,即可輕鬆離線工作。 必須連上網際網路,才能將請求傳送至 PrizmDoc 檢視器 伺服器 (雲端託管或自行託管)。
提供許多預定義的功能。 提供一些預先定義的功能。
通常需要最少行數的程式碼。 通常需要許多行的程式碼。
每個 License 計劃中每個專案的轉換數量不限。 每項雲端託管授權計劃的交易次數有限。
免費開發,無時間限制。 試用版僅有 300 宗交易。

讓我們安裝兩者並比較程式碼。


步驟 1:安裝

1.安裝 IronPdf 函式庫。

在您的專案中安裝 IronPDF 有兩種方式,採用哪一種都沒有差別。

1.1.下載 IronPdf DLL

下載 IronPDF.dll 並將其參考檔加入您的專案。 之後,您可以透過以下方式輕鬆存取命名空間 IronPdf

using IronPdf;
using IronPdf;
Imports IronPdf
$vbLabelText   $csharpLabel

現在,您可以輕鬆存取 IronPdf 所提供的功能和類別。

1.2 透過 NuGet 套件管理員安裝。

  • 套件管理員控制台:

    如果您使用套件管理員控制台,請執行下列指令:

    Install-Package IronPdf
  • 管理解決方案的套件:

    如果您正在使用 NuGet Package Manager 的 GUI,那麼請在搜尋列中瀏覽 IronPDF 並進行安裝。


從 Accusoft 安裝 PrizmDoc 檢視器

PrizmDoc 檢視器 分為兩部分,一部分是伺服器端,稱為 PrizmDoc Server,它以 Restful API 的方式運作。 另一個是我們的專案,藉由這個專案,我們打該 API 並獲得回應。

存取 PrizmDoc 伺服器

正如我們從其名稱所看到的,它是一個伺服器端應用程式,以要求(輸入)的方式取得文件的基本資訊,並將文件轉換為 PDF 檔案,然後將轉換後的 PDF 檔案以回應(輸出)的方式傳送至客戶端。 它是產品的技術核心,也就是文件處理和轉換引擎。我們可以透過兩種不同的方式來使用它,您採用哪一種方式都沒有差別,因為兩者具有相同的程式結構和技術:

1.自助式:

對於此選項,您需要安排您的伺服器,您可以 下載 PrizmDoc Server 然後進行安裝。 閱讀更多有關如何在 windows 上安裝 PrizmDoc Server。

注意:它至少需要 32 GB Ram 和 4 Core CPU,否則可能會面臨糟糕的使用體驗。

2.雲端託管:

這是 PrizmDoc 檢視器 的雲端服務,您不需要安排您的伺服器。 我們將用它來進行比較。 若要執行這項工作,建立您的帳戶,然後就會開啟首頁。 您可以從 API key 功能表中複製 API key,我們稍後會看到如何使用它。

首先,我們會看到如何與 PrizmDoc 檢視器 合作將文件轉換成 PDF 檔案的基本架構,我們會在 C# Console Application 中使用 WebClient() 直接與 Accusoft 伺服器 進行互動。

注意:以下範例僅供概念性了解 PrizmDoc 如何處理 PDF 檔案。 這篇文章有點長,所以如果您跳過這個範例,直接繼續比較也沒問題。

Accusoft 工作架構

在本範例中,我們將把 myWebpage.html 轉換成 sample.pdf 檔案。

注意:我們必須安裝 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
$vbLabelText   $csharpLabel

然後建立一個公有變數 Accusoft API Key,並將您的 API Key 貼入其中,如下所示:

static string ApiKey = "Your-API-KEY";
static string ApiKey = "Your-API-KEY";
Private Shared ApiKey As String = "Your-API-KEY"
$vbLabelText   $csharpLabel

使用 PrizmDoc 檢視器 處理 PDF 檔案有 3 個步驟:

1.將檔案上傳至 PrizmDoc 伺服器。 2.轉換上傳的檔案。 3.從 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
$vbLabelText   $csharpLabel

1.將檔案上傳至伺服器:2.

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("https://api.accusoft.com/PCCIS/V1/WorkFile");
    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("https://api.accusoft.com/PCCIS/V1/WorkFile");
    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(ByVal 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 = New Uri("https://api.accusoft.com/PCCIS/V1/WorkFile")
	Using client = New WebClient()
		client.Headers.Add("acs-api-key", ApiKey)
		client.Headers.Add("Content-Type", "application/octet-stream")
		Using reader = 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
$vbLabelText   $csharpLabel

2.將上傳的檔案轉換為 PDF:

public static async Task<JObject> Convert(string affinityToken, string fileID)
{
    var endpoint = new Uri("https://api.accusoft.com/v2/contentConverters");
    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("https://api.accusoft.com/v2/contentConverters");
    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(ByVal affinityToken As String, ByVal fileID As String) As Task(Of JObject)
	Dim endpoint = New Uri("https://api.accusoft.com/v2/contentConverters")
	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 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
$vbLabelText   $csharpLabel

以下 JSON 是 myJson 物件的結果值:

{
  "input": {
    "sources": 
    [
      {"fileId": "Auto Generated FileId Value"}
    ],
    "dest": {
      "format": "pdf"
    }
  }
}

檢查轉換是否完成

public static async Task<JObject> ConvertStatus(string processId, string affinityToken)
{
    string endpoint = "https://api.accusoft.com/v2/contentConverters/" + 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 = "https://api.accusoft.com/v2/contentConverters/" + 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(ByVal processId As String, ByVal affinityToken As String) As Task(Of JObject)
	Dim endpoint As String = "https://api.accusoft.com/v2/contentConverters/" & processId
	Using client = 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
$vbLabelText   $csharpLabel

3.從伺服器下載轉換後的檔案

public static async Task DownloadFromServer(string affinityToken, string fileId, string outfile)
{
    var endpoint = new Uri("https://api.accusoft.com/PCCIS/V1/WorkFile/" + 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("https://api.accusoft.com/PCCIS/V1/WorkFile/" + 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(ByVal affinityToken As String, ByVal fileId As String, ByVal outfile As String) As Task
	Dim endpoint = New Uri("https://api.accusoft.com/PCCIS/V1/WorkFile/" & fileId)

	Using client = New WebClient()
		client.Headers.Add("acs-api-key", ApiKey)
		client.Headers.Add("Accusoft-Affinity-Token", affinityToken)
		Dim output As New FileInfo(outfile)

		Using writeStream = output.Create()
			Dim results = Await client.DownloadDataTaskAsync(endpoint)
			Await writeStream.WriteAsync(results, 0, results.Length)
		End Using
	End Using
End Function
$vbLabelText   $csharpLabel

上述範例需要花費許多心力! 為了減少工作量,Accusoft 引進了一個 .NET 函式庫,命名為 Accusoft.PrizmDocServerSDK,它是 PrizmDoc Server REST API 的包裝程式。 讓我們看看如何在我們的 .NET 專案中安裝和使用這個函式庫

安裝 Accusoft.PrizmDocServerSDK

有兩種安裝 wrapper 的方式。

  • 套件管理員控制台:

    如果您使用套件管理員主控台,請執行下列指令:

    Install-Package Accusoft.PrizmDocServerSDK
    Install-Package Accusoft.PrizmDocServerSDK
    SHELL
  • 管理解決方案的套件:

    如果您使用 NuGet Package Manager 的 GUI,則在搜尋列中瀏覽 Accusoft.PrizmDocServerSDK 並進行安裝。

現在,您可以輕鬆存取 Accusoft.PrizmDocServer 命名空間,並透過存取來使用它:

using Accusoft.PrizmDocServer;
using Accusoft.PrizmDocServer;
Imports Accusoft.PrizmDocServer
$vbLabelText   $csharpLabel

如何教學

2. IronPDF vs PrizmDoc 檢視器 程式碼比較。

閱讀完這兩個元件的介紹與安裝後,現在就該使用這兩個元件了。 為此,我們將採用一些使用案例,並使用這兩種元件來實作。 我們希望這能提供一種方法,讓您輕鬆了解這兩種程式結構,並總結哪一種最適合您的專案。


3.將 HTML 轉換為 PDF 檔案

在我們的第一個比較中,讓我們假設一個使用個案:我們有一個名為 myWebPage.html 的網頁,並想要從中建立一個 PDF 檔案,然後將其儲存到目標位置。

3.1.IronPdf HTML to 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
$vbLabelText   $csharpLabel

上述程式碼將建立 sample.pdf 檔案,並將其儲存至專案的 bin>debug 資料夾。

您也可以像這樣指定任何路徑:PDF.SaveAs("E:/sample.pdf");

Read More 了解如何使用 IronPDF 處理 PDF 檔案。

現在,我們將使用 PrizmDoc 檢視器 來完成相同的任務,如此一來,我們的比較就變得容易了。

3.2.PrizmDoc 檢視器 HTML to PDF

在 PrizmDoc 檢視器 安裝中,我們已經討論過如何取得 Accusoft API Key,現在我們來看看如何使用它。

首先,我們向 PrizmDoc 伺服器傳送請求,並從伺服器取得回應。 此過程將需要一些時間,因此我們需要使用異步程式設計 (Asynchronous Programming)。

注意:使用 PrizmDoc 檢視器 的雲端服務建立 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("https://api.accusoft.com", "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("https://api.accusoft.com", "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

Shared Sub Main(ByVal args() As String)
	ChromePdfRenderer().GetAwaiter().GetResult()
End Sub

Private Shared Async Function ChromePdfRenderer() As Task
	' Instantiate PrizmDocServerClient object
	Dim prizmDocServer = New PrizmDocServerClient("https://api.accusoft.com", "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
$vbLabelText   $csharpLabel

閱讀更多有關如何使用 PrizmDoc 檢視器 的資訊。

3.3.HTML 到 PDF 的程式碼比較

從這些範例中,我們可以看出 IronPDF 是一種較簡單的 PDF 檔案製作方式,不需要花費太多時間。


4.圖片轉 PDF

在這個比較中,我們以一個使用案例來說明,我們需要藉由 Image 來建立一個 PDF 檔案,而且它存在於我們專案的 debug 資料夾中。 讓我們從 IronPdf 開始。

4.1.IronPDF Image to 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
$vbLabelText   $csharpLabel

Output:

此截圖是使用上述程式碼新建立的 PDF 檔 sample.pdf

Iron 2 related to 4.1.IronPDF Image to PDF。

我們可以看到使用 IronPDF 從影像建立 PDF 檔案是多麼容易。 現在,我們將使用 PrizmDoc 檢視器 執行相同的任務,並查看其產生的 PDF 檔案。

4.2.PrizmDoc 檢視器 Image to 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("https://api.accusoft.com", "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("https://api.accusoft.com", "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

Shared Sub Main(ByVal args() As String)
	ImageToPDF().GetAwaiter().GetResult()
End Sub

Private Shared Async Function ImageToPDF() As Task
	' Instantiate PrizmDocServerClient object
	Dim prizmDocServer = New PrizmDocServerClient("https://api.accusoft.com", "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
$vbLabelText   $csharpLabel

輸出:此截圖為上述程式碼新建立的 PDF 檔 sample.pdf

Prizm 2 related to 4.2.PrizmDoc 檢視器 Image to PDF

4.3.圖片至 PDF 的程式碼比較

我們可以看到,我們只需要使用 IronPdf 寫 2 行簡單的程式碼。 另一方面,使用 PrizmDoc 伺服器時,我們必須使用 Asynchronous Programming 來撰寫許多行的程式碼。 IronPDF 的輸出也會自動提供可用的全頁文件。


5.合併 PDF 檔案

在此比較中,假設我們有三個 PDF 檔案,分別命名為 A.pdf, B.pdf, 和 C.pdf. 我們希望將它們合併為一個 PDF 檔案,我們可以使用這兩個元件來完成這項任務。 首先,我們來看看如何使用 IronPDF 執行這項任務。

5.1.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
$vbLabelText   $csharpLabel

上述程式碼將建立一個 sample.pdf 檔案,它是 A.pdf, B.pdf, 和 C.pdf 的組合。

現在,我們將使用 PrizmDoc 檢視器 完成相同的任務。

5.2.PrizmDoc 檢視器 合併 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("https://api.accusoft.com", "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("https://api.accusoft.com", "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

Shared Sub Main(ByVal args() As String)
	PdfMerge().GetAwaiter().GetResult()
End Sub

Private Shared Async Function PdfMerge() As Task
	' Instantiate PrizmDocServerClient object
	Dim prizmDocServer = New PrizmDocServerClient("https://api.accusoft.com", "Your-API-KEY")
	' Pass the list of pdf files to PrizmDoc Server
	Dim result As ConversionResult = Await prizmDocServer.CombineToPdfAsync( {
		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
$vbLabelText   $csharpLabel

上述程式碼也將產生一個 sample.pdf 檔案,它是 A.pdf, B.pdf, 和 C.pdf 檔案的組合。


6.PDF 標題和頁尾

在這個比較中,假設我們有一個簡單的網頁,名為 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>
HTML

我們希望將此 WebPage 轉換為 PDF 檔案,並設定下列頁首與頁尾屬性:

  • 頁面標題在標題左側、
  • DateTime 在標頭的右側
  • 總頁數在頁尾右側。

首先,我們來看看如何與 IronPDF 合作設定頁首和頁尾。

6.1.IronPDF PDF 的頁首和頁尾。

為了處理 PDF 檔案的 Header 和 Footer,IronPDF 在 ChromePdfRenderer 類上提供了一個名為 RenderingOptions 的屬性,其使用方式如下:

  • 適用於標題:

    ChromePdfRenderer_Obj.RenderingOptions.TextHeader = new TextHeaderFooter();
    ChromePdfRenderer_Obj.RenderingOptions.TextHeader = new TextHeaderFooter();
    ChromePdfRenderer_Obj.RenderingOptions.TextHeader = New TextHeaderFooter()
    $vbLabelText   $csharpLabel
  • 適用於頁腳:

    ChromePdfRenderer_Obj.RenderingOptions.TextFooter = new TextHeaderFooter();
    ChromePdfRenderer_Obj.RenderingOptions.TextFooter = new TextHeaderFooter();
    ChromePdfRenderer_Obj.RenderingOptions.TextFooter = New TextHeaderFooter()
    $vbLabelText   $csharpLabel

我們可以在初始化 TextHeaderFooter() 時設定下列屬性:

  • CenterText 將文字列印在 Header 或 Footer 的中央。
  • LeftText 將文字列印在 Header 或 Footer 的左側。
  • RightText 將文字列印在 Header 或 Footer 的右側。
  • DrawDividerLine 它會繪製一條線,將頁面內容與 Header 或 Footer 分開。
  • FontFamily 用來指定 Header 或 Footer 的字型系列。
  • FontSize指定頁頭或頁尾的字型大小。
  • Spacing 它可以調整頁面內容與 Header 或 Footer 之間的空間。

以下一些預定義的屬性對於設定頁首或頁尾內容非常有幫助。 可以用大括弧 { } 寫成如下:

  • {page} 它會在 Header 或 Footer 中列印目前的頁碼。
  • {total-pages} 它會在 Header 或 Footer 中列印總頁數。
  • {url} 它用來列印呈現的頁面的 URL。
  • {date} 它會在 Header 或 Footer 中列印目前的日期。
  • {time} 它會在 Header 或 Footer 中列印目前的時間。
  • {html-title} 它會在頁首或頁尾列印所呈現網頁的標題。
  • {pdf-title} 它會在頁首或頁尾列印文件標題。

詳細閱讀如何使用 IronPDF 處理 Header 和 Footer。

讓我們看以下範例來實現用例,並示範如何使用上述屬性來設定 PDF 檔案的 Header 和 Footer。

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
$vbLabelText   $csharpLabel

輸出:上述程式碼新建立的 PDF 檔 sample.pdf 的截圖:

Iron Hdr Ftr related to 6.1.IronPDF PDF 的頁首和頁尾。

我們可以看到,在使用 IronPDF 創建 PDF 檔案時,使用直觀的語言來處理標頭和頁尾是多麼簡單。 現在,我們來看看如何使用 PrizmDoc 檢視器 設定頁首與頁尾。

6.2.PrizmDoc 檢視器 PDF 的頁首和頁尾。

PrizmDoc 檢視器 提供 HeaderFooterOptions 類別來處理 Header 和 Footer,其屬性如下:

  • Lines 它指定了 Header 和 Footer 的行 (當您了解以下範例時會更清楚),每一行都有以下屬性:
    • Left 在 Header 或 Footer 行的左側列印文字。
    • Center 將文字列印在 Header 或 Footer 行的左側。
    • Right 在 Header 或 Footer 行的右側列印文字。
  • FontFamily指定頁首或頁尾文字的字型系列。
  • FontSize 用來指定 Header 或 Footer 文字的字型大小。
  • 顏色可指定頁首或頁尾文字的顏色。

閱讀更多有關如何使用 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("https://api.accusoft.com", "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("https://api.accusoft.com", "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

Shared Sub Main(ByVal args() As String)
	SetHeaderFooter().GetAwaiter().GetResult()
End Sub

Private Shared Async Function SetHeaderFooter() As Task
	' Instantiate PrizmDocServerClient object with Header and footer properties
	Dim prizmDocServer = New PrizmDocServerClient("https://api.accusoft.com", "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
$vbLabelText   $csharpLabel

Output:

透過上述程式碼新建 PDF 檔案的截圖:

Prizm Hdr Ftr related to 6.2.PrizmDoc 檢視器 PDF 的頁首和頁尾。

6.3.PDF 標題和頁尾程式碼比較

我們可以看到,IronPDF 提供了更多功能來設置頁眉和頁腳屬性,與 PizmDoc 查看器相比,具有簡單的編程結構。 此外,建議 IronPDF 所產生的 PDF 檔案比 PrizmDoc 檢視器 所產生的檔案更具可讀性與吸引力。


7.將 PDF 頁面轉換成圖片

讓我們再舉一個用例:我們有一個簡單的 PDF 檔案,名為 Sample_PDF.pdf ,其中只有 2 頁。

頁一 第二頁
Page 1 related to 7.將 PDF 頁面轉換成圖片
Page 1 related to 7.將 PDF 頁面轉換成圖片

而且我們需要為每個頁面建立圖像。 首先,我們來看看如何使用 IronPDF 執行這項任務。

7.1.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
$vbLabelText   $csharpLabel

Output:

上述程式碼將會建立以下兩個 .png 影像:

頁一 圖片 第二頁 圖片
Iron Generated Image1 related to 7.1.IronPDF 將 PDF 轉換為影像。
Iron Generated Image2 related to 7.1.IronPDF 將 PDF 轉換為影像。

我們可以看到使用 IronPDF 建立每個 PDF 頁面的影像是多麼的簡單。 現在,我們將使用 PrizmDoc 檢視器 完成相同的任務。

7.2.PrizmDoc 檢視器 PDF to Image

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("https://api.accusoft.com", "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("https://api.accusoft.com", "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

Shared Sub Main(ByVal args() As String)
	PdfToImage().GetAwaiter().GetResult()
End Sub

Private Shared Async Function PdfToImage() As Task
	' Instantiate PrizmDocServerClient object
	Dim prizmDocServer = New PrizmDocServerClient("https://api.accusoft.com", "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 i
End Function
$vbLabelText   $csharpLabel

Output:

上述程式碼亦會建立以下兩張 .png 圖片:

頁一 第二頁
Prizm Generated Image1 related to 7.2.PrizmDoc 檢視器 PDF to Image
Prizm Generated Image2 related to 7.2.PrizmDoc 檢視器 PDF to Image

7.3.PDF 到圖像的程式碼比較

與 PrizmDoc 檢視器 相比,使用 IronPDF 我們可以用最少的代碼行輕鬆製作每頁的圖像,甚至不需要迭代頁面。


使用 Bootstrap 5 和 IronPDF 製作數據表格。

IronPDF 的 Chrome V8 渲染引擎為 Bootstrap 5 數據表格提供了卓越的支援,使您能夠生成具有複雜表格佈局的專業 PDF 報告。 本範例展示了漸層標頭、狀態徽章、分頁控制和摘要度量 - 這些功能展現了 IronPDF 相較於 PrizmDoc 等傳統 PDF 檢視器的優勢。

using IronPdf;

var renderer = new ChromePdfRenderer();

string dataTableReport = @"
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' 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='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' 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");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

此代碼會產生一份複雜的資料表報告,其中包含漸層式標題、反應式表格、狀態徽章和摘要指標。 IronPDF 的 Chrome 渲染引擎保留了所有 Bootstrap 风格,包括表格悬停效果、徽章颜色和分页控件 - 这些功能远远超出了传统的 PDF 浏览器。

主要優勢 vs PrizmDoc 檢視器:

  • 直接呈現 HTML 表格,無須轉換
  • 完整的 Bootstrap 元件支援
  • 漸層背景和現代 CSS
  • 具有適當分頁的回應式表格佈局

有關 Bootstrap PDF 生成的詳細資訊,請參閱 HTML to PDF Bootstrap Guide

8.授權定價

在上面的比較中,我們看到兩個元件的技術工作結構和提供的功能。 現在我們來看看這兩個元件的授權價格。 這是非常重要的,因為我們總是盡力以最低的預算來達成我們的要求。

8.1.IronPDF 授權選項。

IronPdf 授權起始價格為 $699,適用於單一開發人員的單一專案。

如果您是一家公司的工程師,或是為多家客戶提供工作的代理公司,License 的起價為 699 美元,並可根據團隊規模和專案數量調整。

以下授權僅需一次性付款。

開發人員數量 價格
1-5 $699
6-10 $799
11-20 $899
21-50 $1,199
無限制 $1,199
  • 對於擁有多個據點的公司,授權費由 $1199. 起。
  • 對於 SaaS 服務,授權費從 $1099. 起。
  • 對於免權利金的 OEM 再發行,授權費從 $1599. 起。

注意:上述所有授權套裝都附有1 年的支援與更新

閱讀更多有關 IronPdf 所有提供的授權套件。

8.2.PrizmDoc 檢視器 授權選項

自行託管選項

如果您管理自己的伺服器,則授權價格為每年 $7,900,並提供標準支援。

閱讀更多有關 PrizmDoc 檢視器 的所有套件資訊。

雲端選項

此授權涵蓋 PrizmDoc 檢視器 的雲端服務,並依據交易次數進行調整。

詞彙:

Transaction表示我們打到 PrizmDoc 檢視器 伺服器並取得輸出(結果文件)。

預付桶表示您只需支付一次,即可獲得交易,且不會過期。

交易次數 預付桶 月度 每年
200 $18
1,000 $89
2,000 $119
6,000 $254 $169 1,859美元(6,000筆交易/月)
12,000 $434 $289 $3,179 (12,000 交易/月)
25,000 $699 $499 5,459 美元 (25,000 次交易/月)
50,000 $1,199 $799 8,789美元(50,000筆交易/月)
100,000 $1,199 $1,199 10,989美元(100,000筆交易/月)
200,000 $2,549 $1,699 19,188美元(200,000筆交易/月)
300,000 $3,299 $2,199 $25,188 (300,000 交易/月)
400,000 $4,049 $2,699 31,188美元(400,000筆交易/月)
500,000 $4,799 $3,199 37,188美元(500,000筆交易/月)

教程快速存取

Html To Pdf Icon related to 教程快速存取

獲取 C# IronPDF 快速入門手冊

我們製作了一個免費的 PDF 資源指南,以協助您更輕鬆地開發 PDF for .NET,其中包含常用功能的演練以及在 C# 和 VB.NET 中操作、編輯、產生和儲存 PDFS 的範例,可供您的專案使用。

下載指南

探索 IronPdf API 參考資料

探索 IronPDF C# Library 的 API 參考資料,包括 IronPDF 所有功能、類別、方法欄位、命名空間和枚數的詳細資訊。

檢視 API 參考資料
Documentation related to 教程快速存取

請注意Accusoft's PrizmDoc 檢視器 是其各自擁有者的註冊商標。 本網站與 Accusoft"s PrizmDoc 檢視器 無關,亦未經 Accusoft"s PrizmDoc 檢視器 認可或贊助。 所有產品名稱、標誌和品牌均為其各自擁有者的財產。 比較資料僅供參考,並反映撰寫時的公開資訊。

常見問題解答

如何在 C# 中將 HTML 轉換為 PDF?

您可以使用 IronPDF 的 RenderHtmlAsPdf 方法將 HTML 字串轉換成 PDF。您也可以使用 RenderHtmlFileAsPdf 將 HTML 檔案轉換成 PDF。

與 PrizmDoc Viewer 相比,使用 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 伺服器至少需要 32 GB 記憶體和 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-to-PDF 渲染。

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。