CraftMyPDF vs IronPDF:哪個PDF生成程式庫適合C#開發者?
IronPDF 提供程式碼優先的 HTML 到 PDF 轉換,支援完整的 CSS/JavaScript,永久授權價格從 $749 起;而 CraftMyPDF 提供基於雲端的範本設計,整合了 JSON,但需要持續訂閱和 API 依賴。
CraftMyPDF 提供了一個基於雲端的拖放模板設計器,並整合了 JSON 資料;而IronPDF則為尋求完全控製文件產生的 .NET 開發人員提供了程式碼優先的HTML 到 PDF 轉換功能,並提供了完整的 CSS/JavaScript 支援。
PDF(可攜式文件格式)是由 Adobe 開發的一種用於文件交換的檔案格式。 它能在不同裝置上保留格式、字型和圖片,確保外觀一致。 PDF 支援安全性功能、互動性及壓縮功能,使其成為可靠文件共享的理想選擇。
C# PDF 函式庫讓開發人員能夠透過程式設計方式建立、修改 PDF 檔案,並從中擷取內容。 這些工具支援表單處理、數位簽章及跨平台部署。 透過整合 PDF 函式庫,開發人員可直接在應用程式中加入文件生成功能,簡化 PDF 的建立、編輯與管理工作流程。
本文比較了兩種不同的 PDF 生成方法:IronPDF C# 函式庫與 Craftmypdf API。 此比較內容將探討各項功能、提供程式碼範例,並說明授權選項。
什麼是 CraftMyPDF API 基礎解決方案?
CraftMyPDF 主頁展示了拖放 PDF 編輯器介面,其中正在即時編輯裝箱單模板。
CraftMyPDF 是一項基於雲端的 API,可透過範本建立 PDF 檔案。 它提供了一個基於網頁的拖放編輯器,讓使用者無需編寫程式碼即可設計可重複使用的範本。 該平台透過將這些範本與 JSON 資料合併來生成 PDF 檔案,支援發票、報告和證書等文件的動態內容生成。
CraftMyPDF 的主要特性是什麼?
-
拖放編輯器:無需編碼知識即可使用的視覺化範本設計工具。
-
範本可重複使用性:只需設計一次,即可搭配不同的資料集反覆使用。
-
JSON 資料整合:透過 JSON 將動態資料與範本進行整合。
-
進階格式設定與運算式:動態格式化日期、數字及貨幣。
-
API 整合:REST API 支援 Zapier、Make.com 及自訂應用程式。
-
可填寫元件:建立包含文字欄位與核取方塊的互動式表單。
- 安全性與合規性:透過區域性 API 端點確保 PDF 存取安全,並符合 GDPR 規範。
什麼是 IronPDF?
IronPDF PDF Library 適用於 .NET Developers 是一款專為 .NET 應用程式設計的完整 PDF 函式庫。 此工具以 C# 編寫,能從 HTML、CSS、JavaScript 及圖像生成像素級精準的 PDF 檔案。 IronPDF 透過在 .NET 環境中提供全面的 PDF 建立、編輯與管理功能,簡化了 PDF 工作流程。
IronPDF 的主要功能有哪些?
-
HTML 轉 PDF:將 HTML、CSS 和 JavaScript 轉換為像素級精準的 PDF 檔案。
-
URL 轉 PDF:從任何網址生成 PDF 檔案,完整保留內容與響應式樣式。
-
圖片轉 PDF:將 JPG、PNG、GIF、BMP 和 SVG 轉換為 PDF 文件,並支援多幀 TIFF 格式。
-
表單填寫與資料擷取:透過程式化方式建立並填寫 PDF 表單,並支援自訂驗證。
-
PDF 編輯:新增、複製或刪除頁面。 具備頁面旋轉功能的 PDF 合併與分割工具。
-
效能優化:支援多執行緒與非同步處理,透過平行處理實現大量資料生成。
- 無外部依賴:採用原生渲染引擎,僅需部署單一 DLL 檔案,無需額外軟體。
如何在 Visual Studio 中建立 C# 應用程式?
要建立 C# 主控台應用程式,電腦上必須安裝 Visual Studio。 請依照以下步驟設定專案:
如何開啟 Visual Studio?
從"開始"選單或桌面圖示啟動 Visual Studio。
如何建立新專案?
- 在起始頁面上點擊"建立新專案"。
- 搜尋"Console App"或從範本清單中選取。
如何選擇專案範本?
請根據需求選擇"主控台應用程式 (.NET Core)"或"主控台應用程式 (.NET Framework)"。 若需 .NET MAUI 支援,請選擇適當的 MAUI 範本。
如何設定我的專案?
- 專案名稱:輸入專案名稱
- 位置:選擇儲存目錄
- 解決方案名稱:通常與專案名稱一致
- 點擊"建立"以繼續
如何安裝 IronPDF?
IronPDF 提供三種安裝方式:NuGet 套件管理員、套件管理員主控台,以及直接下載。 此函式庫支援 Windows、macOS、Linux 及雲端部署。
如何使用 NuGet 套件管理員?
在 Visual Studio 中,請在"解決方案資源管理器"中右鍵點擊"參考"或"依賴項"。 選擇"管理 NuGet 套件",搜尋"IronPDF",然後點擊"安裝"。
如何使用 NuGet 套件管理員主控台?
開啟"工具">"NuGet 套件管理員">"套件管理員主控台",並執行:
Install-Package IronPdf
如何從 NuGet 網站下載?
請造訪 NuGet 網站,下載套件檔案,並在 Visual Studio 中將其新增為套件來源。 針對 Docker 部署,請使用特定的容器配置。
如需詳細指引,請參閱安裝概覽與進階 NuGet 設定。
如何使用 CraftMyPDF?
若要整合 CraftMyPDF,請建立帳戶、選擇套餐並取得 API 憑證。
如何建立帳戶並選擇免費方案?
- 註冊:請至 CraftMyPDF 網站註冊
- 選擇免費方案:選擇免費方案用於開發與測試
- 取得 API 金鑰:從帳戶儀表板存取 API 金鑰
CraftMyPDF 控制面板顯示免費方案訂閱詳情、已使用 6/50 個積分,以及包含簽名域等新功能和錯誤修復的最新更新日誌。
我需要安裝哪些函式庫?
安裝System.Net.Http 、 RestSharp和Newtonsoft.Json套件:
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
Imports System
Imports System.Net.Http
Imports System.Text
Imports System.Threading.Tasks
Imports RestSharp
初始化 API 客戶端:
var client = new RestClient("___PROTECTED_URL_51___");
var request = new RestRequest(Method.Post);
string apiKey = "API Key"; // Replace with your actual API key
string templateId = "Template ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
var client = new RestClient("___PROTECTED_URL_51___");
var request = new RestRequest(Method.Post);
string apiKey = "API Key"; // Replace with your actual API key
string templateId = "Template ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
Dim client As New RestClient("___PROTECTED_URL_51___")
Dim request As New RestRequest(Method.Post)
Dim apiKey As String = "API Key" ' Replace with your actual API key
Dim templateId As String = "Template ID" ' Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey)
request.AddHeader("Content-Type", "application/json")
如何建立 PDF 檔案?
這兩套函式庫提供了不同的 PDF 生成方法。 IronPDF 使用基於程式碼的HTML 渲染,而 CraftMyPDF 使用資料綁定的視覺化範本。 IronPDF 亦支援 Markdown 轉 PDF 及 XML 轉 PDF 的轉換功能。
如何使用 IronPDF 建立 PDF 檔案?
如何將 HTML 轉換為 PDF?
直接將 HTML 字串轉換為 PDF,並完整支援 CSS 及 JavaScript 渲染:
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtml()
{
var renderer = new ChromePdfRenderer();
// Define your HTML string
string htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a sample PDF document created from an HTML string.</p>";
// Render the HTML as a PDF document
var pdfDocument = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF document
pdfDocument.SaveAs("html_output.pdf");
}
}
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtml()
{
var renderer = new ChromePdfRenderer();
// Define your HTML string
string htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a sample PDF document created from an HTML string.</p>";
// Render the HTML as a PDF document
var pdfDocument = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF document
pdfDocument.SaveAs("html_output.pdf");
}
}
Imports IronPdf
Public Class PDFCreator
Public Sub CreatePdfFromHtml()
Dim renderer = New ChromePdfRenderer()
' Define your HTML string
Dim htmlContent As String = "<h1>Hello, IronPDF!</h1><p>This is a sample PDF document created from an HTML string.</p>"
' Render the HTML as a PDF document
Dim pdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
' Save the PDF document
pdfDocument.SaveAs("html_output.pdf")
End Sub
End Class

如需更多範例,請造訪 HTML 轉 PDF 範例頁面。 開發人員亦可設定自訂邊距、插入分頁符,並設定紙張尺寸。
如何將 URL 轉換為 PDF?
將網頁轉換為 PDF 檔案,同時保留所有樣式,包括 WebGL 內容和響應式 CSS:
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromUrl(string url)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the URL as a PDF document
var pdfDocument = renderer.RenderUrlAsPdf(url);
// Save the PDF document
pdfDocument.SaveAs("url_output.pdf");
}
}
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromUrl(string url)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the URL as a PDF document
var pdfDocument = renderer.RenderUrlAsPdf(url);
// Save the PDF document
pdfDocument.SaveAs("url_output.pdf");
}
}
Imports IronPdf
Public Class PDFCreator
Public Sub CreatePdfFromUrl(url As String)
' Initialize the ChromePdfRenderer
Dim renderer = New ChromePdfRenderer()
' Render the URL as a PDF document
Dim pdfDocument = renderer.RenderUrlAsPdf(url)
' Save the PDF document
pdfDocument.SaveAs("url_output.pdf")
End Sub
End Class
進一步了解 URL 轉 PDF 功能。 關於需驗證的頁面,請參閱 TLS 網站登入及 HTTP 請求標頭。
如何將 HTML 檔案轉換為 PDF?
將本機 HTML 檔案轉換為 PDF,並支援 CSS 媒體類型與基準 URL:
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtmlFile(string filePath)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the HTML file as a PDF document
var pdfDocument = renderer.RenderHtmlFileAsPdf(filePath);
// Save the PDF document
pdfDocument.SaveAs("html_file_output.pdf");
}
}
using IronPdf;
public class PDFCreator
{
public void CreatePdfFromHtmlFile(string filePath)
{
// Initialize the ChromePdfRenderer
var renderer = new ChromePdfRenderer();
// Render the HTML file as a PDF document
var pdfDocument = renderer.RenderHtmlFileAsPdf(filePath);
// Save the PDF document
pdfDocument.SaveAs("html_file_output.pdf");
}
}
Imports IronPdf
Public Class PDFCreator
Public Sub CreatePdfFromHtmlFile(filePath As String)
' Initialize the ChromePdfRenderer
Dim renderer As New ChromePdfRenderer()
' Render the HTML file as a PDF document
Dim pdfDocument = renderer.RenderHtmlFileAsPdf(filePath)
' Save the PDF document
pdfDocument.SaveAs("html_file_output.pdf")
End Sub
End Class
詳情請參閱 HTML 轉 PDF 指南。 對於 HTML ZIP 檔案,IronPDF 會自動處理提取作業。
如何使用 CraftMyPDF API 建立 PDF?
CraftMyPDF 需要先建立模板,然後透過合併資料產生 PDF。
如何建立範本?
1.登入控制台:存取 CraftMyPDF 帳戶
- 建立新範本:使用拖放編輯器進行設計
- 儲存範本:取得 API 呼叫所需的範本 ID
CraftMyPDF範本管理儀表板顯示了一個帶有編輯工具和教學資源的發票範本。
如何提交生成 PDF 的請求?
透過將 JSON 資料傳送至範本來產生 PDF:
using System;
using System.Net;
using System.Threading.Tasks;
using RestSharp;
class Program
{
static async Task Main(string[] args)
{
var client = new RestClient("___PROTECTED_URL_52___");
var request = new RestRequest(Method.Post);
string apiKey = "API-Key"; // Replace with your actual API key
string templateId = "Template-ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
var body = new
{
data = new
{
invoice_number = "INV48321",
date = "2024-05-27",
due_date = "2024-06-27",
currency = "EUR",
discount = 10,
tax = 5,
company_name = "Tech Innovations Ltd",
email = "contact@techinnovations.com",
client = "Future Solutions GmbH",
client_address = "1234 Innovation Drive",
client_address2 = "Berlin",
client_address3 = "10115",
items = new[]
{
new { description = "Cloud Hosting Services", quantity = 12, unit_price = 75, total = 900 },
new { description = "Custom Web Application", quantity = 3, unit_price = 150, total = 450 },
new { description = "Technical Support", quantity = 15, unit_price = 30, total = 450 },
new { description = "Digital Marketing Campaign", quantity = 2, unit_price = 500, total = 1000 },
new { description = "SEO Optimization", quantity = 5, unit_price = 120, total = 600 }
},
gross_total = 3400
},
load_data_from = (string)null,
template_id = templateId,
version = 8,
export_type = "json",
expiration = 60,
output_file = "output.pdf",
is_cmyk = false,
image_resample_res = 600,
direct_download = 0,
cloud_storage = 1
};
request.AddJsonBody(body);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
if (response.IsSuccessful)
{
var content = response.Content;
dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
string fileUrl = result.file;
string localPath = "f:\\downloaded_output.pdf";
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(fileUrl, localPath);
}
Console.WriteLine($"PDF downloaded successfully to {localPath}");
}
else
{
Console.WriteLine($"Error: {response.Content}");
}
}
}
using System;
using System.Net;
using System.Threading.Tasks;
using RestSharp;
class Program
{
static async Task Main(string[] args)
{
var client = new RestClient("___PROTECTED_URL_52___");
var request = new RestRequest(Method.Post);
string apiKey = "API-Key"; // Replace with your actual API key
string templateId = "Template-ID"; // Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey);
request.AddHeader("Content-Type", "application/json");
var body = new
{
data = new
{
invoice_number = "INV48321",
date = "2024-05-27",
due_date = "2024-06-27",
currency = "EUR",
discount = 10,
tax = 5,
company_name = "Tech Innovations Ltd",
email = "contact@techinnovations.com",
client = "Future Solutions GmbH",
client_address = "1234 Innovation Drive",
client_address2 = "Berlin",
client_address3 = "10115",
items = new[]
{
new { description = "Cloud Hosting Services", quantity = 12, unit_price = 75, total = 900 },
new { description = "Custom Web Application", quantity = 3, unit_price = 150, total = 450 },
new { description = "Technical Support", quantity = 15, unit_price = 30, total = 450 },
new { description = "Digital Marketing Campaign", quantity = 2, unit_price = 500, total = 1000 },
new { description = "SEO Optimization", quantity = 5, unit_price = 120, total = 600 }
},
gross_total = 3400
},
load_data_from = (string)null,
template_id = templateId,
version = 8,
export_type = "json",
expiration = 60,
output_file = "output.pdf",
is_cmyk = false,
image_resample_res = 600,
direct_download = 0,
cloud_storage = 1
};
request.AddJsonBody(body);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
if (response.IsSuccessful)
{
var content = response.Content;
dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
string fileUrl = result.file;
string localPath = "f:\\downloaded_output.pdf";
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(fileUrl, localPath);
}
Console.WriteLine($"PDF downloaded successfully to {localPath}");
}
else
{
Console.WriteLine($"Error: {response.Content}");
}
}
}
Imports System
Imports System.Net
Imports System.Threading.Tasks
Imports RestSharp
Module Program
Async Function Main(args As String()) As Task
Dim client As New RestClient("___PROTECTED_URL_52___")
Dim request As New RestRequest(Method.Post)
Dim apiKey As String = "API-Key" ' Replace with your actual API key
Dim templateId As String = "Template-ID" ' Replace with your actual template ID
request.AddHeader("X-API-KEY", apiKey)
request.AddHeader("Content-Type", "application/json")
Dim body = New With {
.data = New With {
.invoice_number = "INV48321",
.date = "2024-05-27",
.due_date = "2024-06-27",
.currency = "EUR",
.discount = 10,
.tax = 5,
.company_name = "Tech Innovations Ltd",
.email = "contact@techinnovations.com",
.client = "Future Solutions GmbH",
.client_address = "1234 Innovation Drive",
.client_address2 = "Berlin",
.client_address3 = "10115",
.items = New Object() {
New With {.description = "Cloud Hosting Services", .quantity = 12, .unit_price = 75, .total = 900},
New With {.description = "Custom Web Application", .quantity = 3, .unit_price = 150, .total = 450},
New With {.description = "Technical Support", .quantity = 15, .unit_price = 30, .total = 450},
New With {.description = "Digital Marketing Campaign", .quantity = 2, .unit_price = 500, .total = 1000},
New With {.description = "SEO Optimization", .quantity = 5, .unit_price = 120, .total = 600}
},
.gross_total = 3400
},
.load_data_from = CType(Nothing, String),
.template_id = templateId,
.version = 8,
.export_type = "json",
.expiration = 60,
.output_file = "output.pdf",
.is_cmyk = False,
.image_resample_res = 600,
.direct_download = 0,
.cloud_storage = 1
}
request.AddJsonBody(body)
Dim response As RestResponse = Await client.ExecuteAsync(request)
Console.WriteLine(response.Content)
If response.IsSuccessful Then
Dim content = response.Content
Dim result = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Object)(content)
Dim fileUrl As String = result.file
Dim localPath As String = "f:\downloaded_output.pdf"
Using webClient As New WebClient()
webClient.DownloadFile(fileUrl, localPath)
End Using
Console.WriteLine($"PDF downloaded successfully to {localPath}")
Else
Console.WriteLine($"Error: {response.Content}")
End If
End Function
End Module
Visual Studio 偵錯控制台顯示 CraftMyPDF API 成功產生 PDF 輸出,並包含 JSON 回應詳情。
生成的 PDF 輸出:
如何使用 Bootstrap 生成 Professional 發票?
IronPDF 可在無需外部依賴項的情況下,支援現代化框架的渲染。 此 Bootstrap 5 範例展示了採用響應式設計與 PRINT CSS 的 Professional 發票生成功能:
using IronPdf;
var renderer = new ChromePdfRenderer();
string professionalInvoice = @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='___PROTECTED_URL_53___ rel='stylesheet'>
<style>
.invoice-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.invoice-table th { background: #f8f9fa; }
@media print { .invoice-box { page-break-inside: avoid; } }
</style>
</head>
<body>
<div class='container my-4'>
<div class='card shadow-lg invoice-box'>
<div class='invoice-header p-4'>
<div class='row align-items-center'>
<div class='col-md-8'>
<h1 class='mb-0'>INVOICE</h1>
<p class='mb-0 opacity-75'>Invoice #INV-2024-0427</p>
</div>
<div class='col-md-4 text-md-end'>
<h3 class='mb-0'>$3,400.00</h3>
<small class='opacity-75'>Due: June 27, 2024</small>
</div>
</div>
</div>
<div class='card-body p-4'>
<div class='row mb-4'>
<div class='col-md-6'>
<h6 class='text-primary text-uppercase mb-2'>From</h6>
<strong>Tech Innovations Ltd</strong><br>
contact@techinnovations.com
</div>
<div class='col-md-6 text-md-end'>
<h6 class='text-primary text-uppercase mb-2'>Bill To</h6>
<strong>Future Solutions GmbH</strong><br>
1234 Innovation Drive<br>
Berlin, 10115
</div>
</div>
<table class='table invoice-table'>
<thead>
<tr>
<th>Description</th>
<th class='text-center'>Qty</th>
<th class='text-end'>Unit Price</th>
<th class='text-end'>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cloud Hosting Services</td>
<td class='text-center'>12</td>
<td class='text-end'>€75.00</td>
<td class='text-end'>€900.00</td>
</tr>
<tr>
<td>Custom Web Application</td>
<td class='text-center'>3</td>
<td class='text-end'>€150.00</td>
<td class='text-end'>€450.00</td>
</tr>
<tr>
<td>Technical Support</td>
<td class='text-center'>15</td>
<td class='text-end'>€30.00</td>
<td class='text-end'>€450.00</td>
</tr>
<tr>
<td>Digital Marketing Campaign</td>
<td class='text-center'>2</td>
<td class='text-end'>€500.00</td>
<td class='text-end'>€1,000.00</td>
</tr>
<tr>
<td>SEO Optimization</td>
<td class='text-center'>5</td>
<td class='text-end'>€120.00</td>
<td class='text-end'>€600.00</td>
</tr>
</tbody>
</table>
<div class='row justify-content-end'>
<div class='col-md-4'>
<table class='table table-sm'>
<tr>
<td>Subtotal:</td>
<td class='text-end'><strong>€3,400.00</strong></td>
</tr>
<tr>
<td>Discount (10%):</td>
<td class='text-end text-success'>-€340.00</td>
</tr>
<tr>
<td>Tax (5%):</td>
<td class='text-end'>€153.00</td>
</tr>
<tr class='table-primary'>
<td><strong>Total Due:</strong></td>
<td class='text-end'><strong>€3,213.00</strong></td>
</tr>
</table>
</div>
</div>
<div class='alert alert-info mt-4'>
<strong>Payment Terms:</strong> Payment due within 30 days. Late payments may incur additional charges.
</div>
<div class='row mt-4 pt-3 border-top'>
<div class='col-md-6'>
<small class='text-muted'>Generated with IronPDF - No external APIs required</small>
</div>
<div class='col-md-6 text-md-end'>
<span class='badge bg-success'>PAID</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(professionalInvoice);
pdf.SaveAs("professional-invoice.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
string professionalInvoice = @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='___PROTECTED_URL_53___ rel='stylesheet'>
<style>
.invoice-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.invoice-table th { background: #f8f9fa; }
@media print { .invoice-box { page-break-inside: avoid; } }
</style>
</head>
<body>
<div class='container my-4'>
<div class='card shadow-lg invoice-box'>
<div class='invoice-header p-4'>
<div class='row align-items-center'>
<div class='col-md-8'>
<h1 class='mb-0'>INVOICE</h1>
<p class='mb-0 opacity-75'>Invoice #INV-2024-0427</p>
</div>
<div class='col-md-4 text-md-end'>
<h3 class='mb-0'>$3,400.00</h3>
<small class='opacity-75'>Due: June 27, 2024</small>
</div>
</div>
</div>
<div class='card-body p-4'>
<div class='row mb-4'>
<div class='col-md-6'>
<h6 class='text-primary text-uppercase mb-2'>From</h6>
<strong>Tech Innovations Ltd</strong><br>
contact@techinnovations.com
</div>
<div class='col-md-6 text-md-end'>
<h6 class='text-primary text-uppercase mb-2'>Bill To</h6>
<strong>Future Solutions GmbH</strong><br>
1234 Innovation Drive<br>
Berlin, 10115
</div>
</div>
<table class='table invoice-table'>
<thead>
<tr>
<th>Description</th>
<th class='text-center'>Qty</th>
<th class='text-end'>Unit Price</th>
<th class='text-end'>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cloud Hosting Services</td>
<td class='text-center'>12</td>
<td class='text-end'>€75.00</td>
<td class='text-end'>€900.00</td>
</tr>
<tr>
<td>Custom Web Application</td>
<td class='text-center'>3</td>
<td class='text-end'>€150.00</td>
<td class='text-end'>€450.00</td>
</tr>
<tr>
<td>Technical Support</td>
<td class='text-center'>15</td>
<td class='text-end'>€30.00</td>
<td class='text-end'>€450.00</td>
</tr>
<tr>
<td>Digital Marketing Campaign</td>
<td class='text-center'>2</td>
<td class='text-end'>€500.00</td>
<td class='text-end'>€1,000.00</td>
</tr>
<tr>
<td>SEO Optimization</td>
<td class='text-center'>5</td>
<td class='text-end'>€120.00</td>
<td class='text-end'>€600.00</td>
</tr>
</tbody>
</table>
<div class='row justify-content-end'>
<div class='col-md-4'>
<table class='table table-sm'>
<tr>
<td>Subtotal:</td>
<td class='text-end'><strong>€3,400.00</strong></td>
</tr>
<tr>
<td>Discount (10%):</td>
<td class='text-end text-success'>-€340.00</td>
</tr>
<tr>
<td>Tax (5%):</td>
<td class='text-end'>€153.00</td>
</tr>
<tr class='table-primary'>
<td><strong>Total Due:</strong></td>
<td class='text-end'><strong>€3,213.00</strong></td>
</tr>
</table>
</div>
</div>
<div class='alert alert-info mt-4'>
<strong>Payment Terms:</strong> Payment due within 30 days. Late payments may incur additional charges.
</div>
<div class='row mt-4 pt-3 border-top'>
<div class='col-md-6'>
<small class='text-muted'>Generated with IronPDF - No external APIs required</small>
</div>
<div class='col-md-6 text-md-end'>
<span class='badge bg-success'>PAID</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(professionalInvoice);
pdf.SaveAs("professional-invoice.pdf");
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim professionalInvoice As String = "
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='___PROTECTED_URL_53___ rel='stylesheet'>
<style>
.invoice-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.invoice-table th { background: #f8f9fa; }
@media print { .invoice-box { page-break-inside: avoid; } }
</style>
</head>
<body>
<div class='container my-4'>
<div class='card shadow-lg invoice-box'>
<div class='invoice-header p-4'>
<div class='row align-items-center'>
<div class='col-md-8'>
<h1 class='mb-0'>INVOICE</h1>
<p class='mb-0 opacity-75'>Invoice #INV-2024-0427</p>
</div>
<div class='col-md-4 text-md-end'>
<h3 class='mb-0'>$3,400.00</h3>
<small class='opacity-75'>Due: June 27, 2024</small>
</div>
</div>
</div>
<div class='card-body p-4'>
<div class='row mb-4'>
<div class='col-md-6'>
<h6 class='text-primary text-uppercase mb-2'>From</h6>
<strong>Tech Innovations Ltd</strong><br>
contact@techinnovations.com
</div>
<div class='col-md-6 text-md-end'>
<h6 class='text-primary text-uppercase mb-2'>Bill To</h6>
<strong>Future Solutions GmbH</strong><br>
1234 Innovation Drive<br>
Berlin, 10115
</div>
</div>
<table class='table invoice-table'>
<thead>
<tr>
<th>Description</th>
<th class='text-center'>Qty</th>
<th class='text-end'>Unit Price</th>
<th class='text-end'>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cloud Hosting Services</td>
<td class='text-center'>12</td>
<td class='text-end'>€75.00</td>
<td class='text-end'>€900.00</td>
</tr>
<tr>
<td>Custom Web Application</td>
<td class='text-center'>3</td>
<td class='text-end'>€150.00</td>
<td class='text-end'>€450.00</td>
</tr>
<tr>
<td>Technical Support</td>
<td class='text-center'>15</td>
<td class='text-end'>€30.00</td>
<td class='text-end'>€450.00</td>
</tr>
<tr>
<td>Digital Marketing Campaign</td>
<td class='text-center'>2</td>
<td class='text-end'>€500.00</td>
<td class='text-end'>€1,000.00</td>
</tr>
<tr>
<td>SEO Optimization</td>
<td class='text-center'>5</td>
<td class='text-end'>€120.00</td>
<td class='text-end'>€600.00</td>
</tr>
</tbody>
</table>
<div class='row justify-content-end'>
<div class='col-md-4'>
<table class='table table-sm'>
<tr>
<td>Subtotal:</td>
<td class='text-end'><strong>€3,400.00</strong></td>
</tr>
<tr>
<td>Discount (10%):</td>
<td class='text-end text-success'>-€340.00</td>
</tr>
<tr>
<td>Tax (5%):</td>
<td class='text-end'>€153.00</td>
</tr>
<tr class='table-primary'>
<td><strong>Total Due:</strong></td>
<td class='text-end'><strong>€3,213.00</strong></td>
</tr>
</table>
</div>
</div>
<div class='alert alert-info mt-4'>
<strong>Payment Terms:</strong> Payment due within 30 days. Late payments may incur additional charges.
</div>
<div class='row mt-4 pt-3 border-top'>
<div class='col-md-6'>
<small class='text-muted'>Generated with IronPDF - No external APIs required</small>
</div>
<div class='col-md-6 text-md-end'>
<span class='badge bg-success'>PAID</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>"
Dim pdf = renderer.RenderHtmlAsPdf(professionalInvoice)
pdf.SaveAs("professional-invoice.pdf")
輸出:一份 Professional PDF 發票,具備 Bootstrap 5 漸層頁首、響應式表格及計算摘要。 IronPDF 可以完美準確地渲染所有 CSS 漸層、表格樣式和實用類別 - 無需呼叫外部 API、無需模板、無需網際網路連線。 與 CraftMyPDF 的雲端方式不同,IronPDF 在您的伺服器上即時產生發票,並可完全控制。
這段程式碼的功能是什麼?
1.設定 RestClient:使用 CraftMyPDF API 端點初始化客戶端
- 新增標頭:包含 API 金鑰與內容類型以進行驗證
- 準備請求主體:建立包含範本資料與選項的 JSON 物件
- 傳送請求:執行 API 呼叫以產生 PDF
- 處理回應:下載生成的 PDF 或顯示錯誤訊息
對技術型創辦人而言,關鍵差異何在?
基於範本與程式碼優先的方法有何差異?
基於模板的(CraftMyPDF):
- 非技術團隊成員亦可建立及修改範本
- 範本由雲端儀表板集中管理
- 模板的變更無需部署程式碼
- 受限於版面設計規範
- 最適合版面配置可預測的標準化文件
Code-First (IronPDF):
- 透過 HTML 和 CSS 完全掌控文件版面配置
- 支援 JavaScript 可實現動態圖表與計算功能
- 範本是程式碼庫的一部分,並受版本控制
- 適用於任何網頁技術,設計靈活性無限制
- 特別適用於需要程式化邏輯處理的複雜動態文件
針對 Razor 範本,IronPDF 提供橫跨 MVC Core、MVC Framework 及 Razor Pages 的原生支援。
不同規模下的成本影響為何?
CraftMyPDF 成本結構:
- 免費方案:每月 50 次 API 呼叫,且模板數量上限為 3 個
- 付費方案的月費起價較高
- 每份 PDF 的費用將隨數量呈線性增長
- 持續性的月費/年費
- 進階功能需額外付費
IronPDF 成本結構:
對於每月處理 1,000 份以上 PDF 檔案的應用程式,IronPDF 的永久授權方案提供可預測的成本,且無需支付持續性費用。 授權計算器可協助估算總擁有成本。 請考慮為規模擴大的團隊提供升級與擴充方案。
開發工作流程有何差異?
CraftMyPDF 工作流程:
- 設計師在網頁介面中建立範本
- 開發者將 JSON 欄位映射至範本
- API 整合需要進行驗證設定
- 測試需進行 API 呼叫並消耗信用額度
- 範本更新發生在程式碼部署之外
IronPDF 工作流程:
IronPDF 的自包含式架構能加速迭代週期並支援離線開發,這對於快速開發至關重要。 此函式庫支援自訂記錄與渲染選項,以利除錯。
關於資料隱私與合規性?
CraftMyPDF 資料處理:
- 在雲端伺服器上處理的文件
- 需透過網際網路傳輸資料
- 符合規範的區域端點
- 暫存檔儲存政策
- 第三方資料處理協議
IronPDF 資料處理:
- 本地端處理可將資料保留在本地
- 無需外部 API 呼叫或網路連線
- 完全掌控文件安全性
- 符合 HIPAA 與 GDPR 規範的部署
- 敏感資料的加密選項
對於處理敏感客戶資料的應用程式,IronPDF 的本地處理功能可消除對第三方隱私的疑慮。 數位簽章與密碼保護提供了額外的安全防護層。 該函式庫亦支援 PDF/A 和 PDF/UA 標準以符合規範要求。
我能多快新增文件類型?
CraftMyPDF 時間軸:
- 版面設計:視複雜度而定,約需 1 至 4 小時
- 欄位對應與測試:1-2 小時
- 視設計師的空檔而定
- 模板審核流程可能會造成延遲
- 受編輯器功能限制
IronPDF 發展歷程:
- HTML 範本建立:30 分鐘至 2 小時
- 使用現有的網頁框架,例如 Bootstrap
- 在不同文件間重複使用 CSS 樣式表
- 在本地測試並即時獲得回饋
- 透過定期發布部署新的文件類型
IronPDF 的"程式碼優先"方法通常能縮短新文件類型的上市時間,特別是在利用現有網頁資產和框架時。 該函式庫支援 RTF 轉 PDF、DOCX 轉 PDF 以及 Markdown 轉 PDF 轉換,提供更靈活的選項。
有哪些授權選項?
IronPDF 提供一次性付費的永久授權。 Lite 許可證 ($999) 支援單一開發人員在一個專案上工作。 專業版授權($1,499)涵蓋多個專案和開發人員。 企業版授權($2,999)適用於部署需求廣泛的大型團隊。 每個許可證均包含一年的支援和更新服務。 OEM 再分發授權允許進行商業分發。 提供免費試用版供評估。 查看完整的授權選項。
CraftMyPDF 採用訂閱式定價。 免費方案適用於開發與測試,且 API 呼叫限制。 付費方案可提升使用限制並新增功能,並能配合業務需求進行擴展。 訂閱透過 CraftMyPDF 控制面板進行管理。
有哪些文件與支援資源可用?
IronPDF 在文件與技術支援方面提供哪些服務?
IronPDF 提供完整的文件,包含詳細指南、範例以及"快速入門"章節。 相關資源涵蓋從基礎用法到進階設定的各種內容。 支援管道包含知識庫、電子郵件支援以及工程支援請求。 支援團隊提供每週 5 天、每日 24 小時的服務,以提供即時協助。 疑難排解指南針對常見問題提供解決方案。
文件內容包含所有功能的 API 參考、教學指南及程式碼範例。 變更日誌用於追蹤更新,里程碑則標示主要版本發布。 如需遷移支援,請參閱比較 Aspose、iText、Syncfusion 及其他競爭對手的指南。
CraftMyPdf 提供哪些文件和支援?
CraftMyPDF 提供 API 文檔,詳細說明端點、參數和範例。 指南涵蓋範本建立、API 請求及回應處理等內容。 如有疑問或建議,可透過電子郵件及社群論壇獲得支援。
我該選擇哪種 PDF 解決方案?
IronPDF 和 CraftMyPDF 都提供了強大的 PDF 生成解決方案,但方法各不相同。 CraftMyPDF 憑藉其視覺化模板設計器和基於雲端的處理脫穎而出,而 IronPDF 則透過HTML 渲染提供完全的程式化控制。
IronPDF 憑藉其豐富的功能集,在處理複雜文件需求方面脫穎而出。 它能將 HTML、URL 和檔案轉換為 PDF,同時支援數位簽名、表單處理及文件編輯等進階功能。 無需外部依賴項的獨立部署模式,確保跨平台運作的可靠性。
各許可模式之間存在顯著差異。 IronPDF 的永久許可證起價為 $999,並提供免費試用以進行評估。 Iron Suite 套裝以購買兩款產品的價格提供九款產品,為完整的文件管理需求帶來非凡價值。
對於需要完全掌控 PDF 生成、具備豐富 HTML/CSS 支援、進階文件處理能力,且成本可預測的開發人員而言,IronPDF 提供了一套可靠的解決方案。 其詳盡的文件、即時支援以及靈活的部署選項,使其適用於從簡單的文件生成到複雜的Enterprise工作流程等各類應用場景。
CraftMyPDF 為其各自所有者的註冊商標。 本網站與 CraftMyPDF 沒有任何關聯、認可或贊助關係。 所有產品名稱、標誌和品牌均為其各自擁有者的財產。 比較僅供參考,反映了撰寫時的公開信息。常見問題解答
使用 C# PDF 庫相比基于 API 的解决方案有哪些优势?
像 IronPDF 这样全面的 PDF 庫提供了丰富的功能、与 .NET 開發环境的無缝集成、強大的支持和成本效益高的許可選項,使其成為复杂文檔處理的优越選择。
如何使用 C# 将 HTML 內容轉换為 PDF 文檔?
您可以使用 IronPDF 将 HTML 內容轉换為 PDF 文檔。它支持 HTML5 和 CSS3,确保網頁內容在生成的 PDF 中准确呈現。
IronPDF 在 PDF 生成中突出了哪些功能?
IronPDF 提供數字签名、表单填写、PDF 编辑、注释和跨平台兼容性。它在将 HTML、URL 和图像轉换為 PDF 時表現出色,并具有強大的性能和优化。
CraftMyPDF 如何處理 PDF 模板設计?
CraftMyPDF 提供基于網頁的拖放编辑器,允許用戶在不需要编碼的情况下設计 PDF 模板。它支持 JSON 數据集成,能够创建定制的 PDF 文檔。
像 IronPDF 这样的 PDF 工具有哪些許可選項?
IronPDF 提供灵活的許可選項,包括 Lite、Professional 和 Enterprise 許可證,一次性费用。它还為新用戶提供免费试用,以探索其功能。
如何将 PDF 生成 API 集成到我的 C# 應用程序中?
要集成像 CraftMyPDF 这样的 PDF 生成 API,您需要创建账户,選择適当的计划,獲取 API 密钥,并使用诸如 System.Net.Http 和 RestSharp 的庫進行 API 調用。
使用 IronPDF 的開發者有哪些支持资源可用?
IronPDF 提供丰富的文檔、教程和 24/5 技術支持。这些资源帮助開發者在他们的項目中有效地實現和排除庫的故障。
如何在 C# 應用程序中安装 IronPDF?
可以通過 Visual Studio 中的 NuGet 軟件包管理器安装 IronPDF,或者通過 NuGet 軟件包管理器控制台安装,也可以從 NuGet 網站直接下载軟件包。
IronPDF 如何增強 PDF 文檔的安全性和互動性?
IronPDF 支持數字签名和表单處理等功能,这些功能提高了文檔的安全性和互動性,使其適合全面的 PDF 管理。

