产品比较 CraftMyPDF和IronPDF之间的比较 Curtis Chau 已更新:七月 28, 2025 Download IronPDF NuGet 下载 DLL 下载 Windows 安装程序 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article PDF,或可携带文档格式,是由Adobe开发的一种文件格式,便于文档交换。 它确保文档在任何设备上看起来都是一样的,保留格式、字体和图像。 PDF具有安全、互动和紧凑的特点,使其在共享的同时保持内容完整无损。 C# PDF库对于处理PDF的开发人员来说是必不可少的。 这些工具帮助创建、修改和提取PDF内容。 它们支持表单处理、数字签名等功能,并跨不同平台工作,提高了PDF处理的效率。 借助C# PDF库,开发人员可以为其应用程序添加PDF功能,简化程序化创建、编辑和管理PDF文件。 In this article, we will compare two different approaches to working with PDFs: the IronPDF C# library and the Craftmypdf API. 我们将查看它们的特性和功能,提供代码示例,并讨论它们的许可证。 1. CraftMyPDF API基础解决方案 CraftMyPDF是一个多功能的API,旨在创建PDF文档。 它提供了一个基于Web的拖拽编辑器,让您可以直接在浏览器中设计PDF模板。 此功能对于从可重用模板和JSON数据创建像素完美的PDF尤为有用。 该编辑器包含丰富的布局组件,支持强大的表达式、高级格式和数据绑定,使其成为各种PDF生成需求的强大工具。 1.1 CraftMyPDF的主要特点 拖拽编辑器: CraftMyPDF的直观拖拽编辑器简化了PDF模板的创建。 您无需编码知识即可设计模板,使其适合所有技能水平的用户。 该编辑器允许您添加各种元素,如文本、图像和形状,并自定义其布局和外观。 模板可复用性: 平台支持可复用模板,这可以大大节省时间。 一旦设计出模板,它可以用不同的数据集反复使用,非常适合生成像发票、报告和证书这样的文档。 您可以使用PDF模板编辑器修改它。 JSON数据集成: CraftMyPDF允许与JSON数据无缝集成。 这意味着您可以将动态数据输入到您的模板中,以生成个性化的PDF文件。 此功能对于需要生成具有可变内容文档的应用尤为有用,如个性化发票或详细报告。 高级格式和表达式: API支持高级格式选项和表达式,使您能够创建复杂的文档。 您可以根据您的规范格式化日期、数字和货币,并使用表达式根据数据动态生成内容。 API集成: CraftMyPDF可以通过其REST API集成到各种平台中。 它支持与无代码平台如Zapier和Make.com 及自定义应用程序集成。 这种灵活性使开发人员能够将PDF生成功能整合到他们的工作流程中,并自动化文档创建过程。 可填写组件: 平台还支持可填写的PDF组件,例如文本字段、复选框和下拉列表。 此功能对于创建用户可以电子完成的交互式表单至关重要。 安全和合规: CraftMyPDF确保对已生成PDF的安全访问,并支持区域API端点以符合GDPR等数据保护法规。 这种对安全性的关注使其成为处理敏感文件的可靠选择。 2. IronPDF介绍 IronPDF .NET开发人员PDF库 是为.NET开发人员设计的强大而多功能的PDF库,提供生成、编辑和管理PDF文档的广泛能力。 用C#编写的IronPDF简化了处理PDF的过程,允许开发人员从HTML、CSS、JavaScript和图像格式生成像素完美的PDF文档。 它与.NET的集成使其成为任何需要PDF功能的应用的强大工具,从简单文件生成到复杂文档操作。 2.1 IronPDF的主要功能 HTML到PDF转换: IronPDF在直接将HTML, CSS和JavaScript转换为PDF文档方面表现出色。 这包括对HTML5和CSS3的支持,确保您的Web内容在生成的PDF中如预期般呈现。 转换过程保持像素完美的准确性,适合从Web到打印的应用程序。 URL到PDF: 您可以从任何URL生成PDF,轻松将网页保存为PDF文件。 此功能对归档Web内容或从在线数据生成报告非常有用。 图像到PDF: IronPDF支持将各种图像格式,包括JPG, PNG, GIF, BMP和SVG,转换为PDF文档。 此功能适用于创建相册、图像画廊或将视觉内容整合到您的PDF中。 表单填写和数据提取: 该库允许程序性地创建和填写PDF表单。 此外,您可以从现有表单中提取数据,方便无缝的数据处理和与其他系统的集成。 数字签名和安全: IronPDF提供强大的安全功能,包括添加数字签名、设置密码和定义用户权限。 这确保了您的PDF文档安全并符合行业标准。 PDF编辑: 您可以通过添加、复制或删除页面来编辑现有的PDF文档。 导入现有的PDF文件。 IronPDF还允许合并和拆分PDF,使其成为文档管理的全面工具。 注释和附件: IronPDF支持添加注释,如便签,并嵌入PDF文档中的附件。 此功能在协作文档审阅和添加补充信息时非常有用。 页眉、页脚和水印: 库允许在PDF文档中添加自定义页眉、页脚和水印。 这些元素可以从HTML生成,提供设计和内容管理的灵活性。 跨平台兼容性: IronPDF可在包括Windows, macOS, Linux, Docker, Azure和AWS在内的各种平台上无缝工作。 它支持.NET Core, .NET Standard和.NET Framework,确保广泛的兼容性和在不同环境中的易于部署。 性能优化: 具有完整的多线程和异步支持,IronPDF为批量处理和高容量PDF生成任务优化了性能。 这确保了资源的高效使用和更快的文档处理。 全面的文档和支持: IronPDF提供广泛的文档、教程和示例,便于开发人员入门。 该库还提供24/5的技术支持,帮助用户快速解决问题。 无外部依赖: IronPDF以单个DLL的形式运行,不需要额外的软件或安装。 这简化了部署,减少了与其他软件组件的潜在冲突。 IronPDF旨在提升生产力,简化.NET应用程序中的PDF管理。 其丰富的功能集结合易用性和全面的支持,使其成为开发人员不可或缺的工具。 3. 在Visual Studio中创建一个C#应用程序 在Visual Studio中创建一个C#控制台应用程序涉及几个步骤。 以下是帮助您设置并启动项目的详细指南。 3.1. 打开Visual Studio 首先,确保您的电脑上安装了Visual Studio。 在“开始”菜单中搜索或点击桌面图标打开Visual Studio。 3.2. 创建一个新项目 打开Visual Studio后,请按照以下步骤创建一个新项目: 点击开始页面上的“创建一个新项目”。 在“创建一个新项目”窗口中,将显示项目模板列表。 使用搜索栏查找“Console App”或从模板列表中选择它。 3.3. 选择项目模板 从搜索结果或列表中选择“Console App (.NET Core)”或“Console App (.NET Framework)”,具体取决于您的偏好或项目要求。 3.4. 配置您的项目 选择控制台应用模板后,您需要配置新项目: 项目名称:输入项目名称。 这将是保存项目文件的文件夹的名称。 位置:选择要保存项目的文件夹。 解决方案名称:此名称通常与项目名称相同,但如果您计划在一个解决方案中包含多个项目,可以更改它。 点击“创建”以继续。 4. 安装 IronPDF 要使用IronPDF有三种主要的安装方法:使用NuGet包管理器,NuGet包管理器控制台,以及从NuGet网站下载。 4.1 NuGet包管理器 首先,让我们谈谈NuGet包管理器。 如果您使用Visual Studio,此方法是简单和用户友好的。 打开您的项目,右键点击在解决方案资源管理器中的“引用”或“依赖项”节点。 从上下文菜单中选择“管理NuGet包”。 在NuGet包管理器中,确保选择“浏览”选项卡,然后在搜索框中输入“IronPDF”。 找到IronPDF包后,点击“安装”。这将把IronPDF库添加到您的项目中并配置以供使用。 4.2 NuGet包管理器控制台 接下来,NuGet包管理器控制台提供了另一种简便的方法安装IronPDF。 要访问这个,在Visual Studio中进入菜单“工具”,选择“NuGet包管理器”,然后选择“包管理器控制台”。在控制台窗口中输入以下命令: Install-Package IronPdf 并按回车。 这个命令将会直接下载并安装IronPDF包到您的项目。 这种方法对那些喜欢在Visual Studio环境中使用命令行工具的人很高效。 4.3 NuGet网站 最后,您可以直接从NuGet网站下载IronPDF包。 如果您需要手动管理包版本或在一个直接包管理受限的环境下工作,此方法特别有用。 转到NuGet网站,搜索“IronPDF”。下载包文件(通常是.nupkg文件)。 下载后,在Visual Studio中打开您的项目,右键点击“引用”或“依赖项”,选择“管理NuGet包”。点击“设置”图标,然后选择“添加”来指定下载的包的路径。 添加包源后,返回到“浏览”选项卡,选择新的源并从那里安装IronPDF。 5. 使用CraftMyPDF 要在您的C#程序中使用CraftMyPDF,您首先需要创建一个账户,选择API的免费计划,然后将其集成到您的应用程序中。 以下是如何入手: 5.1. 创建一个账户并选择免费计划 注册:访问CraftMyPDF网站并注册一个免费账户。 输入所需信息以创建账户。 选择免费计划:创建账户后,导航到定价部分并选择免费计划。 此计划通常允许您使用API的一些有限功能和配额,非常适合开发和测试。 获取API密钥:选择计划后,进入您的账户仪表盘。 在这里,您将找到您的API密钥。 这个密钥是验证您的API请求所必需的。 5.2 安装所需的库 确保您拥有System.Net.Http,RestSharpt,和Newtonsoft JSON命名空间可用,因为它是对CraftMyPDF API进行HTTP请求所必需的。 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; IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 之后我们就会调用CraftMyPDF API。 var client = new RestClient("https://api.craftmypdf.com/v1/create"); 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("https://api.craftmypdf.com/v1/create"); 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 = New RestClient("https://api.craftmypdf.com/v1/create") Dim request = 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") $vbLabelText $csharpLabel 6. 生成PDF 程序化创建PDF能够自动生成报告、发票和证书等文档。 IronPDF提供了几种在C#中创建PDF的方法,包括将HTML字符串、URL和HTML文件转换为PDF文档。 我们将在后面的章节中详细讨论方法。 6.1 使用IronPDF创建PDF 6.1.1 HTML转PDF 将HTML转换为PDF是最常见的用例之一。 它允许您使用HTML和CSS设计文档,然后将其转换为PDF。 这种方法非常灵活,因为它支持现代网页标准,并确保生成的PDF看起来恰如其分地设计。 以下是使用IronPDF将HTML字符串转换为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"); } } 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 $vbLabelText $csharpLabel 在这个例子中,ChromePdfRenderer将所提供的HTML字符串转换为PDF。 渲染的PDF随后被保存到文件系统中。 6.1.2 URL转PDF IronPDF的另一个强大功能是能够直接从其URL将网页转换为PDF文档。 这对于归档网页或从动态网页内容生成PDF特别有用。 以下是如何将URL转换为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"); } } 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"); } } IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 此方法将URL作为输入,将网页渲染为PDF,并保存生成的文档。 它处理所有网页内容,包括HTML,CSS,JavaScript和图像,确保PDF准确反映原网页。 6.1.3 HTML文件转PDF 将HTML文件转换为PDF类似于转换HTML字符串或URL。 此方法允许您使用本地HTML文件,便于从预先存在的网页或存储在文件系统上的模板生成PDF。 以下是如何将HTML文件转换为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"); } } 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"); } } IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 在这个例子中,RenderHtmlFileAsPdf方法用于将由其文件路径指定的HTML文件内容转换为PDF文档。 然后保存生成的PDF。 通过利用这些方法,您可以借助IronPDF从各种来源的HTML内容创建PDF,为文档在您的C#应用程序中的生成提供灵活和强大的解决方案。 这些方法确保您可以轻松集成PDF创建功能,无论您是在处理动态网页内容、本地HTML文件还是直接定义的HTML字符串。 6.2 使用CraftMyPDF API创建PDF CraftMyPDF为从模板生成PDF提供了灵活的API。 要使用此API创建PDF,您必须首先在CraftMyPDF仪表盘中创建一个模板。 一旦您的模板准备就绪,您可以带着必要的数据发送 API 请求来生成PDF。 以下是实现这一目标的步骤。 6.2.1 创建模板 登录CraftMyPDF仪表盘: 登入您的CraftMyPDF账户,并导航到仪表盘。 创建新模板: 点击“创建模板”按钮。 使用拖拽式编辑器设计您的PDF模板。 您可以根据需要包括文本、图像、表格和其他元素。 保存模板: 设计完成后,保存模板。 系统会提供给您一个模板ID,您将需要使用该ID来生成使用该模板的PDF。 6.2.2 发送请求以生成PDF 创建模板后,可以使用以下C#代码通过向CraftMyPDF API发送请求来生成PDF。 using System; using System.Net; using System.Threading.Tasks; using RestSharp; class Program { static async Task Main(string[] args) { var client = new RestClient("https://api.craftmypdf.com/v1/create"); 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("https://api.craftmypdf.com/v1/create"); 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}"); } } } 'INSTANT VB NOTE: 'Option Strict Off' is used here since dynamic typing is used: Option Strict Off Imports System Imports System.Net Imports System.Threading.Tasks Imports RestSharp Friend Class Program Shared Async Function Main(ByVal args() As String) As Task Dim client = New RestClient("https://api.craftmypdf.com/v1/create") Dim request = 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 { Key .data = New With { Key .invoice_number = "INV48321", Key .date = "2024-05-27", Key .due_date = "2024-06-27", Key .currency = "EUR", Key .discount = 10, Key .tax = 5, Key .company_name = "Tech Innovations Ltd", Key .email = "contact@techinnovations.com", Key .client = "Future Solutions GmbH", Key .client_address = "1234 Innovation Drive", Key .client_address2 = "Berlin", Key .client_address3 = "10115", Key .items = { New With { Key .description = "Cloud Hosting Services", Key .quantity = 12, Key .unit_price = 75, Key .total = 900 }, New With { Key .description = "Custom Web Application", Key .quantity = 3, Key .unit_price = 150, Key .total = 450 }, New With { Key .description = "Technical Support", Key .quantity = 15, Key .unit_price = 30, Key .total = 450 }, New With { Key .description = "Digital Marketing Campaign", Key .quantity = 2, Key .unit_price = 500, Key .total = 1000 }, New With { Key .description = "SEO Optimization", Key .quantity = 5, Key .unit_price = 120, Key .total = 600 } }, Key .gross_total = 3400 }, Key .load_data_from = DirectCast(Nothing, String), Key .template_id = templateId, Key .version = 8, Key .export_type = "json", Key .expiration = 60, Key .output_file = "output.pdf", Key .is_cmyk = False, Key .image_resample_res = 600, Key .direct_download = 0, Key .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 'INSTANT VB NOTE: In the following line, Instant VB substituted 'Object' for 'dynamic' - this will work in VB with Option Strict Off: Dim result As Object = Newtonsoft.Json.JsonConvert.DeserializeObject(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 Class $vbLabelText $csharpLabel 它是由PDF生成API CraftMyPdf生成的PDF文档: Bootstrap发票生成 专业发票生成需要现代、响应性布局。 这个Bootstrap 5示例展示了IronPDF创建像素完美发票的能力,无需外部API或模板。 using IronPdf; var renderer = new ChromePdfRenderer(); string professionalInvoice = @" <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'> <style> .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='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' 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"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 输出:使用Bootstrap 5梯度标题、响应表格和计算摘要的专业发票PDF。 IronPDF准确呈现所有CSS渐变、表格样式和实用程序类——无需外部API调用,无需模板,无需互联网连接。 与CraftMyPDF的云端方式不同,IronPDF在您的服务器上即时生成发票,并拥有完全控制。 有关Bootstrap表格支持的更多信息,请参阅Bootstrap和Flexbox CSS指南。 代码解释 设置RestClient和RestRequest:用CraftMyPDF API URL实例化RestClient,并为生成PDF的POST方法创建RestRequest。 添加头部:API密钥被添加在请求头中以进行认证。 内容类型设置为application/json。 准备请求体:请求体是一个JSON对象。 它包含填充模板字段的数据,模板ID和各种选项如导出类型和过期时间。 发送请求:请求被异步发送使用ExecuteAsync并根据请求体生成PDF文档。 处理响应:如果响应成功,生成的PDF文件的URL将从响应中提取,文件将使用WebClient下载到本地路径。 若请求不成功,将打印错误信息。 7. 许可证 IronPDF提供了多种许可选项以满足不同用户的需求。 主要的许可包括Lite,Professional和Enterprise版本。 Lite许可,价格为$799,适合单个项目的单个开发人员。 Professional许可费用为$1,199,支持多个项目和开发人员,而Enterprise许可则是为大型团队和更广泛的部署设计,价格为$2,399。 每个许可都是一次性费用,并包括一年期的支持和更新。 另外,还有OEM再分发许可,允许将IronPDF作为商用产品的一部分分发。 IronPDF还提供用于评估目的的免费试用版本。 CraftMyPDF采用基于订阅的许可模式。 它提供几个计划,包括适合小规模和开发目的的免费层。 免费计划允许有限使用API,适合用于测试和小项目。 对于更高的使用需求,有付费计划,提供增加的API调用限制和附加功能。 这些付费计划随着业务需求的增长提供灵活性和强大的支持。 用户需要通过CraftMyPDF网站订阅这些计划,并能通过用户仪表盘管理他们的订阅和API密钥。 8. 文档和支持 8.1 IronPDF文档和支持 IronPDF提供了广泛的文档和强大的支持以帮助用户有效使用该库。 文档详尽,无论是详细指南、示例,还是帮助新用户快速入门的快速入门部分。 关键章节覆盖基本用法、高级配置和故障排除。 此外,IronPDF通过多种渠道提供支持,包括丰富的知识库、电子邮件支持以及更复杂问题的工程支持请求。 支持团队24/5可用,提供快速帮助解决用户的查询和问题。 8.2 CraftMyPdf文档和支持 CraftMyPDF也为其用户提供了全面的文档和支持。 API文档提供所有可用端点、参数和请求示例的详细信息,确保开发人员可以顺利集成API。 文档包括创建模板、发出API请求和处理响应的指南。 CraftMyPDF通过电子邮件提供客户支持,并提供一个社区论坛,用户可以在这里提问和分享见解。 文档设计为用户友好,确保所有技能水平的开发人员都能有效使用API生成PDF。 9. 结论 在本文中,我们探讨了两个强大的PDF生成工具:IronPDF和CraftMyPDF的功能、许可和文档。 这两个工具都提供了强大的功能来创建和管理PDF文档,但IronPDF凭借几个显著的优势脱颖而出。 IronPDF提供了一套全面的功能,以满足各种PDF生成需求,包括将HTML字符串、URL和HTML文件轻松转换为PDF。 它与.NET环境的无缝集成以及处理复杂文件结构的能力使其成为一个高度通用的工具。 此外,IronPDF支持高级设置如添加页眉和页脚、数码签名以及处理PDF表单,确保其可以满足各种应用的需求。 IronPDF的一大优势是其许可结构。 它提供免费试用,允许用户在购买前评估软件。 许可证起价为$799,使其对个人开发人员和小团队可访问。 此外,IronPDF还通过提供九个产品的Iron Suite以两个价格,提供了卓越的价值主张,是综合PDF和文档管理需求的经济选择。 综上所述,虽然IronPDF和CraftMyPDF都是用于PDF生成的优秀工具,但IronPDF提供了更广泛的功能集、强大的支持和更具吸引力的许可模式。 其处理复杂文档需求的能力和价格合适的Iron Suite套餐使它在CraftMyPDF之上。 无论您是个人开发人员还是更大团队的一员,IronPDF为您的所有PDF生成需求提供可靠而强大的解决方案。 [{i:(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提供一个基于Web的拖放编辑器,允许用户无需编程即可设计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管理。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 相关文章 已发布十一月 13, 2025 比较 C# HTML 到 PDF 开源与 IronPDF 比较开源 HTML 到 PDF 库与 IronPDF for C#。发现哪个解决方案为您的 .NET 项目提供最佳的 PDF 生成能力。 阅读更多 已发布十月 27, 2025 哪种 ASP.NET Core PDF 库性价比最高? 发现适合ASP.NET Core应用程序的最佳PDF库。比较IronPDF的Chrome引擎与Aspose和Syncfusion的替代品。 阅读更多 已发布十月 27, 2025 如何使用 Aspose C# 与 IronPDF 创作 PDF 通过此逐步指南,学习如何使用 Aspose C# 与 IronPDF 创建 PDF,专为开发人员设计。 阅读更多 HTML到PDF转换器在C#中GroupDocs替代方案Compdfkit和IronPDF之间的比较
已发布十一月 13, 2025 比较 C# HTML 到 PDF 开源与 IronPDF 比较开源 HTML 到 PDF 库与 IronPDF for C#。发现哪个解决方案为您的 .NET 项目提供最佳的 PDF 生成能力。 阅读更多
已发布十月 27, 2025 哪种 ASP.NET Core PDF 库性价比最高? 发现适合ASP.NET Core应用程序的最佳PDF库。比较IronPDF的Chrome引擎与Aspose和Syncfusion的替代品。 阅读更多
已发布十月 27, 2025 如何使用 Aspose C# 与 IronPDF 创作 PDF 通过此逐步指南,学习如何使用 Aspose C# 与 IronPDF 创建 PDF,专为开发人员设计。 阅读更多