跳過到頁腳內容
產品比較

APITemplate io和IronPDF對比C# PDF庫

身為一名 C# 開發者,我在專案中生成與處理 PDF 檔案時,經常面臨各種挑戰。 在我們的領域中,對高效、可靠且易於整合的 PDF 解決方案的需求,是一項普遍的課題。 正因如此,我決定深入探索 APITemplateIronPDF 這兩個廣受歡迎的工具,它們承諾能簡化 C# 應用程式中的 PDF 相關任務。

在這篇文章中,我將分享我使用 APITemplate 和 IronPDF 的實際經驗,比較它們的功能、效能和整合能力。 我的目標是為您提供清晰且客觀的分析,協助您為下一個專案做出明智的決策。 當我第一次接觸 APITemplate 和 IronPDF 時,就被它們在 C# 開發中解決 PDF 相關挑戰的潛力所吸引。 讓我們來看看這些工具各自提供了哪些功能。

APITemplate

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 1

APITemplate 是一項以雲端為基礎的服務,專注於從範本生成 PDF 和影像。 它提供的 API 可讓開發人員透過傳送 JSON 資料至預先定義的範本來建立文件和圖形。 在我的初步測試中,我發現 APITemplate 非常簡單易用。 我可以使用他們的網頁介面建立一個範本,然後用他們的 API 從我的 C# 應用程式中填入資料。

APITemplate 的主要功能

基於範本的生成

APITemplate 的核心優勢在於其基於範本的方法。 我可以為文件和圖片建立可重複使用的範本,這可為我節省大量重複性工作的時間。 它還提供了一個用於生成 PDF 的 markdown 模板編輯器。 您可以從與 Zapier 及其他第三方整合的可重複使用範本中產生 PDF。

JSON 資料整合

JSON 資料整合是我經常使用的一項功能。 它讓您能夠以 JSON 資料填充範本。 這使得與我的 C# 應用程式整合變得非常容易,因為我可以將物件序列化為 JSON 並傳送至 API。

API 控制台

API 控制台功能為我節省了不少時間。 有了它,我可以直接從他們的網站上預覽和測試 API 呼叫,幫助我在 C# 程式碼中實作之前調試和微調我的請求。

可自訂的頁首與頁尾

在我的 PDF 中加入自訂頁首和頁尾的功能非常有價值,尤其是在建立專業報告或發票時。 我可以輕鬆地加入頁碼、日期或公司標誌。

IronPDF

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 2

另一方面,IronPDF 是專為在 C# 應用程式中操作 PDF 而設計的 .NET 函式庫。 它提供廣泛的功能,包括 PDF 的建立、編輯和轉換。 其突出的功能之一是能夠從 HTML 生成 PDF,這對於基於 Web 的應用程式非常有用。

我第一次使用 IronPDF 的經驗是透過 NuGet 安裝,並直接將它整合到我的 C# 專案中。 它的 API 整合過程非常流暢,這意味著我可以馬上在我的專案中使用它。讓我印象深刻的是,我無須仰賴外部服務,就能以程式化的方式輕鬆建立 PDF。

我注意到的關鍵差異是 APITemplate 擅長從預定義的範本中建立文件,而 IronPDF 則在您的 C# 程式碼中提供更多自訂 PDF 操作的彈性。 APITemplate 基於雲端的特性意味著您不需要擔心 PDF 生成的伺服器資源,但它需要網際網路連線。 IronPDF 作為一個本機庫,可以離線工作,但會使用您伺服器的資源。

IronPDF 的主要功能

從 HTML 建立 PDF

IronPDF 擅長從 HTML 內容產生 PDF。 我已經廣泛使用這項功能來動態建立報表和文件。 只需將 HTML 字串甚至 URL 傳送至函式庫即可。 IronPDF 對現代網路標準的廣泛支援,意味著我從 HTML 內容產生的每個 PDF 都是高品質的文件。

PDF 操作

此功能可讓我以程式化的方式 編輯現有的 PDF。 我可以在 PDF 文件中加入文字、圖片,甚至新增頁面,這對更新報告或表格非常有用。

PDF 合併與分割

我發現這項功能在處理大型文件時特別方便。 IronPDF 可讓您輕鬆 將多個 PDF 合併為一個 PDF,或 將單一 PDF 拆分成數個檔案。

文字萃取

當我需要從 PDF 中提取文字內容進行分析或編制索引時,IronPDF 的文字提取功能就派上了用場。 它能很好地處理各種 PDF 排版,讓資料提取變得輕而易舉。

表格填寫

對於涉及自動完成表單的專案,IronPDF 表單填寫功能非常有用。 我可以程式化地填充 PDF 表單,節省手動輸入資料的時間。

數位簽名

在我的許多專案中,安全性至關重要。 IronPDF 可以讓我在 PDF 中加入 數位簽名,增強文件的真實性和安全性。

密碼保護

在處理敏感性文件時,我使用 IronPDF 來為 PDF 加入 密碼保護。 這對確保我的機密資訊安全非常有幫助。

PDF 至圖片轉換

有時候,我需要將 PDF 頁面轉換成圖片,用於預覽或縮圖。 IronPDF 讓這個過程變得簡單直接,它只需要我寫幾行程式碼,並支援各種圖片格式。

跨平台相容性

作為一名從事跨平台專案的 .NET 開發人員,我很欣賞 IronPDF 能夠在不同作業系統中無縫運作,這都要歸功於它對 .NET Standard 的支援。

為您的 C# 專案設定 IronPDF 和 APITemplate

在 C# 專案中設定這些工具相當簡單直接。 我將根據自己的經驗帶您瞭解 IronPDF 和 APITemplate 的翻譯過程。

IronPDF

要在我的 C# 專案中設定 IronPDF,我遵循以下步驟:

1.在 Visual Studio 中開啟我的專案。

2.**使用 NuGet Package Manager 安裝 IronPDF。 我使用 NuGet 套件管理員或套件管理員控制台。

1.在 NuGet Package Manager 中,搜尋 IronPDF 並安裝。

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 3

2.另外,在套件管理員控制台中,我執行:

   :ProductInstall
   :ProductInstall
SHELL

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 4

3.安裝完成後,我在 C# 檔案的頂端加入必要的 using 語句:

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

4.為了啟動授權,我在應用程式啟動初期加入這一行:

   IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY-HERE";
   IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY-HERE";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY-HERE"
$vbLabelText   $csharpLabel

就是這樣! 現在我可以開始在我的程式碼中使用 IronPDF 了。

APITemplate

對 APITemplate 而言,由於它是基於 Web 的 API,因此設定過程有點不同:

1.首先,我在他們的網站上註冊了 APITemplate 帳戶。 2.註冊後,我瀏覽到 API 區段以取得我的 API 金鑰。 3.**在我的 C# 專案中,我不需要安裝任何特定的套件。 我通常使用內建的 HttpClient 來進行 API 呼叫。

4.我安全地儲存 API 金鑰。 在開發中,我可能會使用使用者秘密:

   dotnet user-secrets set "APITemplate:ApiKey" "YOUR-API-KEY-HERE"
   dotnet user-secrets set "APITemplate:ApiKey" "YOUR-API-KEY-HERE"
SHELL

5.在我的程式碼中,我使用 API 金鑰設定 HttpClient:

   using System.Net.Http;
   using System.Net.Http.Headers;

   var client = new HttpClient();
   client.DefaultRequestHeaders.Add("X-API-KEY", Configuration["APITemplate:ApiKey"]);
   using System.Net.Http;
   using System.Net.Http.Headers;

   var client = new HttpClient();
   client.DefaultRequestHeaders.Add("X-API-KEY", Configuration["APITemplate:ApiKey"]);
Imports System.Net.Http
Imports System.Net.Http.Headers

Dim client As New HttpClient()
client.DefaultRequestHeaders.Add("X-API-KEY", Configuration("APITemplate:ApiKey"))
$vbLabelText   $csharpLabel

6.現在我可以對 APITemplate 進行 API 呼叫了。

在這個專案中,我會使用 官方範例 GitHub 的 APITemplate 專案,這個專案已經設定好了,您只需要加入範本的關鍵字。 完成這些設定後,我就可以開始在 C# 專案中使用 IronPDF 和 APITemplate 了。 IronPDF 可在我的應用程式中本機操作,而 APITemplate 則需要連線網際網路才能與其伺服器通訊。

IronPDF vs APITemplate 中的高級功能

身為一名 C# 開發者,我有機會深入探索 IronPDF 和 APITemplate 這兩款工具。 讓我們來看看其中一些令我印象深刻的高階功能。

IronPDF 進階功能

支援 JavaScript 的 HTML 至 PDF 轉換

IronPDF 的 HTML 轉 PDF 功能令人印象深刻。它不僅能渲染靜態 HTML,還能處理 JavaScript。 這對我處理動態網頁內容時,始終是一大優勢。

以下是我使用的快速範例:

var Renderer = new ChromePdfRenderer();
string htmlContent = @"
    <html>
    <body>
        <h1>Dynamic Chart</h1>
        <canvas id='myChart'></canvas>
        <script src='https://cdn.jsdelivr.net/npm/chart.js'></script>
        <script>
            var ctx = document.getElementById('myChart').getContext('2d');
            new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
                    datasets: [{
                        label: '# of Votes',
                        data: [12, 19, 3, 5, 2, 3],
                        backgroundColor: [
                            'rgba(255, 99, 132, 0.2)',
                            'rgba(54, 162, 235, 0.2)',
                            'rgba(255, 206, 86, 0.2)',
                            'rgba(75, 192, 192, 0.2)',
                            'rgba(153, 102, 255, 0.2)',
                            'rgba(255, 159, 64, 0.2)'
                        ],
                        borderColor: [
                            'rgba(255, 99, 132, 1)',
                            'rgba(54, 162, 235, 1)',
                            'rgba(255, 206, 86, 1)',
                            'rgba(75, 192, 192, 1)',
                            'rgba(153, 102, 255, 1)',
                            'rgba(255, 159, 64, 1)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    scales: {
                        y: {
                            beginAtZero: true
                        }
                    }
                }
            });
        </script>
    </body>
    </html>";
var PDF = Renderer.RenderHtmlAsPdf(htmlContent);
PDF.SaveAs("dynamic_chart.pdf");
var Renderer = new ChromePdfRenderer();
string htmlContent = @"
    <html>
    <body>
        <h1>Dynamic Chart</h1>
        <canvas id='myChart'></canvas>
        <script src='https://cdn.jsdelivr.net/npm/chart.js'></script>
        <script>
            var ctx = document.getElementById('myChart').getContext('2d');
            new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
                    datasets: [{
                        label: '# of Votes',
                        data: [12, 19, 3, 5, 2, 3],
                        backgroundColor: [
                            'rgba(255, 99, 132, 0.2)',
                            'rgba(54, 162, 235, 0.2)',
                            'rgba(255, 206, 86, 0.2)',
                            'rgba(75, 192, 192, 0.2)',
                            'rgba(153, 102, 255, 0.2)',
                            'rgba(255, 159, 64, 0.2)'
                        ],
                        borderColor: [
                            'rgba(255, 99, 132, 1)',
                            'rgba(54, 162, 235, 1)',
                            'rgba(255, 206, 86, 1)',
                            'rgba(75, 192, 192, 1)',
                            'rgba(153, 102, 255, 1)',
                            'rgba(255, 159, 64, 1)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    scales: {
                        y: {
                            beginAtZero: true
                        }
                    }
                }
            });
        </script>
    </body>
    </html>";
var PDF = Renderer.RenderHtmlAsPdf(htmlContent);
PDF.SaveAs("dynamic_chart.pdf");
Dim Renderer = New ChromePdfRenderer()
Dim htmlContent As String = "
    <html>
    <body>
        <h1>Dynamic Chart</h1>
        <canvas id='myChart'></canvas>
        <script src='https://cdn.jsdelivr.net/npm/chart.js'></script>
        <script>
            var ctx = document.getElementById('myChart').getContext('2d');
            new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
                    datasets: [{
                        label: '# of Votes',
                        data: [12, 19, 3, 5, 2, 3],
                        backgroundColor: [
                            'rgba(255, 99, 132, 0.2)',
                            'rgba(54, 162, 235, 0.2)',
                            'rgba(255, 206, 86, 0.2)',
                            'rgba(75, 192, 192, 0.2)',
                            'rgba(153, 102, 255, 0.2)',
                            'rgba(255, 159, 64, 0.2)'
                        ],
                        borderColor: [
                            'rgba(255, 99, 132, 1)',
                            'rgba(54, 162, 235, 1)',
                            'rgba(255, 206, 86, 1)',
                            'rgba(75, 192, 192, 1)',
                            'rgba(153, 102, 255, 1)',
                            'rgba(255, 159, 64, 1)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    scales: {
                        y: {
                            beginAtZero: true
                        }
                    }
                }
            });
        </script>
    </body>
    </html>"
Dim PDF = Renderer.RenderHtmlAsPdf(htmlContent)
PDF.SaveAs("dynamic_chart.pdf")
$vbLabelText   $csharpLabel

此代碼會使用 Chart.js 產生具有動態圖表的 PDF。 JavaScript 會在 PDF 製作過程中執行,產生包含渲染圖表的 PDF。 我曾用它來建立資料經常改變的動態報表,省去手動更新圖表的麻煩。

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 5

能夠嵌入外部腳本(例如本例中的 Chart.js),意味著我可以運用強大的 JavaScript 函式庫,在 PDF 中建立豐富且動態的內容。 此外,此功能可讓我在 HTML 中使用 CSS 和回應式設計技術,確保所產生的 PDF 在各種裝置和印刷格式上看起來都很棒。 我甚至使用媒體查詢來從相同的 HTML 來源建立最適合螢幕檢視和列印的 PDF。

PDF 加密和解密

安全性在我許多專案中至關重要,特別是在處理敏感資訊時。 IronPDF 的加密和解密功能在這些情況下發揮了無價的作用。

var pdf = PdfDocument.FromFile("input.pdf");
// Set user password (for opening the document)
pdf.Password = "user_password";
// Set owner password (for editing, printing, etc.)
pdf.OwnerPassword = "owner_password";
// Set specific permissions
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.NoEdit;
pdf.SaveAs("highly_secured.pdf");
var pdf = PdfDocument.FromFile("input.pdf");
// Set user password (for opening the document)
pdf.Password = "user_password";
// Set owner password (for editing, printing, etc.)
pdf.OwnerPassword = "owner_password";
// Set specific permissions
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.NoEdit;
pdf.SaveAs("highly_secured.pdf");
Dim pdf = PdfDocument.FromFile("input.pdf")
' Set user password (for opening the document)
pdf.Password = "user_password"
' Set owner password (for editing, printing, etc.)
pdf.OwnerPassword = "owner_password"
' Set specific permissions
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.NoEdit
pdf.SaveAs("highly_secured.pdf")
$vbLabelText   $csharpLabel

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 6

此程式碼不僅使用使用者密碼加密 PDF,還設定了擁有者密碼,可細緻控制 權限。 我可以明確指定使用者可以或不可以對 PDF 進行哪些操作,例如列印或複製內容。

對於解密,我經常使用這種方法:

try
{
    var pdf = PdfDocument.FromFile("encrypted.pdf", "user_password");
    pdf.SecuritySettings.RemovePasswordsAndEncryption();
    pdf.SaveAs("decrypted.pdf");
    Console.WriteLine("PDF decrypted successfully!");
}
catch (Exception ex)
{
    Console.WriteLine($"Decryption failed: {ex.Message}");
}
try
{
    var pdf = PdfDocument.FromFile("encrypted.pdf", "user_password");
    pdf.SecuritySettings.RemovePasswordsAndEncryption();
    pdf.SaveAs("decrypted.pdf");
    Console.WriteLine("PDF decrypted successfully!");
}
catch (Exception ex)
{
    Console.WriteLine($"Decryption failed: {ex.Message}");
}
Try
	Dim pdf = PdfDocument.FromFile("encrypted.pdf", "user_password")
	pdf.SecuritySettings.RemovePasswordsAndEncryption()
	pdf.SaveAs("decrypted.pdf")
	Console.WriteLine("PDF decrypted successfully!")
Catch ex As Exception
	Console.WriteLine($"Decryption failed: {ex.Message}")
End Try
$vbLabelText   $csharpLabel

此代碼嘗試使用使用者密碼開啟加密的 PDF,移除所有安全限制,並將其儲存為未加密的新檔案。try-catch 區塊有助於處理密碼可能不正確的情況。

我已經在各種情境中使用過這些功能,例如建立安全的文件管理系統,不同的使用者有不同等級的 PDF 存取權限。 例如,在醫療記錄系統中,我確保對敏感的病患資訊進行加密,只有授權人員才能存取。

PDF壓縮

在處理大量 PDF 時,檔案大小成為關鍵因素。 IronPDF 的 壓縮功能在管理儲存空間和頻寬限制方面,是您的救星。

以下是一個更進階的例子,說明我如何使用壓縮:

using IronPdf;
using System.IO;
using PdfDocument = IronPdf.PdfDocument;

var PDF = PdfDocument.FromFile(@"F:/Test.pdf");
// Compress images
PDF.CompressImages(80); // 80% quality
// Compress fonts
PDF.CompressStructTree();
// Save the compressed PDF
PDF.SaveAs(@"F:/highly_compressed.pdf");
// Compare file sizes
var originalSize = new FileInfo(@"F:/Test.pdf").Length;
var compressedSize = new FileInfo(@"F:/highly_compressed.pdf").Length;
var compressionRatio = (1 - (double)compressedSize / originalSize) * 100;
Console.WriteLine($"Original size: {originalSize / 1024} KB");
Console.WriteLine($"Compressed size: {compressedSize / 1024} KB");
Console.WriteLine($"Compression ratio: {compressionRatio:F2}%");
using IronPdf;
using System.IO;
using PdfDocument = IronPdf.PdfDocument;

var PDF = PdfDocument.FromFile(@"F:/Test.pdf");
// Compress images
PDF.CompressImages(80); // 80% quality
// Compress fonts
PDF.CompressStructTree();
// Save the compressed PDF
PDF.SaveAs(@"F:/highly_compressed.pdf");
// Compare file sizes
var originalSize = new FileInfo(@"F:/Test.pdf").Length;
var compressedSize = new FileInfo(@"F:/highly_compressed.pdf").Length;
var compressionRatio = (1 - (double)compressedSize / originalSize) * 100;
Console.WriteLine($"Original size: {originalSize / 1024} KB");
Console.WriteLine($"Compressed size: {compressedSize / 1024} KB");
Console.WriteLine($"Compression ratio: {compressionRatio:F2}%");
Imports IronPdf
Imports System.IO
Imports PdfDocument = IronPdf.PdfDocument

Private PDF = PdfDocument.FromFile("F:/Test.pdf")
' Compress images
PDF.CompressImages(80) ' 80% quality
' Compress fonts
PDF.CompressStructTree()
' Save the compressed PDF
PDF.SaveAs("F:/highly_compressed.pdf")
' Compare file sizes
Dim originalSize = (New FileInfo("F:/Test.pdf")).Length
Dim compressedSize = (New FileInfo("F:/highly_compressed.pdf")).Length
Dim compressionRatio = (1 - CDbl(compressedSize) / originalSize) * 100
Console.WriteLine($"Original size: {originalSize \ 1024} KB")
Console.WriteLine($"Compressed size: {compressedSize \ 1024} KB")
Console.WriteLine($"Compression ratio: {compressionRatio:F2}%")
$vbLabelText   $csharpLabel

以下是結果:

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 7

我發現這種技術組合在減少檔案大小方面非常有效,而且不會對品質造成重大影響。

我已經在各種場合中使用過此功能:

  1. 電子郵件附件:透過電子郵件傳送 PDF 檔案時,我會將其壓縮,以確保檔案大小不超過附件大小限制。
  2. 網頁應用程式:對於需要使用者下載的 PDF 檔案,壓縮有助於縮短載入時間並減少頻寬使用量。
  3. 歸檔:在長期儲存大量 PDF 檔案時,壓縮技術能顯著降低儲存成本。

在一個專案中,我為一家法律事務所開發文件管理系統。 他們有數以千計 PDF 格式的案例檔案,其中許多是檔案大小很大的掃描文件。 透過實施這項壓縮技術,我們降低了他們超過 60% 的儲存需求,大幅節省雲端儲存帳單的成本。

數位簽名

在 PDF 中加入 數位簽名是許多商業流程的必備功能,可確保文件的真實性和不可抵賴性。 IronPDF 使這項複雜的任務出奇地簡單。 以下是我如何實作數位簽章的詳細範例:

using IronPdf;
using IronPdf.Signing;

var renderer = new ChromePdfRenderer();
var pdf = PdfDocument.FromFile(@"F:/Contract.pdf");
var signature = new IronPdf.Signing.PdfSignature(@"F:/Iron.pfx", "123")
{
    // Step 3. Optional signing options and a handwritten signature graphic
    SigningContact = "support@ironsoftware.com",
    SigningLocation = "New York, USA",
    SigningReason = "Signing PDF"
};
pdf.Sign(signature);
pdf.SaveAs(@"F:/signed.pdf");
using IronPdf;
using IronPdf.Signing;

var renderer = new ChromePdfRenderer();
var pdf = PdfDocument.FromFile(@"F:/Contract.pdf");
var signature = new IronPdf.Signing.PdfSignature(@"F:/Iron.pfx", "123")
{
    // Step 3. Optional signing options and a handwritten signature graphic
    SigningContact = "support@ironsoftware.com",
    SigningLocation = "New York, USA",
    SigningReason = "Signing PDF"
};
pdf.Sign(signature);
pdf.SaveAs(@"F:/signed.pdf");
Imports IronPdf
Imports IronPdf.Signing

Private renderer = New ChromePdfRenderer()
Private pdf = PdfDocument.FromFile("F:/Contract.pdf")
Private signature = New IronPdf.Signing.PdfSignature("F:/Iron.pfx", "123") With {
	.SigningContact = "support@ironsoftware.com",
	.SigningLocation = "New York, USA",
	.SigningReason = "Signing PDF"
}
pdf.Sign(signature)
pdf.SaveAs("F:/signed.pdf")
$vbLabelText   $csharpLabel

我已在數個實際應用中使用此功能:

  1. 合約管理系統:我們為一家需要以電子方式發送和接收簽署合約的公司實作了此系統。 數位簽章確保了合約的法律效力。
  2. 病歷系統:在某醫療保健應用程式中,我們採用數位簽章機制,讓醫師能夠在病歷與處方箋上簽署確認。
  3. 政府文件處理:我們為某政府機關建置了一套系統,可對官方文件進行數位簽章。

PDF 分割與合併

分割和合併 PDFs 的能力是我在文件管理系統中經常使用的基本功能。 IronPDF 對這些功能的實現既強大又靈活。 以下是一個更進階的範例:分割與合併 PDF:

using IronPdf;
class Program
{
    static void Main(string[] args)
    {
        // Create first PDF with three pages
        const string html_a = @"
            <h1>Document A</h1>
            <p>This is the first page of Document A.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document A - Page 2</h2>
            <p>This is the second page of Document A.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document A - Page 3</h2>
            <p>This is the third and final page of Document A.</p>";
        // Create second PDF with two pages
        const string html_b = @"
            <h1>Document B</h1>
            <p>Welcome to the first page of Document B.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document B - Page 2</h2>
            <p>This is the second and last page of Document B.</p>";
        // Render HTML to PDF
        var renderer = new ChromePdfRenderer();
        var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
        var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
        // Merge PDFs
        var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
        merged.SaveAs(@"F:/IronPdf/MergedDocument.pdf");
        Console.WriteLine("Merged PDF created: MergedDocument.pdf");
        // Load the merged PDF
        var pdf = PdfDocument.FromFile(@"F:/IronPdf/MergedDocument.pdf");
        // Extract the first page
        var firstPage = pdf.CopyPage(0);
        firstPage.SaveAs(@"F:/IronPdf/FirstPageOnly.pdf");
        Console.WriteLine("First page extracted: FirstPageOnly.pdf");
        // Extract pages 2 to 4 (note: index starts at 0)
        var middlePages = pdf.CopyPages(1, 3);
        middlePages.SaveAs(@"F:/IronPdf/Pages2to4.pdf");
        Console.WriteLine("Pages 2 to 4 extracted: Pages2to4.pdf");
        Console.WriteLine("Process completed. Press any key to exit.");
        Console.ReadKey();
    }
}
using IronPdf;
class Program
{
    static void Main(string[] args)
    {
        // Create first PDF with three pages
        const string html_a = @"
            <h1>Document A</h1>
            <p>This is the first page of Document A.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document A - Page 2</h2>
            <p>This is the second page of Document A.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document A - Page 3</h2>
            <p>This is the third and final page of Document A.</p>";
        // Create second PDF with two pages
        const string html_b = @"
            <h1>Document B</h1>
            <p>Welcome to the first page of Document B.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document B - Page 2</h2>
            <p>This is the second and last page of Document B.</p>";
        // Render HTML to PDF
        var renderer = new ChromePdfRenderer();
        var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
        var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
        // Merge PDFs
        var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
        merged.SaveAs(@"F:/IronPdf/MergedDocument.pdf");
        Console.WriteLine("Merged PDF created: MergedDocument.pdf");
        // Load the merged PDF
        var pdf = PdfDocument.FromFile(@"F:/IronPdf/MergedDocument.pdf");
        // Extract the first page
        var firstPage = pdf.CopyPage(0);
        firstPage.SaveAs(@"F:/IronPdf/FirstPageOnly.pdf");
        Console.WriteLine("First page extracted: FirstPageOnly.pdf");
        // Extract pages 2 to 4 (note: index starts at 0)
        var middlePages = pdf.CopyPages(1, 3);
        middlePages.SaveAs(@"F:/IronPdf/Pages2to4.pdf");
        Console.WriteLine("Pages 2 to 4 extracted: Pages2to4.pdf");
        Console.WriteLine("Process completed. Press any key to exit.");
        Console.ReadKey();
    }
}
Imports IronPdf
Friend Class Program
	Shared Sub Main(ByVal args() As String)
		' Create first PDF with three pages
		Const html_a As String = "
            <h1>Document A</h1>
            <p>This is the first page of Document A.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document A - Page 2</h2>
            <p>This is the second page of Document A.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document A - Page 3</h2>
            <p>This is the third and final page of Document A.</p>"
		' Create second PDF with two pages
		Const html_b As String = "
            <h1>Document B</h1>
            <p>Welcome to the first page of Document B.</p>
            <div style='page-break-after: always;'></div>
            <h2>Document B - Page 2</h2>
            <p>This is the second and last page of Document B.</p>"
		' Render HTML to PDF
		Dim renderer = New ChromePdfRenderer()
		Dim pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)
		Dim pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)
		' Merge PDFs
		Dim merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b)
		merged.SaveAs("F:/IronPdf/MergedDocument.pdf")
		Console.WriteLine("Merged PDF created: MergedDocument.pdf")
		' Load the merged PDF
		Dim pdf = PdfDocument.FromFile("F:/IronPdf/MergedDocument.pdf")
		' Extract the first page
		Dim firstPage = pdf.CopyPage(0)
		firstPage.SaveAs("F:/IronPdf/FirstPageOnly.pdf")
		Console.WriteLine("First page extracted: FirstPageOnly.pdf")
		' Extract pages 2 to 4 (note: index starts at 0)
		Dim middlePages = pdf.CopyPages(1, 3)
		middlePages.SaveAs("F:/IronPdf/Pages2to4.pdf")
		Console.WriteLine("Pages 2 to 4 extracted: Pages2to4.pdf")
		Console.WriteLine("Process completed. Press any key to exit.")
		Console.ReadKey()
	End Sub
End Class
$vbLabelText   $csharpLabel

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 8

以下是由程式碼產生的合併文件:

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 9

表格填寫

自動化表格填寫在我的許多專案中都大大節省了時間。 IronPDF 可以讓我以程式化的方式填寫 PDF 表單,這對於處理大量表單或建立個人化文件而言非常寶貴。 以下是一個更全面的填表範例:

using IronPdf;
using System;

// Load the combined form
PdfDocument pdf = PdfDocument.FromFile(@"F:/completeForm.pdf");

// Handle radio buttons
var radioForm = pdf.Form.FindFormField("traveltype");
radioForm.Value = "Airplane";

// Handle checkbox
var checkboxForm = pdf.Form.FindFormField("taskCompleted");
checkboxForm.Value = "Yes";

// Handle combobox
var comboboxForm = pdf.Form.FindFormField("priority");
comboboxForm.Value = "Low";

// Print out all the available choices for combobox
foreach (var choice in comboboxForm.Choices)
{
    Console.WriteLine(choice);
}

// Handle text inputs
pdf.Form.FindFormField("firstname").Value = "John";
pdf.Form.FindFormField("lastname").Value = "Smith";

// Handle text area
pdf.Form.FindFormField("address").Value = "Iron Software\r\n205 N. Michigan Ave.";

// Save the edited PDF
pdf.SaveAs(@"F:/completeFormEdited.pdf");
using IronPdf;
using System;

// Load the combined form
PdfDocument pdf = PdfDocument.FromFile(@"F:/completeForm.pdf");

// Handle radio buttons
var radioForm = pdf.Form.FindFormField("traveltype");
radioForm.Value = "Airplane";

// Handle checkbox
var checkboxForm = pdf.Form.FindFormField("taskCompleted");
checkboxForm.Value = "Yes";

// Handle combobox
var comboboxForm = pdf.Form.FindFormField("priority");
comboboxForm.Value = "Low";

// Print out all the available choices for combobox
foreach (var choice in comboboxForm.Choices)
{
    Console.WriteLine(choice);
}

// Handle text inputs
pdf.Form.FindFormField("firstname").Value = "John";
pdf.Form.FindFormField("lastname").Value = "Smith";

// Handle text area
pdf.Form.FindFormField("address").Value = "Iron Software\r\n205 N. Michigan Ave.";

// Save the edited PDF
pdf.SaveAs(@"F:/completeFormEdited.pdf");
Imports Microsoft.VisualBasic
Imports IronPdf
Imports System

' Load the combined form
Private pdf As PdfDocument = PdfDocument.FromFile("F:/completeForm.pdf")

' Handle radio buttons
Private radioForm = pdf.Form.FindFormField("traveltype")
radioForm.Value = "Airplane"

' Handle checkbox
Dim checkboxForm = pdf.Form.FindFormField("taskCompleted")
checkboxForm.Value = "Yes"

' Handle combobox
Dim comboboxForm = pdf.Form.FindFormField("priority")
comboboxForm.Value = "Low"

' Print out all the available choices for combobox
For Each choice In comboboxForm.Choices
	Console.WriteLine(choice)
Next choice

' Handle text inputs
pdf.Form.FindFormField("firstname").Value = "John"
pdf.Form.FindFormField("lastname").Value = "Smith"

' Handle text area
pdf.Form.FindFormField("address").Value = "Iron Software" & vbCrLf & "205 N. Michigan Ave."

' Save the edited PDF
pdf.SaveAs("F:/completeFormEdited.pdf")
$vbLabelText   $csharpLabel

我已在數個實際應用中使用此功能:

1.HR 入職系統: 我們建立了一個系統,可根據人力資源資料庫中的資訊自動填寫新員工文件,節省人工輸入資料的時間。

2.保險索賠處理:我們為一家保險公司建立了一個系統,可將投保人資訊預先填入索賠表格,大幅加快索賠提交流程。

3.學校申請系統:在一個教育專案中,我們實作了一套系統,可根據學生資料填寫學校申請表,讓學生和行政人員的申請程序更為簡便。

4.稅務表格生成:我們為一家會計師事務所建立了一個系統,可根據客戶的財務資料自動填寫稅務表格,在報稅季節減少錯誤並節省時間。

以程式化方式填寫表格的能力是許多業務流程自動化的關鍵因素,可大幅節省時間並減少手動資料輸入的錯誤。

水印

在 PDF 上加入 watermarks 通常是品牌、安全性或狀態指示所必需的。 IronPDF 提供靈活的水印功能,我發現它在許多專案中都很有用。 以下是我如何使用水印的詳細範例:

using IronPdf;
using IronSoftware.Drawing;

string watermarkHtml = @"
<img style='width: 250px;' src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>
<h1>Iron Software</h1>";

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Watermark</h1>");

// Apply watermark with 45 degrees rotation and 70% opacity
pdf.ApplyWatermark(watermarkHtml, rotation: 30, opacity: 90);
pdf.SaveAs("watermarkOpacity&amp;Rotation.pdf");
using IronPdf;
using IronSoftware.Drawing;

string watermarkHtml = @"
<img style='width: 250px;' src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>
<h1>Iron Software</h1>";

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Watermark</h1>");

// Apply watermark with 45 degrees rotation and 70% opacity
pdf.ApplyWatermark(watermarkHtml, rotation: 30, opacity: 90);
pdf.SaveAs("watermarkOpacity&amp;Rotation.pdf");
Imports IronPdf
Imports IronSoftware.Drawing

Private watermarkHtml As String = "
<img style='width: 250px;' src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>
<h1>Iron Software</h1>"

Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Watermark</h1>")

' Apply watermark with 45 degrees rotation and 70% opacity
pdf.ApplyWatermark(watermarkHtml, rotation:= 30, opacity:= 90)
pdf.SaveAs("watermarkOpacity&amp;Rotation.pdf")
$vbLabelText   $csharpLabel

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 10

APITemplate 進階功能

動態範本生成

APITemplate 的動態範本生成功能非常強大,可使用自訂的 JSON 資料建立高度自訂的文件。 APITemplate 的 API 支援動態元件。 您可以得到 PDF 和圖像輸出的程式碼。 在 API 控制台中,我能夠使用所見即所得編輯器輕易地產生 PDF 文件。

讓我們來看看我如何在專案中運用這些工具。

using System;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw=";
            var template_id = "bf077b23b4a407ae";
            var url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={template_id}";
            var data = new
            {
                date = "15/05/2022",
                invoice_no = "435568799",
                sender_address1 = "3244 Jurong Drive",
                sender_address2 = "Falmouth Maine 1703",
                sender_phone = "255-781-6789",
                sender_email = "dev@ironsoftware.com",
                rece_addess1 = "2354 Lakeside Drive",
                rece_addess2 = "New York 234562 ",
                rece_phone = "34333-84-223",
                rece_email = "info@ironsoftware.com",
                items = new[]
                {
                    new { item_name = "Oil", unit = 1, unit_price = 100, total = 100 },
                    new { item_name = "Rice", unit = 2, unit_price = 200, total = 400 },
                    new { item_name = "Orange", unit = 7, unit_price = 20, total = 1400 }
                },
                total = "total",
                footer_email = "info@ironsoftware.com"
            };
            var json_content = JsonSerializer.Serialize(data);
            var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
            var byteContent = new ByteArrayContent(buffer);
            Console.WriteLine(json_content);
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            var response = await client.PostAsync(url, byteContent);
            var ret = await response.Content.ReadAsStringAsync();
            var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
            if (returnContent.status == "success")
            {
                Console.WriteLine($"Downloading {returnContent.download_url}...");
                var download_response = await client.GetAsync(returnContent.download_url);
                using (var stream = await download_response.Content.ReadAsStreamAsync())
                {
                    var fileInfo = new FileInfo(@"F:/generated_document.pdf");
                    using (var fileStream = fileInfo.OpenWrite())
                    {
                        await stream.CopyToAsync(fileStream);
                    }
                }
                Console.WriteLine("PDF file has been downloaded and saved as 'generated_document.pdf'");
            }
        }
    }
}
using System;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw=";
            var template_id = "bf077b23b4a407ae";
            var url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={template_id}";
            var data = new
            {
                date = "15/05/2022",
                invoice_no = "435568799",
                sender_address1 = "3244 Jurong Drive",
                sender_address2 = "Falmouth Maine 1703",
                sender_phone = "255-781-6789",
                sender_email = "dev@ironsoftware.com",
                rece_addess1 = "2354 Lakeside Drive",
                rece_addess2 = "New York 234562 ",
                rece_phone = "34333-84-223",
                rece_email = "info@ironsoftware.com",
                items = new[]
                {
                    new { item_name = "Oil", unit = 1, unit_price = 100, total = 100 },
                    new { item_name = "Rice", unit = 2, unit_price = 200, total = 400 },
                    new { item_name = "Orange", unit = 7, unit_price = 20, total = 1400 }
                },
                total = "total",
                footer_email = "info@ironsoftware.com"
            };
            var json_content = JsonSerializer.Serialize(data);
            var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
            var byteContent = new ByteArrayContent(buffer);
            Console.WriteLine(json_content);
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            var response = await client.PostAsync(url, byteContent);
            var ret = await response.Content.ReadAsStringAsync();
            var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
            if (returnContent.status == "success")
            {
                Console.WriteLine($"Downloading {returnContent.download_url}...");
                var download_response = await client.GetAsync(returnContent.download_url);
                using (var stream = await download_response.Content.ReadAsStreamAsync())
                {
                    var fileInfo = new FileInfo(@"F:/generated_document.pdf");
                    using (var fileStream = fileInfo.OpenWrite())
                    {
                        await stream.CopyToAsync(fileStream);
                    }
                }
                Console.WriteLine("PDF file has been downloaded and saved as 'generated_document.pdf'");
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Net.Http
Imports System.Text.Json
Imports System.Threading.Tasks

Namespace csharp
	Friend Class ReturnContent
		Public Property download_url() As String
		Public Property status() As String
	End Class

	Friend Class Program
		Shared Async Function Main(ByVal args() As String) As Task
			Dim api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw="
			Dim template_id = "bf077b23b4a407ae"
			Dim url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={template_id}"
			Dim data = New With {
				Key .date = "15/05/2022",
				Key .invoice_no = "435568799",
				Key .sender_address1 = "3244 Jurong Drive",
				Key .sender_address2 = "Falmouth Maine 1703",
				Key .sender_phone = "255-781-6789",
				Key .sender_email = "dev@ironsoftware.com",
				Key .rece_addess1 = "2354 Lakeside Drive",
				Key .rece_addess2 = "New York 234562 ",
				Key .rece_phone = "34333-84-223",
				Key .rece_email = "info@ironsoftware.com",
				Key .items = {
					New With {
						Key .item_name = "Oil",
						Key .unit = 1,
						Key .unit_price = 100,
						Key .total = 100
					},
					New With {
						Key .item_name = "Rice",
						Key .unit = 2,
						Key .unit_price = 200,
						Key .total = 400
					},
					New With {
						Key .item_name = "Orange",
						Key .unit = 7,
						Key .unit_price = 20,
						Key .total = 1400
					}
				},
				Key .total = "total",
				Key .footer_email = "info@ironsoftware.com"
			}
			Dim json_content = JsonSerializer.Serialize(data)
			Dim buffer = System.Text.Encoding.UTF8.GetBytes(json_content)
			Dim byteContent = New ByteArrayContent(buffer)
			Console.WriteLine(json_content)
			Dim client = New HttpClient()
			client.DefaultRequestHeaders.Add("X-API-KEY", api_key)
			Dim response = Await client.PostAsync(url, byteContent)
			Dim ret = Await response.Content.ReadAsStringAsync()
			Dim returnContent = JsonSerializer.Deserialize(Of ReturnContent)(ret)
			If returnContent.status = "success" Then
				Console.WriteLine($"Downloading {returnContent.download_url}...")
				Dim download_response = Await client.GetAsync(returnContent.download_url)
				Using stream = Await download_response.Content.ReadAsStreamAsync()
					Dim fileInfo As New FileInfo("F:/generated_document.pdf")
					Using fileStream = fileInfo.OpenWrite()
						Await stream.CopyToAsync(fileStream)
					End Using
				End Using
				Console.WriteLine("PDF file has been downloaded and saved as 'generated_document.pdf'")
			End If
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 11

這是生成的 PDF 文件:

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 12

批量 PDF 生成

APITemplate 的批量 PDF 生成功能,在透過單次 API 呼叫建立多份文件時,是一項顯著優勢。 以下是我使用它的一個更詳細的範例:

using System;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw=";
            var template_id = "d4f77b23b4ab09fa";
            var url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={template_id}";
            var membershipCards = new List<object>
            {
                new { name = "Iron Dev 1", email = "dev1@ironsoftware.com", membership_id = "M001", expiry_date = "2024-12-31" },
                new { name = "Iron Dev 2", email = "dev2@ironsoftware.com", membership_id = "M002", expiry_date = "2025-06-30" },
                new { name = "Iron Dev 3", email = "dev3@ironsoftware.com", membership_id = "M003", expiry_date = "2024-09-15" }
            };
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            for (int i = 0; i < membershipCards.Count; i++)
            {
                var json_content = JsonSerializer.Serialize(membershipCards[i]);
                var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
                var byteContent = new ByteArrayContent(buffer);
                Console.WriteLine($"Creating PDF for {((dynamic)membershipCards[i]).name}...");
                var response = await client.PostAsync(url, byteContent);
                var ret = await response.Content.ReadAsStringAsync();
                var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
                if (returnContent.status == "success")
                {
                    Console.WriteLine($"Downloading {returnContent.download_url}...");
                    var download_response = await client.GetAsync(returnContent.download_url);
                    using (var stream = await download_response.Content.ReadAsStreamAsync())
                    {
                        var fileInfo = new FileInfo($"F:/membership_card_{i + 1}.pdf");
                        using (var fileStream = fileInfo.OpenWrite())
                        {
                            await stream.CopyToAsync(fileStream);
                        }
                    }
                    Console.WriteLine($"PDF file has been downloaded and saved as 'membership_card_{i + 1}.pdf'");
                }
                else
                {
                    Console.WriteLine($"Failed to create PDF for {((dynamic)membershipCards[i]).name}. Status: {returnContent.status}");
                }
            }
        }
    }
}
using System;
using System.IO;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw=";
            var template_id = "d4f77b23b4ab09fa";
            var url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={template_id}";
            var membershipCards = new List<object>
            {
                new { name = "Iron Dev 1", email = "dev1@ironsoftware.com", membership_id = "M001", expiry_date = "2024-12-31" },
                new { name = "Iron Dev 2", email = "dev2@ironsoftware.com", membership_id = "M002", expiry_date = "2025-06-30" },
                new { name = "Iron Dev 3", email = "dev3@ironsoftware.com", membership_id = "M003", expiry_date = "2024-09-15" }
            };
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            for (int i = 0; i < membershipCards.Count; i++)
            {
                var json_content = JsonSerializer.Serialize(membershipCards[i]);
                var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
                var byteContent = new ByteArrayContent(buffer);
                Console.WriteLine($"Creating PDF for {((dynamic)membershipCards[i]).name}...");
                var response = await client.PostAsync(url, byteContent);
                var ret = await response.Content.ReadAsStringAsync();
                var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
                if (returnContent.status == "success")
                {
                    Console.WriteLine($"Downloading {returnContent.download_url}...");
                    var download_response = await client.GetAsync(returnContent.download_url);
                    using (var stream = await download_response.Content.ReadAsStreamAsync())
                    {
                        var fileInfo = new FileInfo($"F:/membership_card_{i + 1}.pdf");
                        using (var fileStream = fileInfo.OpenWrite())
                        {
                            await stream.CopyToAsync(fileStream);
                        }
                    }
                    Console.WriteLine($"PDF file has been downloaded and saved as 'membership_card_{i + 1}.pdf'");
                }
                else
                {
                    Console.WriteLine($"Failed to create PDF for {((dynamic)membershipCards[i]).name}. Status: {returnContent.status}");
                }
            }
        }
    }
}
'INSTANT VB NOTE: 'Option Strict Off' is used here since dynamic typing is used:
Option Strict Off

Imports System
Imports System.IO
Imports System.Net.Http
Imports System.Text.Json
Imports System.Threading.Tasks
Imports System.Collections.Generic

Namespace csharp
	Friend Class ReturnContent
		Public Property download_url() As String
		Public Property status() As String
	End Class

	Friend Class Program
		Shared Async Function Main(ByVal args() As String) As Task
			Dim api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw="
			Dim template_id = "d4f77b23b4ab09fa"
			Dim url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={template_id}"
			Dim membershipCards = New List(Of Object) From {
				New With {
					Key .name = "Iron Dev 1",
					Key .email = "dev1@ironsoftware.com",
					Key .membership_id = "M001",
					Key .expiry_date = "2024-12-31"
				},
				New With {
					Key .name = "Iron Dev 2",
					Key .email = "dev2@ironsoftware.com",
					Key .membership_id = "M002",
					Key .expiry_date = "2025-06-30"
				},
				New With {
					Key .name = "Iron Dev 3",
					Key .email = "dev3@ironsoftware.com",
					Key .membership_id = "M003",
					Key .expiry_date = "2024-09-15"
				}
			}
			Dim client = New HttpClient()
			client.DefaultRequestHeaders.Add("X-API-KEY", api_key)
			For i As Integer = 0 To membershipCards.Count - 1
				Dim json_content = JsonSerializer.Serialize(membershipCards(i))
				Dim buffer = System.Text.Encoding.UTF8.GetBytes(json_content)
				Dim byteContent = New ByteArrayContent(buffer)
'INSTANT VB NOTE: In the following line, Instant VB substituted 'Object' for 'dynamic' - this will work in VB with Option Strict Off:
				Console.WriteLine($"Creating PDF for {CType(membershipCards(i), Object).name}...")
				Dim response = Await client.PostAsync(url, byteContent)
				Dim ret = Await response.Content.ReadAsStringAsync()
				Dim returnContent = JsonSerializer.Deserialize(Of ReturnContent)(ret)
				If returnContent.status = "success" Then
					Console.WriteLine($"Downloading {returnContent.download_url}...")
					Dim download_response = Await client.GetAsync(returnContent.download_url)
					Using stream = Await download_response.Content.ReadAsStreamAsync()
						Dim fileInfo As New FileInfo($"F:/membership_card_{i + 1}.pdf")
						Using fileStream = fileInfo.OpenWrite()
							Await stream.CopyToAsync(fileStream)
						End Using
					End Using
					Console.WriteLine($"PDF file has been downloaded and saved as 'membership_card_{i + 1}.pdf'")
				Else
'INSTANT VB NOTE: In the following line, Instant VB substituted 'Object' for 'dynamic' - this will work in VB with Option Strict Off:
					Console.WriteLine($"Failed to create PDF for {CType(membershipCards(i), Object).name}. Status: {returnContent.status}")
				End If
			Next i
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

此代碼可在單一 API 呼叫中產生多張會員卡。 每張卡片都可自訂個別會員資訊。 以下是此代碼產生的一張卡片:

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 13

影像產生

雖然 PDF 生成是 APITemplate 的主要重點,但其圖片生成功能同樣令人印象深刻。您可以使用主控台中的圖片範本來產生社交媒體圖片。 它還提供回應式圖片智慧裁剪。橫幅生成 API 與圖片 API 相同。 以下是我使用過的較複雜的範例:

using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw=";
            var template_id = "f4377b23b4aeeed0";
            var url = $"https://rest.apitemplate.io/v2/create-image?template_id={template_id}";
            var json_content = @"{
    ""overrides"": [
        {
            ""name"": ""rect_image_bg"",
            ""stroke"": ""grey"",
            ""src"": ""https://images.unsplash.com/photo-1542401886-65d6c61db217?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxOTc1MDZ8MHwxfHNlYXJjaHwzfHxkZXNlcnR8ZW58MHwwfHx8MTYyMTUxOTI2OA&ixlib=rb-1.2.1&q=80&w=1080""
        },
        {
            ""name"": ""rect_container"",
            ""stroke"": ""grey"",
            ""backgroundColor"": ""rgba(255, 255, 255, 0.62)""
        },
        {
            ""name"": ""text_quote"",
            ""text"": ""Just witnessed the most breathtaking sunset over the Sahara. The way the light dances on the dunes, painting the sky in shades of orange and purple, is truly magical. Nature's artistry at its finest!  #DesertAdventures #SaharaSkies"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#414141""
        },
        {
            ""name"": ""text_footer"",
            ""text"": ""2024-07-30 - Twitter - iPhone 16 Pro"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#666666""
        },
        {
            ""name"": ""circle_profile"",
            ""stroke"": ""grey"",
            ""src"": ""https://images.unsplash.com/photo-1520998116484-6eeb2f72b5b9?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxOTc1MDZ8MHwxfHNlYXJjaHw2Mnx8aGFwcHl8ZW58MHwwfHx8MTYyMTY5MjkwNw&ixlib=rb-1.2.1&q=80&w=1080""
        },
        {
            ""name"": ""text_name"",
            ""text"": ""Sarah Wanderlust"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#4E4E4E""
        },
        {
            ""name"": ""text_twitter"",
            ""text"": ""@sarahexplores"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#4E4E4E""
        }
    ]
}";
            var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
            var byteContent = new ByteArrayContent(buffer);
            Console.WriteLine(json_content);
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            var response = await client.PostAsync(url, byteContent);
            var ret = await response.Content.ReadAsStringAsync();
            var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
            if (returnContent.status == "success")
            {
                Console.WriteLine($"Downloading {returnContent.download_url}...");
                var download_response = await client.GetAsync(returnContent.download_url);
                using (var stream = await download_response.Content.ReadAsStreamAsync())
                {
                    var fileInfo = new FileInfo("image.jpeg");
                    using (var fileStream = fileInfo.OpenWrite())
                    {
                        await stream.CopyToAsync(fileStream);
                    }
                }
            }
        }
    }
}
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw=";
            var template_id = "f4377b23b4aeeed0";
            var url = $"https://rest.apitemplate.io/v2/create-image?template_id={template_id}";
            var json_content = @"{
    ""overrides"": [
        {
            ""name"": ""rect_image_bg"",
            ""stroke"": ""grey"",
            ""src"": ""https://images.unsplash.com/photo-1542401886-65d6c61db217?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxOTc1MDZ8MHwxfHNlYXJjaHwzfHxkZXNlcnR8ZW58MHwwfHx8MTYyMTUxOTI2OA&ixlib=rb-1.2.1&q=80&w=1080""
        },
        {
            ""name"": ""rect_container"",
            ""stroke"": ""grey"",
            ""backgroundColor"": ""rgba(255, 255, 255, 0.62)""
        },
        {
            ""name"": ""text_quote"",
            ""text"": ""Just witnessed the most breathtaking sunset over the Sahara. The way the light dances on the dunes, painting the sky in shades of orange and purple, is truly magical. Nature's artistry at its finest!  #DesertAdventures #SaharaSkies"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#414141""
        },
        {
            ""name"": ""text_footer"",
            ""text"": ""2024-07-30 - Twitter - iPhone 16 Pro"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#666666""
        },
        {
            ""name"": ""circle_profile"",
            ""stroke"": ""grey"",
            ""src"": ""https://images.unsplash.com/photo-1520998116484-6eeb2f72b5b9?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxOTc1MDZ8MHwxfHNlYXJjaHw2Mnx8aGFwcHl8ZW58MHwwfHx8MTYyMTY5MjkwNw&ixlib=rb-1.2.1&q=80&w=1080""
        },
        {
            ""name"": ""text_name"",
            ""text"": ""Sarah Wanderlust"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#4E4E4E""
        },
        {
            ""name"": ""text_twitter"",
            ""text"": ""@sarahexplores"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#4E4E4E""
        }
    ]
}";
            var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
            var byteContent = new ByteArrayContent(buffer);
            Console.WriteLine(json_content);
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            var response = await client.PostAsync(url, byteContent);
            var ret = await response.Content.ReadAsStringAsync();
            var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
            if (returnContent.status == "success")
            {
                Console.WriteLine($"Downloading {returnContent.download_url}...");
                var download_response = await client.GetAsync(returnContent.download_url);
                using (var stream = await download_response.Content.ReadAsStreamAsync())
                {
                    var fileInfo = new FileInfo("image.jpeg");
                    using (var fileStream = fileInfo.OpenWrite())
                    {
                        await stream.CopyToAsync(fileStream);
                    }
                }
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Net.Http
Imports System.Text
Imports System.Text.Json
Imports System.Threading.Tasks

Namespace csharp
	Friend Class ReturnContent
		Public Property download_url() As String
		Public Property status() As String
	End Class

	Friend Class Program
		Shared Async Function Main(ByVal args() As String) As Task
			Dim api_key = "a9e4MjA2NTg6MTc3Njk6Uk1ZSzVjTWs1T3d6VE9Mdw="
			Dim template_id = "f4377b23b4aeeed0"
			Dim url = $"https://rest.apitemplate.io/v2/create-image?template_id={template_id}"
			Dim json_content = "{
    ""overrides"": [
        {
            ""name"": ""rect_image_bg"",
            ""stroke"": ""grey"",
            ""src"": ""https://images.unsplash.com/photo-1542401886-65d6c61db217?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxOTc1MDZ8MHwxfHNlYXJjaHwzfHxkZXNlcnR8ZW58MHwwfHx8MTYyMTUxOTI2OA&ixlib=rb-1.2.1&q=80&w=1080""
        },
        {
            ""name"": ""rect_container"",
            ""stroke"": ""grey"",
            ""backgroundColor"": ""rgba(255, 255, 255, 0.62)""
        },
        {
            ""name"": ""text_quote"",
            ""text"": ""Just witnessed the most breathtaking sunset over the Sahara. The way the light dances on the dunes, painting the sky in shades of orange and purple, is truly magical. Nature's artistry at its finest!  #DesertAdventures #SaharaSkies"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#414141""
        },
        {
            ""name"": ""text_footer"",
            ""text"": ""2024-07-30 - Twitter - iPhone 16 Pro"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#666666""
        },
        {
            ""name"": ""circle_profile"",
            ""stroke"": ""grey"",
            ""src"": ""https://images.unsplash.com/photo-1520998116484-6eeb2f72b5b9?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxOTc1MDZ8MHwxfHNlYXJjaHw2Mnx8aGFwcHl8ZW58MHwwfHx8MTYyMTY5MjkwNw&ixlib=rb-1.2.1&q=80&w=1080""
        },
        {
            ""name"": ""text_name"",
            ""text"": ""Sarah Wanderlust"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#4E4E4E""
        },
        {
            ""name"": ""text_twitter"",
            ""text"": ""@sarahexplores"",
            ""textBackgroundColor"": ""rgba(246, 243, 243, 0)"",
            ""color"": ""#4E4E4E""
        }
    ]
}"
			Dim buffer = System.Text.Encoding.UTF8.GetBytes(json_content)
			Dim byteContent = New ByteArrayContent(buffer)
			Console.WriteLine(json_content)
			Dim client = New HttpClient()
			client.DefaultRequestHeaders.Add("X-API-KEY", api_key)
			Dim response = Await client.PostAsync(url, byteContent)
			Dim ret = Await response.Content.ReadAsStringAsync()
			Dim returnContent = JsonSerializer.Deserialize(Of ReturnContent)(ret)
			If returnContent.status = "success" Then
				Console.WriteLine($"Downloading {returnContent.download_url}...")
				Dim download_response = Await client.GetAsync(returnContent.download_url)
				Using stream = Await download_response.Content.ReadAsStreamAsync()
					Dim fileInfo As New FileInfo("image.jpeg")
					Using fileStream = fileInfo.OpenWrite()
						Await stream.CopyToAsync(fileStream)
					End Using
				End Using
			End If
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 14

本範例會產生具有動態內容、自訂背景顏色和內嵌產品圖片的產品促銷圖片。

QR 代碼產生

APITemplate 內建的 QR code 生成功能為我的許多專案增色不少。 您可以將資料 URL 置於 QR 代碼的內容中。 以下是我使用過的較複雜的範例:

using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "API-Key";
            var template_id = "Template-Key";
            var url = $"https://rest.apitemplate.io/v2/create-image?template_id={template_id}";
            var json_content = @"{
    ""overrides"": [
        {
            ""name"": ""background-color"",
            ""stroke"": ""grey"",
            ""backgroundColor"": ""#FFFFFF""
        },
        {
            ""name"": ""qr_1"",
            ""content"": ""http://ironpdf.com/"",
            ""backgroundColor"": ""white"",
            ""color"": ""#000000""
        }
    ]
}";
            var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
            var byteContent = new ByteArrayContent(buffer);
            //Console.WriteLine(json_content);
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            var response = await client.PostAsync(url, byteContent);
            var ret = await response.Content.ReadAsStringAsync();
            var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
            Console.WriteLine(returnContent.status);
            if (returnContent.status == "success")
            {
                Console.WriteLine($"Downloading {returnContent.download_url}...");
                var download_response = await client.GetAsync(returnContent.download_url);
                using (var stream = await download_response.Content.ReadAsStreamAsync())
                {
                    var fileInfo = new FileInfo(@"F:/QRimage.jpeg");
                    using (var fileStream = fileInfo.OpenWrite())
                    {
                        await stream.CopyToAsync(fileStream);
                    }
                }
            }
        }
    }
}
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace csharp
{
    class ReturnContent
    {
        public string download_url { get; set; }
        public string status { get; set; }
    }

    class Program
    {
        static async Task Main(string[] args)
        {
            var api_key = "API-Key";
            var template_id = "Template-Key";
            var url = $"https://rest.apitemplate.io/v2/create-image?template_id={template_id}";
            var json_content = @"{
    ""overrides"": [
        {
            ""name"": ""background-color"",
            ""stroke"": ""grey"",
            ""backgroundColor"": ""#FFFFFF""
        },
        {
            ""name"": ""qr_1"",
            ""content"": ""http://ironpdf.com/"",
            ""backgroundColor"": ""white"",
            ""color"": ""#000000""
        }
    ]
}";
            var buffer = System.Text.Encoding.UTF8.GetBytes(json_content);
            var byteContent = new ByteArrayContent(buffer);
            //Console.WriteLine(json_content);
            var client = new HttpClient();
            client.DefaultRequestHeaders.Add("X-API-KEY", api_key);
            var response = await client.PostAsync(url, byteContent);
            var ret = await response.Content.ReadAsStringAsync();
            var returnContent = JsonSerializer.Deserialize<ReturnContent>(ret);
            Console.WriteLine(returnContent.status);
            if (returnContent.status == "success")
            {
                Console.WriteLine($"Downloading {returnContent.download_url}...");
                var download_response = await client.GetAsync(returnContent.download_url);
                using (var stream = await download_response.Content.ReadAsStreamAsync())
                {
                    var fileInfo = new FileInfo(@"F:/QRimage.jpeg");
                    using (var fileStream = fileInfo.OpenWrite())
                    {
                        await stream.CopyToAsync(fileStream);
                    }
                }
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Net.Http
Imports System.Text
Imports System.Text.Json
Imports System.Threading.Tasks

Namespace csharp
	Friend Class ReturnContent
		Public Property download_url() As String
		Public Property status() As String
	End Class

	Friend Class Program
		Shared Async Function Main(ByVal args() As String) As Task
			Dim api_key = "API-Key"
			Dim template_id = "Template-Key"
			Dim url = $"https://rest.apitemplate.io/v2/create-image?template_id={template_id}"
			Dim json_content = "{
    ""overrides"": [
        {
            ""name"": ""background-color"",
            ""stroke"": ""grey"",
            ""backgroundColor"": ""#FFFFFF""
        },
        {
            ""name"": ""qr_1"",
            ""content"": ""http://ironpdf.com/"",
            ""backgroundColor"": ""white"",
            ""color"": ""#000000""
        }
    ]
}"
			Dim buffer = System.Text.Encoding.UTF8.GetBytes(json_content)
			Dim byteContent = New ByteArrayContent(buffer)
			'Console.WriteLine(json_content);
			Dim client = New HttpClient()
			client.DefaultRequestHeaders.Add("X-API-KEY", api_key)
			Dim response = Await client.PostAsync(url, byteContent)
			Dim ret = Await response.Content.ReadAsStringAsync()
			Dim returnContent = JsonSerializer.Deserialize(Of ReturnContent)(ret)
			Console.WriteLine(returnContent.status)
			If returnContent.status = "success" Then
				Console.WriteLine($"Downloading {returnContent.download_url}...")
				Dim download_response = Await client.GetAsync(returnContent.download_url)
				Using stream = Await download_response.Content.ReadAsStreamAsync()
					Dim fileInfo As New FileInfo("F:/QRimage.jpeg")
					Using fileStream = fileInfo.OpenWrite()
						Await stream.CopyToAsync(fileStream)
					End Using
				End Using
			End If
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 15

文件和支援

身為一名 C# 開發人員,經常需要處理 PDF 的產生與操作,我發現文件與支援的品質可以決定一個專案的成敗。 讓我們來探討我使用 IronPDF 和 APITemplate 相關文件與技術支援的經驗。

IronPDF

說明文件

IronPDF 的說明文件內容全面、結構良好,對我的專案有很大的幫助。 以下是我的詳細經驗:IronPDF 的說明文件可在 https://ironpdf.com/docs/ 取得,內容相當廣泛。以下是我所欣賞的一些重要方面:

1.入門指南:文件一開始就提供了一個清晰的分步指南,說明如何透過 NuGet 安裝 IronPDF 並建立您的第一個 PDF。 這幫助我在最初的專案中快速上手。

2.API 參考:API 參考詳盡,涵蓋所有類別和方法。 每個條目都包含 C# 範例,我發現這些範例在實作特定功能時非常寶貴。

3.程式碼範例:在整個文件中,有許多程式碼片段和完整範例。 當我需要實作更複雜的 PDF 作業時,這些工具特別有幫助。

4.Tutorials and How-To Guides: IronPDF 為常見的工作提供詳細的教學,例如從 HTML 建立 PDF、加入水印或使用表單。 這些引導我完成更進階的使用案例。

5.疑難排解部分:本文件包含一個疑難排解部分,可解決常見的問題。 當我遇到錯誤或意想不到的行為時,這節省了我的時間。

支援

IronPDF 的聯絡人反應迅速,而且根據我的經驗,支援管道也非常有幫助:

1.電子郵件支援:當我遇到複雜的問題時,我會使用他們的電子郵件支援。 回應時間通常在 24 小時之內,而且支援團隊對產品非常熟悉。

2.社區論壇: IronPDF 維護一個社區論壇,開發人員可以在此提出問題並分享解決方案。 我既找到了問題的答案,也根據自己的經驗貢獻了解決方案。

3.Stack Overflow: IronPDF 團隊積極監控 Stack Overflow 上的 [ironPdf]標籤。 我在那裡發佈的問題都得到了有用的回應。

4.定期更新: IronPDF 經常發佈更新,包含錯誤修正和新功能。 變更記錄很詳盡,可以幫助我瞭解每個版本的新增或變更內容。

5.遷移指南:當主要版本之間發生突破性變化時,IronPDF 提供了遷移指南。 這些對我的專案更新至更新版本的函式庫至關重要。

APITemplate

APITemplate 的文件和支援結构与 IronPDF 不同,反映了其作為基于云的服务的性质。以下是我的經驗:

說明文件

APITemplate 的說明文件可在 https://docs.apitemplate.io/reference/api-reference.html 取得,它著重於 API 的使用。 以下是重點:

1.API 參考: 文件提供了清晰的 API 參考,詳細說明了所有可用的端點、所需參數和回應格式。 當我將 APITemplate 整合到 C# 應用程式時,這是我最常用的資源。

2.驗證:有一個關於驗證的專門章節,清楚地解釋了如何使用 API 金鑰。 當我剛開始使用這項服務時,這一點至關重要。

支援

APITemplate 的支援結構較著重於電子郵件支援:

1.電子郵件支援:當我遇到問題時,我會使用他們的電子郵件支援。 回應時間通常在 1-2 個工作天之內。

2.常見問題部分:文件包含常見問題部分,可解決常見問題。 這常常是我遇到問題時的第一站。

使用 Bootstrap 5 和 IronPDF 製作分析儀表板

IronPDF 的 Chrome V8 渲染引擎擅长渲染現代 Bootstrap 5 布局,非常適合生成包含业务指標和數据可视化的 PDF 报告。 與 APITemplate 基於 API 的方式不同,IronPDF 直接處理 HTML,並完全支援 CSS3,包括 flexbox、CSS Grid 和自訂屬性。

using IronPdf;

var renderer = new ChromePdfRenderer();

string analyticsDashboard = @"
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
    <style>
        .metric-card {
            transition: transform 0.2s;
            border-left: 4px solid #0d6efd;
        }
        .metric-card:hover { transform: translateY(-5px); }
        .trend-up { color: #198754; }
        .trend-down { color: #dc3545; }
        @media print {
            .metric-card { page-break-inside: avoid; }
        }
    </style>
</head>
<body class='bg-light'>
    <div class='container py-5'>
        <div class='row mb-4'>
            <div class='col-12'>
                <div class='card shadow-sm'>
                    <div class='card-body'>
                        <h1 class='display-6 mb-0'>Performance Dashboard</h1>
                        <p class='text-muted mb-0'>Q4 2024 Analytics Overview</p>
                    </div>
                </div>
            </div>
        </div>

        <div class='row g-4 mb-4'>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Total Revenue</h6>
                        <h2 class='display-6 mb-3'>$2.4M</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-success' style='width: 85%'></div>
                        </div>
                        <small class='trend-up'>↑ 18% from last quarter</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Active Users</h6>
                        <h2 class='display-6 mb-3'>48,592</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-primary' style='width: 72%'></div>
                        </div>
                        <small class='trend-up'>↑ 12% growth rate</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Conversion Rate</h6>
                        <h2 class='display-6 mb-3'>3.8%</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-warning' style='width: 38%'></div>
                        </div>
                        <small class='trend-down'>↓ 2% needs attention</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Satisfaction</h6>
                        <h2 class='display-6 mb-3'>4.7/5</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-success' style='width: 94%'></div>
                        </div>
                        <small class='trend-up'>↑ Excellent rating</small>
                    </div>
                </div>
            </div>
        </div>

        <div class='card shadow-sm'>
            <div class='card-body'>
                <h5 class='card-title mb-3'>Top Performing Products</h5>
                <div class='table-responsive'>
                    <table class='table table-hover'>
                        <thead class='table-light'>
                            <tr>
                                <th>Product</th>
                                <th>Revenue</th>
                                <th>Units</th>
                                <th>Trend</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><strong>Enterprise Suite</strong></td>
                                <td>$1,240,000</td>
                                <td>2,150</td>
                                <td><span class='badge bg-success'>+22%</span></td>
                            </tr>
                            <tr>
                                <td><strong>Professional Plan</strong></td>
                                <td>$820,000</td>
                                <td>4,890</td>
                                <td><span class='badge bg-success'>+15%</span></td>
                            </tr>
                            <tr>
                                <td><strong>Starter Package</strong></td>
                                <td>$340,000</td>
                                <td>8,240</td>
                                <td><span class='badge bg-warning'>+5%</span></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html>";

var pdf = renderer.RenderHtmlAsPdf(analyticsDashboard);
pdf.SaveAs("analytics-dashboard.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

string analyticsDashboard = @"
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
    <style>
        .metric-card {
            transition: transform 0.2s;
            border-left: 4px solid #0d6efd;
        }
        .metric-card:hover { transform: translateY(-5px); }
        .trend-up { color: #198754; }
        .trend-down { color: #dc3545; }
        @media print {
            .metric-card { page-break-inside: avoid; }
        }
    </style>
</head>
<body class='bg-light'>
    <div class='container py-5'>
        <div class='row mb-4'>
            <div class='col-12'>
                <div class='card shadow-sm'>
                    <div class='card-body'>
                        <h1 class='display-6 mb-0'>Performance Dashboard</h1>
                        <p class='text-muted mb-0'>Q4 2024 Analytics Overview</p>
                    </div>
                </div>
            </div>
        </div>

        <div class='row g-4 mb-4'>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Total Revenue</h6>
                        <h2 class='display-6 mb-3'>$2.4M</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-success' style='width: 85%'></div>
                        </div>
                        <small class='trend-up'>↑ 18% from last quarter</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Active Users</h6>
                        <h2 class='display-6 mb-3'>48,592</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-primary' style='width: 72%'></div>
                        </div>
                        <small class='trend-up'>↑ 12% growth rate</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Conversion Rate</h6>
                        <h2 class='display-6 mb-3'>3.8%</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-warning' style='width: 38%'></div>
                        </div>
                        <small class='trend-down'>↓ 2% needs attention</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Satisfaction</h6>
                        <h2 class='display-6 mb-3'>4.7/5</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-success' style='width: 94%'></div>
                        </div>
                        <small class='trend-up'>↑ Excellent rating</small>
                    </div>
                </div>
            </div>
        </div>

        <div class='card shadow-sm'>
            <div class='card-body'>
                <h5 class='card-title mb-3'>Top Performing Products</h5>
                <div class='table-responsive'>
                    <table class='table table-hover'>
                        <thead class='table-light'>
                            <tr>
                                <th>Product</th>
                                <th>Revenue</th>
                                <th>Units</th>
                                <th>Trend</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><strong>Enterprise Suite</strong></td>
                                <td>$1,240,000</td>
                                <td>2,150</td>
                                <td><span class='badge bg-success'>+22%</span></td>
                            </tr>
                            <tr>
                                <td><strong>Professional Plan</strong></td>
                                <td>$820,000</td>
                                <td>4,890</td>
                                <td><span class='badge bg-success'>+15%</span></td>
                            </tr>
                            <tr>
                                <td><strong>Starter Package</strong></td>
                                <td>$340,000</td>
                                <td>8,240</td>
                                <td><span class='badge bg-warning'>+5%</span></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html>";

var pdf = renderer.RenderHtmlAsPdf(analyticsDashboard);
pdf.SaveAs("analytics-dashboard.pdf");
Imports IronPdf

Dim renderer As New ChromePdfRenderer()

Dim analyticsDashboard As String = "
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
    <style>
        .metric-card {
            transition: transform 0.2s;
            border-left: 4px solid #0d6efd;
        }
        .metric-card:hover { transform: translateY(-5px); }
        .trend-up { color: #198754; }
        .trend-down { color: #dc3545; }
        @media print {
            .metric-card { page-break-inside: avoid; }
        }
    </style>
</head>
<body class='bg-light'>
    <div class='container py-5'>
        <div class='row mb-4'>
            <div class='col-12'>
                <div class='card shadow-sm'>
                    <div class='card-body'>
                        <h1 class='display-6 mb-0'>Performance Dashboard</h1>
                        <p class='text-muted mb-0'>Q4 2024 Analytics Overview</p>
                    </div>
                </div>
            </div>
        </div>

        <div class='row g-4 mb-4'>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Total Revenue</h6>
                        <h2 class='display-6 mb-3'>$2.4M</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-success' style='width: 85%'></div>
                        </div>
                        <small class='trend-up'>↑ 18% from last quarter</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Active Users</h6>
                        <h2 class='display-6 mb-3'>48,592</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-primary' style='width: 72%'></div>
                        </div>
                        <small class='trend-up'>↑ 12% growth rate</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Conversion Rate</h6>
                        <h2 class='display-6 mb-3'>3.8%</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-warning' style='width: 38%'></div>
                        </div>
                        <small class='trend-down'>↓ 2% needs attention</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card metric-card shadow-sm h-100'>
                    <div class='card-body'>
                        <h6 class='text-muted text-uppercase mb-2'>Satisfaction</h6>
                        <h2 class='display-6 mb-3'>4.7/5</h2>
                        <div class='progress' style='height: 6px;'>
                            <div class='progress-bar bg-success' style='width: 94%'></div>
                        </div>
                        <small class='trend-up'>↑ Excellent rating</small>
                    </div>
                </div>
            </div>
        </div>

        <div class='card shadow-sm'>
            <div class='card-body'>
                <h5 class='card-title mb-3'>Top Performing Products</h5>
                <div class='table-responsive'>
                    <table class='table table-hover'>
                        <thead class='table-light'>
                            <tr>
                                <th>Product</th>
                                <th>Revenue</th>
                                <th>Units</th>
                                <th>Trend</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><strong>Enterprise Suite</strong></td>
                                <td>$1,240,000</td>
                                <td>2,150</td>
                                <td><span class='badge bg-success'>+22%</span></td>
                            </tr>
                            <tr>
                                <td><strong>Professional Plan</strong></td>
                                <td>$820,000</td>
                                <td>4,890</td>
                                <td><span class='badge bg-success'>+15%</span></td>
                            </tr>
                            <tr>
                                <td><strong>Starter Package</strong></td>
                                <td>$340,000</td>
                                <td>8,240</td>
                                <td><span class='badge bg-warning'>+5%</span></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html>"

Dim pdf = renderer.RenderHtmlAsPdf(analyticsDashboard)
pdf.SaveAs("analytics-dashboard.pdf")
$vbLabelText   $csharpLabel

此代碼可產生專業的分析儀表板 PDF,其中包含度量卡、進度列和反應式表格。 IronPDF 的 Chrome 引擎可以完美渲染 Bootstrap 的 flexbox 布局、陰影和懸浮效果 - 這些功能需要使用 APITemplate 等基於 API 的服務進行大量的客製工作。

與 APITemplate 的主要優勢:

  • 直接 HTML 渲染,完全支援 Bootstrap
  • 不需要 API 調用或範本設定
  • 完全相容 CSS3,包括動畫
  • 離線處理,無外部依賴

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

授權

IronPDF 定價與授權

APITemplate io 與 IronPDF 對 C# PDF 函式庫的比較:圖 16

IronPDF 提供不同的價格層級,以滿足不同的需求:

  1. Lite:定價為 $999,此等級適合單一開發人員處理單一專案。 這是一項一次性的費用,因此對小型專案或個別開發人員而言是一項經濟實惠的選擇。 2.專業版:在 $1,499,此選項最多支援 10 位開發人員、10 個地點和 10 個專案。 此層級也包含一次性費用,並為中小型團隊提供更多的彈性。 3.無限制:對於 $2,999,此等級允許無限制的開發者、地點和項目。 這非常適合需要廣泛使用而不受限制的大型團隊和企業。

IronPDF 也提供企業和 OEM 再發行授權,適用於大型組織和需要將 PDF 功能整合至商業產品的組織。 它也提供免費試用來測試。

APITemplate 定價與授權

APITemplate 以其基於 API 的 PDF 生成服務提供了一種不同的方法。定價通常以 API 的呼叫次數為基礎,因此對於不同的使用模式而言更具彈性:

  1. 基礎方案:通常以較低價格起跳,每月 API 呼叫次數有限。 這適合小型專案或僅有極少 PDF 生成需求的企業。
  2. 標準方案:此方案包含更多 API 呼叫次數及額外功能,專為中型企業設計。
  3. Enterprise 方案:專為高用量使用者量身打造,此方案提供最多的 API 呼叫次數,以及優先技術支援和客製化整合等高級功能。

APITemplate 的授權方式簡單直接,通常採用按月或按年訂閱的模式。

主要差異

  1. 定價模式:IronPDF 採用一次性付費模式,從長遠來看具有成本效益,特別是對於持續且大量使用的情況。 APITemplate 則採用訂閱模式,隨著使用量的增加,可以有更大的彈性和擴充性。
  2. 技術支援與更新:購買 IronPDF 即享一年技術支援與更新服務,並可選擇延長此期限。 APITemplate 的訂閱方案通常包含持續支援與更新,作為套件的一部分。

為什麼要選擇 IronPDF?

IronPDF 和 APITemplate 都提供從 HTML 內容產生 PDF 的功能,但 IronPDF 的實作更強大、更靈活。 這裡有一個比較:

IronPDF

using IronPdf;

var renderer = new ChromePdfRenderer();
var html = @"
<html>
<head>
    <style>
        body { font-family: Arial, sans-serif; }
        .header { color: #0066cc; font-size: 24px; }
        .content { margin-top: 20px; }
    </style>
</head>
<body>
    <div class='header'>Dynamic Report</div>
    <div class='content'>
        <p>This report was generated on: <script>document.write(new Date().toLocaleString());</script></p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    </div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("IronPDF_report.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();
var html = @"
<html>
<head>
    <style>
        body { font-family: Arial, sans-serif; }
        .header { color: #0066cc; font-size: 24px; }
        .content { margin-top: 20px; }
    </style>
</head>
<body>
    <div class='header'>Dynamic Report</div>
    <div class='content'>
        <p>This report was generated on: <script>document.write(new Date().toLocaleString());</script></p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    </div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("IronPDF_report.pdf");
Imports IronPdf

Private renderer = New ChromePdfRenderer()
Private html = "
<html>
<head>
    <style>
        body { font-family: Arial, sans-serif; }
        .header { color: #0066cc; font-size: 24px; }
        .content { margin-top: 20px; }
    </style>
</head>
<body>
    <div class='header'>Dynamic Report</div>
    <div class='content'>
        <p>This report was generated on: <script>document.write(new Date().toLocaleString());</script></p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    </div>
</body>
</html>"
Private pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("IronPDF_report.pdf")
$vbLabelText   $csharpLabel

APITemplate

using System.Net.Http;
using System.Text.Json;

var apiKey = "your_api_key";
var templateId = "your_template_id";
var url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={templateId}";
var data = new
{
    header = "Dynamic Report",
    content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    date = DateTime.Now.ToShortDateString()
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-KEY", apiKey);
var response = await client.PostAsync(url, content);
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("APITemplate_report.pdf", pdfBytes);
using System.Net.Http;
using System.Text.Json;

var apiKey = "your_api_key";
var templateId = "your_template_id";
var url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={templateId}";
var data = new
{
    header = "Dynamic Report",
    content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    date = DateTime.Now.ToShortDateString()
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-KEY", apiKey);
var response = await client.PostAsync(url, content);
var pdfBytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("APITemplate_report.pdf", pdfBytes);
Imports System.Net.Http
Imports System.Text.Json

Private apiKey = "your_api_key"
Private templateId = "your_template_id"
Private url = $"https://rest.apitemplate.io/v2/create-pdf?template_id={templateId}"
Private data = New With {
	Key .header = "Dynamic Report",
	Key .content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
	Key .date = DateTime.Now.ToShortDateString()
}
Private json = JsonSerializer.Serialize(data)
Private content = New StringContent(json, System.Text.Encoding.UTF8, "application/json")
Private client = New HttpClient()
client.DefaultRequestHeaders.Add("X-API-KEY", apiKey)
Dim response = Await client.PostAsync(url, content)
Dim pdfBytes = Await response.Content.ReadAsByteArrayAsync()
File.WriteAllBytes("APITemplate_report.pdf", pdfBytes)
$vbLabelText   $csharpLabel

主要差異

  1. JavaScript 支援:IronPDF 完全支援在 HTML 中執行 JavaScript,可實現動態內容生成(例如範例中的當前日期)。 APITemplate 通常要求事先提供所有資料。
  2. CSS 彈性:透過 IronPDF,您可直接在 HTML 中完全掌控 CSS 樣式。 APITemplate 通常需要預定義的範本,自訂選項有限。
  3. 效能:IronPDF 在本地端處理 HTML,因此能更快產生 PDF 檔案,對於複雜文件而言尤為顯著。 APITemplate 的雲端方式可能會帶來延遲。
  4. 離線功能:IronPDF 支援離線運作,對於網路連線受限或有高度安全需求的應用程式而言相當實用。 APITemplate 總是需要網際網路連線。
  5. 動態內容:IronPDF 允許即時生成更多動態內容,而 APITemplate 通常需要預先定義的範本結構。
  6. 自訂設定:IronPDF 提供更細緻的 PDF 生成流程控制,包含頁面大小、邊距及其他 PDF 專屬設定的選項。
  7. 一致性:IronPDF 採用其專屬渲染引擎,可確保在不同環境下呈現效果一致。APITemplate 的輸出結果則可能因伺服器設定而有所差異。

結論

在各種 C# 專案中廣泛使用 IronPDF 和 APITemplate 之後,我開始欣賞每種工具的獨特優點。 然而,對於我大部分與 PDF 相關的工作,IronPDF 一直被證明是上佳的選擇。雖然 APITemplate 有其優點,特別是對於簡單的、基於範本的文件產生,但我發現 IronPDF 的多功能性讓它可以同樣有效地處理這些任務,同時也提供了在需要時處理更複雜 PDF 作業的能力。

總而言之,雖然這兩種工具都有它的用武之地,但 IronPDF 一直被證明是 C# 開發中操作 PDF 的更強大、更靈活、更具成本效益的解決方案。 它強大的功能集、優異的效能和全面的支援,使它成為我處理任何 PDF 相關工作的首選,從最簡單的文件產生到最複雜的 PDF 操作。

請注意APITemplate 為其各自所有者的註冊商標。 本網站與 APITemplate 無任何關聯、背書或贊助。 所有產品名稱、標誌和品牌均為其各自擁有者的財產。 比較僅供參考,反映了撰寫時的公開信息。

常見問題解答

雲端工具和庫工具之間的 PDF 生成工具有何主要差異?

像 APITemplate 這樣的雲端工具通過 API 調用生成 PDF,需要互聯網連接。與此相反,像 IronPDF 這樣的庫工具集成在你的 C# 應用中,允許離線 PDF 操作並提供更多的 PDF 創建和自定義控制。

IronPDF 如何在 C# 應用程序中處理 HTML 到 PDF 的轉換?

IronPDF 允許使用像 RenderHtmlAsPdf 這樣的方法無縫地將 HTML 轉換為 PDF。它完全支持包括 CSS 和 JavaScript 在內的現代網頁標準,確保將網頁內容高質量地呈現在 PDF 中。

我可以使用 IronPDF 來生成 PDF 中的動態內容嗎?

是的,IronPDF 支持 JavaScript 的執行,這讓 PDF 中的動態內容生成成為可能。這在直接從具有動態數據的網頁創建交互式 PDF 時特別有用。

使用 IronPDF 比訂閱服務有什麼優勢?

IronPDF 提供一次性授權費,是一種實惠的長期使用解決方案。它允許離線操作,並提供廣泛的 PDF 操作功能,這可能比像 APITemplate 這樣的訂閱服務更靈活和強大。

IronPDF 為開發人員提供了什麼支持?

IronPDF 通過詳細的文檔提供全面支持,包括指南、API 參考和代碼示例。開發人員還可以通過電子郵件支持、社區論壇以及在 Stack Overflow 等平台上進行監控來尋求幫助。

IronPDF 是否支持跨平台開發?

是的,IronPDF 與 .NET Standard 兼容,支持跨平台開發。這確保了開發人員可以無縫地將 IronPDF 集成到運行於不同操作系統的項目中。

IronPDF 如何確保生成的 PDF 的安全性?

IronPDF 包括 PDF 加密和解密功能,允許開發人員使用密碼和數字簽名來保護文檔。這些功能有助於維護 PDF 文檔的機密性和完整性。

使用 IronPDF 有哪些常見的故障排除提示?

當遇到 IronPDF 的問題時,確保所有依賴項均已正確安裝和更新。檢查文檔以了解兼容性和配置設置,並查看示例代碼以驗證實施方法。如果問題依然存在,支持團隊將提供幫助。

Curtis Chau
技術作家

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

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

鋼鐵支援團隊

我們每週 5 天,每天 24 小時在線上。
聊天
電子郵件
打電話給我