跳至页脚内容
产品比较

IronPDF vs XFINIUM.PDF:.NET的HTML到PDF库比较

IronPDF在使用Chromium引擎进行HTML到PDF转换方面表现出色,完全支持CSS和JavaScript。相比之下,XFINIUM.PDF专注于低级PDF操作,不支持原生HTML渲染,使得IronPDF成为在.NET应用程序中进行现代网页PDF生成的更适合选择。

现代技术为开发者提供了更智能的解决方案,自动化正在推动软件开发过程。 处理C# PDF文件长期以来一直是开发者的一大挑战。 在为PDF文件创建内容时,必须考虑多种因素,而在将不同格式的内容转换为PDF时,更需要如此。 这些挑战现在通过旨在帮助读取、写入、创建和转换来自各种格式的PDF的库得到解决。

本文比较了两个流行的PDF库,适用于.NET.NET Core 开发人员:

IronPDF和XFINIUM.PDF都提供了在.NET和.NET Core中创建操作打印PDF的方法。 您可以通过查看以下两个库及其各自针对PDF转换和操作的功能比较来做出明智的决定。

首先,让我们探讨这两个库提供的功能,然后再进行比较。

XFINIUM.PDF库有什么功能?

XFINIUM.PDF库是一个跨平台的PDF开发工具,适用于初学者和高级PDF开发人员。 它让您可以创建报告填写PDF表单、构建PDF组合、从PDF报告中删除敏感数据,或将PDF报告转换为多页TIFF图像

XFINIUM.PDF 有两个版本:Generator Edition,包括PDF生成和编辑;Viewer Edition,增加了PDF渲染PDF查看功能。

XFINIUM.PDF完全使用C#编写,作为完全托管的代码。 它按开发者授权,免版税分发,使您可以在不增加额外成本的情况下分发您的程序。

生成器版和查看器版之间有什么区别?

生成器版是查看器版的一个子集。 它提供创建和编辑PDF的功能,而Viewer版增加了PDF渲染功能。 The Viewer Edition 可以将PDF页面转换为RAW、BMP、GIF、JPG、PNG和TIFF图像

XFINIUM.PDF 规范

关键特性包括:

安全性

数字签名

条码

内置矢量条码引擎

  • 一维条码:
  • Codabar, Code 11, Code 25, Code 39/93/128
  • Pharmaceutical: Code 32, Pharmacode, PZN
  • 二维条码:
  • DataMatrix、QR、PDF417、Micro PDF417

对于高级条码功能,您可以考虑Ironbarcode 文档,它提供完整的条码生成和读取功能。

内容提取

低级 COS API

  • 添加、编辑和删除 COS 对象
  • 支持的类型:字符串、数字、名称、布尔值、空值、数组、字典、流

PDF 渲染(仅限查看器版)

IronPDF的主要功能是什么?

IronPDF .NET PDF库简化了C#程序员的PDF开发。 使用此工具,您可以轻松构建适用于.NET的核心PDF库。

IronPDF 将HTML页面转换为PDF文件,使用.NET Chromium引擎。 您无需使用复杂的API即可通过HTML转换为PDF来定位或设计PDF。 支持标准的网页文档,包括HTML、ASPX、JS、CSS和图像

您可以使用HTML5、CSS、JavaScript和图像来开发.NET PDF库。 可以使用页眉和页脚来编辑、标记和改进PDF文件。 该库有效管理读取PDF文本提取图形

免费下载 IronPDF,并立即在您的 .NET 项目中使用。

IronPDF C# 库的突出特点

关键特性包括:

生成 PDF(HTML 到 PDF)

编辑现有PDF文档

读取和填写表单字段

操作PDF文档

转换各种文件格式

打印和节省

IronPDF支持所有主要操作系统和框架:

.NET Core 2.1, 3.0, 3.1, .NET 6和5

如何安装IronPDF C#库?

您可以通过以下四种方式下载并安装IronPDF:

  1. 使用 Visual Studio
  2. 开发人员命令提示符
  3. 直接下载NuGet 包
  4. 下载 IronPDF .DLL 库

使用Visual Studio

Visual Studio提供NuGet包管理器来安装项目中的包。 通过项目菜单访问,或在解决方案资源管理器中右键单击您的项目。

Visual Studio Project menu showing various options including 'Manage NuGet Packages' highlighted for package management.

**图 1**。使用 Visual Studio 中的项目菜单访问 NuGet 包管理器

Visual Studio Solution Explorer context menu showing the Manage NuGet Packages option highlighted in yellow

**图 2**。使用 Visual Studio 中的上下文菜单访问 NuGet 包管理器

选择后,浏览以查找IronPDF包并安装它。

Visual Studio interface showing NuGet Package Manager with IronPDF library search results and installation options

**图 3**。使用 Visual Studio 中的 NuGET 包管理器安装 IronPDF 库

使用开发人员命令提示

通过开发人员命令提示符安装IronPDF NuGet package

打开开发人员命令提示符

  • 键入以下命令:

    nuget install IronPdf
    nuget install IronPdf
    SHELL
  • 按回车键
  • 软件包下载并安装
  • 重新加载您的Visual Studio项目

直接下载 NuGet 包

直接从NuGet下载并安装IronPDF:

  • 请访问 IronPdf NuGet页面
  • 选择下载包
  • 双击下载的软件包
  • 软件包安装
  • 重新加载您的Visual Studio项目

通过下载库安装 IronPDF

直接从IronPDF下载下载IronPDF .DLL文件。

IronPDF website homepage showing the C# PDF Library with download options for DLL and NuGet installation

**图 4**。从 IronPDF 网站下载 IronPDF 库 DLL

在项目中引用该库:

  • 右键单击解决方案资源管理器中的解决方案
  • 选择引用
  • 浏览 IronPDF.dll 库
  • 点击确定

IronPDF现在可以使用。 接下来让我们安装XFINIUM.PDF。

我如何安装XFINIUM.PDF?

在.NET Core中,安装Xfinium PDF作为cake插件或工具:

# Install Xfinium.Pdf.NetCore as a Cake Addin
#addin nuget:?package=Xfinium.Pdf.NetCore&version=10.2.0
# Install Xfinium.Pdf.NetCore as a Cake Addin
#addin nuget:?package=Xfinium.Pdf.NetCore&version=10.2.0
SHELL
# Install Xfinium.Pdf.NetCore as a Cake Tool
#tool nuget:?package=Xfinium.Pdf.NetCore&version=10.2.0
# Install Xfinium.Pdf.NetCore as a Cake Tool
#tool nuget:?package=Xfinium.Pdf.NetCore&version=10.2.0
SHELL

现在让我们比较IronPDF和XFINIUM.PDF。

如何在.NET Core中创建一个简单的PDF文档?

软件开发人员必须知道如何使用C#动态创建PDF文件。 您可能需要PDF创建功能以从用户输入生成报告、将用户文本保存为PDF、提取HTML信息并将其转换为PDF,等等。

这两个库都可以将HTML网页转换为PDF。 让我们来研究每个库的方法。

使用 IronPDF.

IronPDF提供多种创建PDF文件的方法。

将现有 URL 转换为 PDF.

IronPDF使从现有URL将HTML转换为PDF文档变得简单。 JavaScript图片、表单和CSS均获得全面支持。

实现会自动处理URL渲染:

// Create an instance of the ChromePdfRenderer
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();

// Configure rendering options for better performance
Renderer.RenderingOptions.WaitFor.RenderDelay = 500; // Wait for JavaScript to load
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

// Render a URL to PDF
using var Pdf = Renderer.RenderUrlAsPdf("___PROTECTED_URL_134___");

// Save the PDF with metadata
Pdf.MetaData.Author = "IronPDF";
Pdf.MetaData.Title = "Website to PDF Conversion";
Pdf.SaveAs("url.pdf");
// Create an instance of the ChromePdfRenderer
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();

// Configure rendering options for better performance
Renderer.RenderingOptions.WaitFor.RenderDelay = 500; // Wait for JavaScript to load
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

// Render a URL to PDF
using var Pdf = Renderer.RenderUrlAsPdf("___PROTECTED_URL_134___");

// Save the PDF with metadata
Pdf.MetaData.Author = "IronPDF";
Pdf.MetaData.Title = "Website to PDF Conversion";
Pdf.SaveAs("url.pdf");
$vbLabelText   $csharpLabel

将 HTML 输入字符串转换为 PDF 文件

请参考以下用于从HTML字符串渲染PDF页面的代码示例。 可以单独使用HTML,也可以将其与CSS、图像和JavaScript结合使用:

// Create an instance of the ChromePdfRenderer
var Renderer = new IronPdf.ChromePdfRenderer();

// Configure rendering options
Renderer.RenderingOptions.MarginTop = 50; // millimeters
Renderer.RenderingOptions.MarginBottom = 50;
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

// Render a simple HTML string to PDF
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");

// Add document properties
PDF.MetaData.Author = "Development Team";
PDF.MetaData.Keywords = "HTML, PDF, C#";
PDF.MetaData.ModifiedDate = DateTime.Now;

// Save the PDF
PDF.SaveAs("pixel-perfect.pdf");

// Load external HTML assets: images, CSS, and javascript
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from 
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");

// Apply security settings
AdvancedPDF.Password = "pass123";
AdvancedPDF.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;

// Save the advanced PDF with external assets
AdvancedPDF.SaveAs("html-with-assets.pdf");
// Create an instance of the ChromePdfRenderer
var Renderer = new IronPdf.ChromePdfRenderer();

// Configure rendering options
Renderer.RenderingOptions.MarginTop = 50; // millimeters
Renderer.RenderingOptions.MarginBottom = 50;
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

// Render a simple HTML string to PDF
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");

// Add document properties
PDF.MetaData.Author = "Development Team";
PDF.MetaData.Keywords = "HTML, PDF, C#";
PDF.MetaData.ModifiedDate = DateTime.Now;

// Save the PDF
PDF.SaveAs("pixel-perfect.pdf");

// Load external HTML assets: images, CSS, and javascript
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from 
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");

// Apply security settings
AdvancedPDF.Password = "pass123";
AdvancedPDF.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;

// Save the advanced PDF with external assets
AdvancedPDF.SaveAs("html-with-assets.pdf");
$vbLabelText   $csharpLabel

有关高级HTML到PDF转换技术,请参阅HTML到PDF教程

使用 XFINIUM.PDF

使用XFINIUM.PDF创建一个空白PDF文档需要三行:创建文档、创建页面并保存:

// Create a new PDF document
PdfFixedDocument document = new PdfFixedDocument();

// Add a page to the document
PdfPage page = document.Pages.Add();

// Save the document as a PDF file
document.Save("empty.pdf");
// Create a new PDF document
PdfFixedDocument document = new PdfFixedDocument();

// Add a page to the document
PdfPage page = document.Pages.Add();

// Save the document as a PDF file
document.Save("empty.pdf");
$vbLabelText   $csharpLabel

添加文本内容需要三个额外的步骤:创建字体、创建用于颜色的画笔以及绘制文本:

// Create a new PDF document
PdfFixedDocument document = new PdfFixedDocument();
PdfPage page = document.Pages.Add();

// Create a standard font with Helvetica face and 24 point size
PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 24);

// Create a solid RGB red brush.
PdfBrush brush = new PdfBrush(PdfRgbColor.Red);

// Draw the text on the page.
page.Graphics.DrawString("Hello World", helvetica, brush, 100, 100);

// Save the document as a PDF file
document.Save("helloworld.pdf");
// Create a new PDF document
PdfFixedDocument document = new PdfFixedDocument();
PdfPage page = document.Pages.Add();

// Create a standard font with Helvetica face and 24 point size
PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 24);

// Create a solid RGB red brush.
PdfBrush brush = new PdfBrush(PdfRgbColor.Red);

// Draw the text on the page.
page.Graphics.DrawString("Hello World", helvetica, brush, 100, 100);

// Save the document as a PDF file
document.Save("helloworld.pdf");
$vbLabelText   $csharpLabel

对象模型与PDF标准非常相似。 这种方法为构建复杂的抽象结构(如流文档)提供了明显的好处。## 如何创建可填写的PDF文件

使用 XFINIUM.PDF

XFINIUM.PDF允许您创建新的PDF表单填写现有的PDF表单

每种PDF表单字段类型都有一个对应的类:

PdfTextBoxField – 文本框字段 PdfCheckBoxField – 复选框

  • PdfRadioButtonField – 单选按钮组
  • PdfComboboxField – 组合框
  • PdfListboxField – 列表框
  • PdfPushbuttonField – 按动按钮
  • PdfSignatureField – 签名字段

要创建表单字段,请指定字段名称和页面位置。 创建字段对象后,将其添加到页面并设置其属性:

// Create a text box field named "firstname"
PdfTextBoxField firstNameTextBox = new PdfTextBoxField("firstname");

// Add the field to a PDF page
pdfpage.Fields.Add(firstNameTextBox);

// Set the position of the field on the PDF page
firstNameTextBox.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 45, 200, 20);
// Create a text box field named "firstname"
PdfTextBoxField firstNameTextBox = new PdfTextBoxField("firstname");

// Add the field to a PDF page
pdfpage.Fields.Add(firstNameTextBox);

// Set the position of the field on the PDF page
firstNameTextBox.Widgets[0].VisualRectangle = new PdfVisualRectangle(150, 45, 200, 20);
$vbLabelText   $csharpLabel

要填写现有的PDF表单,将其加载到PdfFixedDocument对象中。 文档的字段集合会自动填充。 您可以通过索引或名称查找字段,并通过设置值属性来填写它们:

// Load an existing PDF document with forms
PdfFixedDocument document = new PdfFixedDocument("form.pdf");

// Fill form fields with values
(document.Form.Fields["firstname"] as PdfTextBoxField).Text = "John";
(document.Form.Fields["lastname"] as PdfTextBoxField).Value = "Doe";
(document.Form.Fields["sex"].Widgets[0] as PdfRadioButtonWidget).Checked = true;
(document.Form.Fields["firstcar"] as PdfComboBoxField).SelectedIndex = 0;
(document.Form.Fields["secondcar"] as PdfListBoxField).SelectedIndex = 1;
(document.Form.Fields["agree"] as PdfCheckBoxField).Checked = true;

// Save the filled form as a new PDF file
document.Save("form_filled.pdf");
// Load an existing PDF document with forms
PdfFixedDocument document = new PdfFixedDocument("form.pdf");

// Fill form fields with values
(document.Form.Fields["firstname"] as PdfTextBoxField).Text = "John";
(document.Form.Fields["lastname"] as PdfTextBoxField).Value = "Doe";
(document.Form.Fields["sex"].Widgets[0] as PdfRadioButtonWidget).Checked = true;
(document.Form.Fields["firstcar"] as PdfComboBoxField).SelectedIndex = 0;
(document.Form.Fields["secondcar"] as PdfListBoxField).SelectedIndex = 1;
(document.Form.Fields["agree"] as PdfCheckBoxField).Checked = true;

// Save the filled form as a new PDF file
document.Save("form_filled.pdf");
$vbLabelText   $csharpLabel

使用 IronPDF.

下面是您如何使用IronPDF 创建可填写的PDF

// PM> Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;

// Step 1. Creating a PDF with editable forms from HTML using form and input tags
var FormHtml = @"
<html>
    <head>
        <style>
            body { font-family: Arial, sans-serif; margin: 40px; }
            h2 { color: #333; }
            form { background: #f4f4f4; padding: 20px; border-radius: 8px; }
            input[type='text'] { 
                width: 100%; 
                padding: 8px; 
                margin: 10px 0;
                border: 1px solid #ddd;
                border-radius: 4px;
            }
            input[type='checkbox'] { margin-right: 10px; }
            select { width: 100%; padding: 8px; margin: 10px 0; }
        </style>
    </head>
    <body>
        <h2>Editable PDF Form</h2>
        <form>
          First name:<br> <input type='text' name='firstname' value=''> <br>
          Last name:<br> <input type='text' name='lastname' value=''>
          <br><br>
          Email:<br> <input type='text' name='email' value=''>
          <br><br>
          Subscribe to newsletter: <input type='checkbox' name='newsletter' value='yes'>
          <br><br>
          Country: 
          <select name='country'>
              <option value='usa'>United States</option>
              <option value='uk'>United Kingdom</option>
              <option value='canada'>Canada</option>
          </select>
        </form>
    </body>
</html>";

// Create a PDF renderer with form creation enabled
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
Renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
Renderer.RenderingOptions.MarginTop = 20;
Renderer.RenderingOptions.MarginBottom = 20;

// Render the HTML as a PDF and save it
var pdfDocument = Renderer.RenderHtmlAsPdf(FormHtml);
pdfDocument.SaveAs("BasicForm.pdf");

// Step 2. Reading and Writing PDF form values.
var FormDocument = PdfDocument.FromFile("BasicForm.pdf");

// Get form field collection
var form = FormDocument.Form;

// Set and Read the value of the "firstname" field
var FirstNameField = form.FindFormField("firstname");
FirstNameField.Value = "Minnie";
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value);

// Set and Read the value of the "lastname" field
var LastNameField = form.FindFormField("lastname");
LastNameField.Value = "Mouse";
Console.WriteLine("LastNameField value: {0}", LastNameField.Value);

// Set email field
var EmailField = form.FindFormField("email");
EmailField.Value = "minnie.mouse@example.com";

// Set checkbox
var NewsletterField = form.FindFormField("newsletter");
NewsletterField.Value = "yes";

// Set dropdown selection
var CountryField = form.FindFormField("country");
CountryField.Value = "usa";

// Save the form with filled values
FormDocument.SaveAs("FilledForm.pdf");

// Step 3. Flattening the form (making it non-editable)
FormDocument.Form.Flatten();
FormDocument.SaveAs("FlattenedForm.pdf");
// PM> Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;

// Step 1. Creating a PDF with editable forms from HTML using form and input tags
var FormHtml = @"
<html>
    <head>
        <style>
            body { font-family: Arial, sans-serif; margin: 40px; }
            h2 { color: #333; }
            form { background: #f4f4f4; padding: 20px; border-radius: 8px; }
            input[type='text'] { 
                width: 100%; 
                padding: 8px; 
                margin: 10px 0;
                border: 1px solid #ddd;
                border-radius: 4px;
            }
            input[type='checkbox'] { margin-right: 10px; }
            select { width: 100%; padding: 8px; margin: 10px 0; }
        </style>
    </head>
    <body>
        <h2>Editable PDF Form</h2>
        <form>
          First name:<br> <input type='text' name='firstname' value=''> <br>
          Last name:<br> <input type='text' name='lastname' value=''>
          <br><br>
          Email:<br> <input type='text' name='email' value=''>
          <br><br>
          Subscribe to newsletter: <input type='checkbox' name='newsletter' value='yes'>
          <br><br>
          Country: 
          <select name='country'>
              <option value='usa'>United States</option>
              <option value='uk'>United Kingdom</option>
              <option value='canada'>Canada</option>
          </select>
        </form>
    </body>
</html>";

// Create a PDF renderer with form creation enabled
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
Renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
Renderer.RenderingOptions.MarginTop = 20;
Renderer.RenderingOptions.MarginBottom = 20;

// Render the HTML as a PDF and save it
var pdfDocument = Renderer.RenderHtmlAsPdf(FormHtml);
pdfDocument.SaveAs("BasicForm.pdf");

// Step 2. Reading and Writing PDF form values.
var FormDocument = PdfDocument.FromFile("BasicForm.pdf");

// Get form field collection
var form = FormDocument.Form;

// Set and Read the value of the "firstname" field
var FirstNameField = form.FindFormField("firstname");
FirstNameField.Value = "Minnie";
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value);

// Set and Read the value of the "lastname" field
var LastNameField = form.FindFormField("lastname");
LastNameField.Value = "Mouse";
Console.WriteLine("LastNameField value: {0}", LastNameField.Value);

// Set email field
var EmailField = form.FindFormField("email");
EmailField.Value = "minnie.mouse@example.com";

// Set checkbox
var NewsletterField = form.FindFormField("newsletter");
NewsletterField.Value = "yes";

// Set dropdown selection
var CountryField = form.FindFormField("country");
CountryField.Value = "usa";

// Save the form with filled values
FormDocument.SaveAs("FilledForm.pdf");

// Step 3. Flattening the form (making it non-editable)
FormDocument.Form.Flatten();
FormDocument.SaveAs("FlattenedForm.pdf");
$vbLabelText   $csharpLabel

您首先通过使用HTML格式化标签创建一个表单。 库在保存为PDF时处理复杂性。 读取和写入表单值是通过FindFormField函数完成的。 您的应用程序可以立即使用此功能以编程方式填写表单。

有关高级表单处理,包括数字签名,请参阅创建PDF表单教程

如何在PDF文件上进行数字签名

远程工作需要高效的文档处理。 填写和签署表单、发送文件和处理文档是日常业务活动。 签署PDF文档、组合文档和表单替代了纸质文档。 数字签名使公司能够在线签署协议和共享PDF表单。

使用 XFINIUM.PDF

签名字段在PDF文件中应用数字签名(PdfSignatureField 类)。 虽然签名栏出现在一页上,但数字签名对整个文档进行签署。

签署过程使用PdfDigitalSignature对象来设置签名属性。 签名是在根据PDF文件的二进制布局保存文档时生成的。

PdfDigitalSignature 为所有XFINIUM签名提供了基础:

  • PdfCmsDigitalSignature – CMS标准签名(继承自PdfDigitalSignature
  • PdfPadesDigitalSignature – PADES标准签名(继承自PdfCmsDigitalSignature
  • PdfInteractiveCmsDigitalSignature – 使用 硬件智能卡进行CMS签名 PdfInteractivePadesDigitalSignature – 支持硬件智能卡的PADES
  • PdfDocumentTimeStamp – 文档级时间戳(继承自PdfDigitalSignature

使用 IronPDF.

开发者经常询问如何使用IronPDF和C#以编程方式在PDF中添加签名。 这可能意味着:

从文件中添加图形签名图像

  • 加密签名以防止篡改
  • 添加手写签名图标与加密签名

第一种方法是将签名PNG图像加盖到现有PDF页面上。 用于签名或公司印章:

// Open an existing PDF document or create a new one
var Pdf = PdfDocument.FromFile(@"C:\Path\To\ASPX to PDF.pdf");

// Define an HTML stamp with a signature image
var SignatureStamp = new HtmlStamp()
{
    Html = "<img src='signature.png' />",
    Width = 150,
    Height = 50,
    Bottom = 300,
    Left = 85,
    ZIndex = HtmlStamp.StampLayer.OnTopOfExistingPDFContent
};

// Advanced stamp with styling
var StyledSignatureStamp = new HtmlStamp()
{
    Html = @"<div style='border: 2px solid #000; padding: 10px; background: rgba(255,255,255,0.9);'>
                <img src='signature.png' style='width: 120px;' />
                <p style='margin: 5px 0 0 0; font-size: 10px;'>Digitally Signed</p>
                <p style='margin: 0; font-size: 8px;'>{date}</p>
             </div>",
    Width = 150,
    Height = 100,
    Bottom = 50,
    Right = 50,
    ZIndex = HtmlStamp.StampLayer.OnTopOfExistingPDFContent
};

// Stamp the signature on the first page of the PDF
Pdf.StampHTML(SignatureStamp, 1);

// Or apply to all pages
Pdf.StampHTML(StyledSignatureStamp);

// Save the stamped PDF
Pdf.SaveAs(@"C:\Path\To\Stamped_PDF.pdf");
// Open an existing PDF document or create a new one
var Pdf = PdfDocument.FromFile(@"C:\Path\To\ASPX to PDF.pdf");

// Define an HTML stamp with a signature image
var SignatureStamp = new HtmlStamp()
{
    Html = "<img src='signature.png' />",
    Width = 150,
    Height = 50,
    Bottom = 300,
    Left = 85,
    ZIndex = HtmlStamp.StampLayer.OnTopOfExistingPDFContent
};

// Advanced stamp with styling
var StyledSignatureStamp = new HtmlStamp()
{
    Html = @"<div style='border: 2px solid #000; padding: 10px; background: rgba(255,255,255,0.9);'>
                <img src='signature.png' style='width: 120px;' />
                <p style='margin: 5px 0 0 0; font-size: 10px;'>Digitally Signed</p>
                <p style='margin: 0; font-size: 8px;'>{date}</p>
             </div>",
    Width = 150,
    Height = 100,
    Bottom = 50,
    Right = 50,
    ZIndex = HtmlStamp.StampLayer.OnTopOfExistingPDFContent
};

// Stamp the signature on the first page of the PDF
Pdf.StampHTML(SignatureStamp, 1);

// Or apply to all pages
Pdf.StampHTML(StyledSignatureStamp);

// Save the stamped PDF
Pdf.SaveAs(@"C:\Path\To\Stamped_PDF.pdf");
$vbLabelText   $csharpLabel

使用.pfx和.p12 X509Certificate2数字证书加密签名PDF仅需一行代码:

// 123456 below represents the signature password
new IronPdf.PdfSignature("CertificateFile.p12", "123456").SignPdfFile("ASPX to PDF.pdf");

// Or with more control
var signature = new IronPdf.PdfSignature("CertificateFile.p12", "123456")
{
    SigningContact = "john@example.com",
    SigningLocation = "New York, USA",
    SigningReason = "Contract Agreement"
};

// Load the PDF
var pdf = PdfDocument.FromFile("contract.pdf");

// Sign and save
pdf.SignPdfWithDigitalSignature(signature);
pdf.SaveAs("signed-contract.pdf");
// 123456 below represents the signature password
new IronPdf.PdfSignature("CertificateFile.p12", "123456").SignPdfFile("ASPX to PDF.pdf");

// Or with more control
var signature = new IronPdf.PdfSignature("CertificateFile.p12", "123456")
{
    SigningContact = "john@example.com",
    SigningLocation = "New York, USA",
    SigningReason = "Contract Agreement"
};

// Load the PDF
var pdf = PdfDocument.FromFile("contract.pdf");

// Sign and save
pdf.SignPdfWithDigitalSignature(signature);
pdf.SaveAs("signed-contract.pdf");
$vbLabelText   $csharpLabel

此高级示例结合了.pfx/.p12 X509Certificate2数字ID签名和手写签名:

// Create a digital signature using a certificate file
var Signature = new IronPdf.PdfSignature("Iron.pfx", "123456");

// Render a PDF document to be signed
var Renderer = new ChromePdfRenderer();
Renderer.RenderingOptions.MarginBottom = 0;
Renderer.RenderingOptions.MarginTop = 0;
Renderer.RenderingOptions.EnableJavaScript = true;
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

// Create PDF with security features
string html = @"<h1>Contract Agreement</h1>
                <p>This document is digitally signed and encrypted.</p>
                <p>Agreement Date: " + DateTime.Now.ToString("yyyy-MM-dd") + @"</p>";

PdfDocument doc = Renderer.RenderHtmlAsPdf(html);

// Configure optional signing options and a handwritten signature graphic
Signature.SigningContact = "support@ironsoftware.com";
Signature.SigningLocation = "Chicago, USA";
Signature.SigningReason = "To show how to sign a PDF";

// Load a handwritten signature image
Signature.LoadSignatureImageFromFile("handwriting.png");

// Advanced security: Set permissions
doc.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint;
doc.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.NoEdit;
doc.SecuritySettings.AllowUserCopyPasteContent = false;

// Sign the PDF document with the digital signature
doc.SignPdfWithDigitalSignature(Signature);

// Add password protection
doc.Password = "userpassword";
doc.OwnerPassword = "ownerpassword";

// Save the signed PDF document
doc.SaveAs("Signed_ASPX_to_PDF.pdf");
// Create a digital signature using a certificate file
var Signature = new IronPdf.PdfSignature("Iron.pfx", "123456");

// Render a PDF document to be signed
var Renderer = new ChromePdfRenderer();
Renderer.RenderingOptions.MarginBottom = 0;
Renderer.RenderingOptions.MarginTop = 0;
Renderer.RenderingOptions.EnableJavaScript = true;
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

// Create PDF with security features
string html = @"<h1>Contract Agreement</h1>
                <p>This document is digitally signed and encrypted.</p>
                <p>Agreement Date: " + DateTime.Now.ToString("yyyy-MM-dd") + @"</p>";

PdfDocument doc = Renderer.RenderHtmlAsPdf(html);

// Configure optional signing options and a handwritten signature graphic
Signature.SigningContact = "support@ironsoftware.com";
Signature.SigningLocation = "Chicago, USA";
Signature.SigningReason = "To show how to sign a PDF";

// Load a handwritten signature image
Signature.LoadSignatureImageFromFile("handwriting.png");

// Advanced security: Set permissions
doc.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint;
doc.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.NoEdit;
doc.SecuritySettings.AllowUserCopyPasteContent = false;

// Sign the PDF document with the digital signature
doc.SignPdfWithDigitalSignature(Signature);

// Add password protection
doc.Password = "userpassword";
doc.OwnerPassword = "ownerpassword";

// Save the signed PDF document
doc.SaveAs("Signed_ASPX_to_PDF.pdf");
$vbLabelText   $csharpLabel

要实现完整的安全措施,请查看Ironsecuredoc文档了解先进的文档保护功能。## 每个库如何处理现代CSS框架和Bootstrap?

现代网页应用程序通常依赖于像Bootstrap这样的CSS框架,以实现快速UI开发和响应式设计。 PDF生成工具必须准确保留这些框架布局,以确保文档质量专业。

IronPDF:完整的 Bootstrap 框架支持

IronPDF的Chromium渲染引擎完全支持现代CSS框架:

  • Bootstrap 5:使用所有响应式组件进行完整的flexbox和CSS网格渲染 Bootstrap 4:完整的卡片系统、导航栏和实用类
  • Tailwind CSS:所有以效用优先的类和响应式变体
  • Foundation和其他框架:完全支持CSS3意味着所有现代框架均能正常工作
  • 高级CSS:Flexbox、CSS Grid、自定义属性、动画和变换

实际验证:Bootstrap主页和模板以与浏览器一致的准确性进行转换。

代码示例: 使用 Bootstrap 卡片的事件日程

using IronPdf;

var renderer = new ChromePdfRenderer();

// Configure rendering for optimal Bootstrap output
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.RenderDelay = 500; // Allow JS to fully load
renderer.RenderingOptions.ViewPortWidth = 1280; // Desktop viewport
renderer.RenderingOptions.MarginTop = 10;
renderer.RenderingOptions.MarginBottom = 10;
renderer.RenderingOptions.MarginLeft = 10;
renderer.RenderingOptions.MarginRight = 10;

string bootstrapSchedule = @"
<!DOCTYPE html>
<html>
<head>
    <link href='___PROTECTED_URL_135___ rel='stylesheet'>
    <style>
        @media print {
            .pagebreak { page-break-after: always; }
        }
    </style>
</head>
<body>
    <div class='container my-5'>
        <h1 class='text-center mb-5'>Tech Conference 2025 - Schedule</h1>

        <div class='row g-4'>
            <div class='col-md-6'>
                <div class='card border-primary'>
                    <div class='card-header bg-primary text-white d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Keynote Session</h5>
                        <span class='badge bg-light text-primary'>9:00 AM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Main Auditorium</h6>
                        <p class='card-text'><strong>The Future of AI in Software Development</strong></p>
                        <p class='card-text'>Join us for an exploration of how artificial intelligence is transforming the software development environment.</p>
                        <div class='d-flex align-items-center'>
                            <img src='___PROTECTED_URL_136___ class='rounded-circle me-2' alt='Speaker'>
                            <div>
                                <div class='fw-bold'>Dr. Sarah Chen</div>
                                <small class='text-muted'>AI Research Lead</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class='col-md-6'>
                <div class='card border-success'>
                    <div class='card-header bg-success text-white d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Workshop</h5>
                        <span class='badge bg-light text-success'>10:30 AM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Workshop Room A</h6>
                        <p class='card-text'><strong>Hands-On: Cloud-Native Architecture</strong></p>
                        <p class='card-text'>Learn practical techniques for building flexible, cloud-native applications with modern frameworks.</p>
                        <div class='d-flex align-items-center'>
                            <img src='___PROTECTED_URL_137___ class='rounded-circle me-2' alt='Speaker'>
                            <div>
                                <div class='fw-bold'>Michael Rodriguez</div>
                                <small class='text-muted'>Cloud Architect</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class='col-md-6'>
                <div class='card border-warning'>
                    <div class='card-header bg-warning text-dark d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Panel Discussion</h5>
                        <span class='badge bg-dark'>2:00 PM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Main Auditorium</h6>
                        <p class='card-text'><strong>Security in Modern Web Applications</strong></p>
                        <p class='card-text'>Industry experts discuss current security challenges and best practices for protecting user data.</p>
                        <small class='text-muted'>Featuring 4 industry experts</small>
                    </div>
                </div>
            </div>

            <div class='col-md-6'>
                <div class='card border-info'>
                    <div class='card-header bg-info text-white d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Technical Talk</h5>
                        <span class='badge bg-light text-info'>3:30 PM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Room B</h6>
                        <p class='card-text'><strong>Performance Optimization Strategies</strong></p>
                        <p class='card-text'>Deep dive into advanced techniques for improve application performance and reducing latency.</p>
                        <div class='d-flex align-items-center'>
                            <img src='___PROTECTED_URL_138___ class='rounded-circle me-2' alt='Speaker'>
                            <div>
                                <div class='fw-bold'>Alex Kim</div>
                                <small class='text-muted'>Performance Engineer</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class='pagebreak'></div>

        <h2 class='mt-5'>Additional Sessions</h2>
        <div class='table-responsive'>
            <table class='table table-striped'>
                <thead>
                    <tr>
                        <th>Time</th>
                        <th>Session</th>
                        <th>Speaker</th>
                        <th>Location</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>11:45 AM</td>
                        <td>Lightning Talks</td>
                        <td>Various</td>
                        <td>Room C</td>
                    </tr>
                    <tr>
                        <td>1:00 PM</td>
                        <td>Networking Lunch</td>
                        <td>-</td>
                        <td>Cafeteria</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>";

// Generate the PDF
var pdf = renderer.RenderHtmlAsPdf(bootstrapSchedule);

// Add metadata
pdf.MetaData.Author = "Tech Conference Team";
pdf.MetaData.Title = "Conference Schedule 2025";
pdf.MetaData.Subject = "Event Schedule";

// Save the PDF
pdf.SaveAs("conference-schedule.pdf");

// Example: Generate responsive invoice with Bootstrap
string bootstrapInvoice = @"
<!DOCTYPE html>
<html>
<head>
    <link href='___PROTECTED_URL_139___ rel='stylesheet'>
    <link href='___PROTECTED_URL_140___ rel='stylesheet'>
</head>
<body>
    <div class='container mt-5'>
        <div class='row'>
            <div class='col-12'>
                <div class='card'>
                    <div class='card-body'>
                        <div class='row mb-4'>
                            <div class='col-sm-6'>
                                <h2 class='text-primary'><i class='fas fa-file-invoice'></i> INVOICE</h2>
                                <p class='mb-1'><strong>Invoice #:</strong> INV-2025-001</p>
                                <p class='mb-1'><strong>Date:</strong> " + DateTime.Now.ToString("MMMM dd, yyyy") + @"</p>
                            </div>
                            <div class='col-sm-6 text-sm-end'>
                                <h4>Your Company Name</h4>
                                <p class='mb-1'>123 Business St</p>
                                <p class='mb-1'>City, State 12345</p>
                                <p>contact@company.com</p>
                            </div>
                        </div>

                        <hr>

                        <div class='row mb-4'>
                            <div class='col-sm-6'>
                                <h5>Bill To:</h5>
                                <p class='mb-1'><strong>Client Company</strong></p>
                                <p class='mb-1'>456 Client Ave</p>
                                <p>City, State 67890</p>
                            </div>
                        </div>

                        <div class='table-responsive'>
                            <table class='table table-bordered'>
                                <thead class='table-primary'>
                                    <tr>
                                        <th>Description</th>
                                        <th class='text-center'>Quantity</th>
                                        <th class='text-end'>Price</th>
                                        <th class='text-end'>Total</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>Web Development Services</td>
                                        <td class='text-center'>40</td>
                                        <td class='text-end'>$150.00</td>
                                        <td class='text-end'>$6,000.00</td>
                                    </tr>
                                    <tr>
                                        <td>UI/UX Design</td>
                                        <td class='text-center'>20</td>
                                        <td class='text-end'>$125.00</td>
                                        <td class='text-end'>$2,500.00</td>
                                    </tr>
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <td colspan='3' class='text-end'><strong>Subtotal:</strong></td>
                                        <td class='text-end'><strong>$8,500.00</strong></td>
                                    </tr>
                                    <tr>
                                        <td colspan='3' class='text-end'>Tax (10%):</td>
                                        <td class='text-end'>$850.00</td>
                                    </tr>
                                    <tr class='table-primary'>
                                        <td colspan='3' class='text-end'><strong>Total Due:</strong></td>
                                        <td class='text-end'><strong>$9,350.00</strong></td>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>

                        <div class='alert alert-info mt-4'>
                            <i class='fas fa-info-circle'></i> Payment is due within 30 days. Thank you for your business!
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>";

var invoicePdf = renderer.RenderHtmlAsPdf(bootstrapInvoice);
invoicePdf.SaveAs("bootstrap-invoice.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

// Configure rendering for optimal Bootstrap output
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.RenderDelay = 500; // Allow JS to fully load
renderer.RenderingOptions.ViewPortWidth = 1280; // Desktop viewport
renderer.RenderingOptions.MarginTop = 10;
renderer.RenderingOptions.MarginBottom = 10;
renderer.RenderingOptions.MarginLeft = 10;
renderer.RenderingOptions.MarginRight = 10;

string bootstrapSchedule = @"
<!DOCTYPE html>
<html>
<head>
    <link href='___PROTECTED_URL_135___ rel='stylesheet'>
    <style>
        @media print {
            .pagebreak { page-break-after: always; }
        }
    </style>
</head>
<body>
    <div class='container my-5'>
        <h1 class='text-center mb-5'>Tech Conference 2025 - Schedule</h1>

        <div class='row g-4'>
            <div class='col-md-6'>
                <div class='card border-primary'>
                    <div class='card-header bg-primary text-white d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Keynote Session</h5>
                        <span class='badge bg-light text-primary'>9:00 AM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Main Auditorium</h6>
                        <p class='card-text'><strong>The Future of AI in Software Development</strong></p>
                        <p class='card-text'>Join us for an exploration of how artificial intelligence is transforming the software development environment.</p>
                        <div class='d-flex align-items-center'>
                            <img src='___PROTECTED_URL_136___ class='rounded-circle me-2' alt='Speaker'>
                            <div>
                                <div class='fw-bold'>Dr. Sarah Chen</div>
                                <small class='text-muted'>AI Research Lead</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class='col-md-6'>
                <div class='card border-success'>
                    <div class='card-header bg-success text-white d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Workshop</h5>
                        <span class='badge bg-light text-success'>10:30 AM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Workshop Room A</h6>
                        <p class='card-text'><strong>Hands-On: Cloud-Native Architecture</strong></p>
                        <p class='card-text'>Learn practical techniques for building flexible, cloud-native applications with modern frameworks.</p>
                        <div class='d-flex align-items-center'>
                            <img src='___PROTECTED_URL_137___ class='rounded-circle me-2' alt='Speaker'>
                            <div>
                                <div class='fw-bold'>Michael Rodriguez</div>
                                <small class='text-muted'>Cloud Architect</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class='col-md-6'>
                <div class='card border-warning'>
                    <div class='card-header bg-warning text-dark d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Panel Discussion</h5>
                        <span class='badge bg-dark'>2:00 PM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Main Auditorium</h6>
                        <p class='card-text'><strong>Security in Modern Web Applications</strong></p>
                        <p class='card-text'>Industry experts discuss current security challenges and best practices for protecting user data.</p>
                        <small class='text-muted'>Featuring 4 industry experts</small>
                    </div>
                </div>
            </div>

            <div class='col-md-6'>
                <div class='card border-info'>
                    <div class='card-header bg-info text-white d-flex justify-content-between align-items-center'>
                        <h5 class='mb-0'>Technical Talk</h5>
                        <span class='badge bg-light text-info'>3:30 PM</span>
                    </div>
                    <div class='card-body'>
                        <h6 class='card-subtitle mb-2 text-muted'>Room B</h6>
                        <p class='card-text'><strong>Performance Optimization Strategies</strong></p>
                        <p class='card-text'>Deep dive into advanced techniques for improve application performance and reducing latency.</p>
                        <div class='d-flex align-items-center'>
                            <img src='___PROTECTED_URL_138___ class='rounded-circle me-2' alt='Speaker'>
                            <div>
                                <div class='fw-bold'>Alex Kim</div>
                                <small class='text-muted'>Performance Engineer</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class='pagebreak'></div>

        <h2 class='mt-5'>Additional Sessions</h2>
        <div class='table-responsive'>
            <table class='table table-striped'>
                <thead>
                    <tr>
                        <th>Time</th>
                        <th>Session</th>
                        <th>Speaker</th>
                        <th>Location</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>11:45 AM</td>
                        <td>Lightning Talks</td>
                        <td>Various</td>
                        <td>Room C</td>
                    </tr>
                    <tr>
                        <td>1:00 PM</td>
                        <td>Networking Lunch</td>
                        <td>-</td>
                        <td>Cafeteria</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>";

// Generate the PDF
var pdf = renderer.RenderHtmlAsPdf(bootstrapSchedule);

// Add metadata
pdf.MetaData.Author = "Tech Conference Team";
pdf.MetaData.Title = "Conference Schedule 2025";
pdf.MetaData.Subject = "Event Schedule";

// Save the PDF
pdf.SaveAs("conference-schedule.pdf");

// Example: Generate responsive invoice with Bootstrap
string bootstrapInvoice = @"
<!DOCTYPE html>
<html>
<head>
    <link href='___PROTECTED_URL_139___ rel='stylesheet'>
    <link href='___PROTECTED_URL_140___ rel='stylesheet'>
</head>
<body>
    <div class='container mt-5'>
        <div class='row'>
            <div class='col-12'>
                <div class='card'>
                    <div class='card-body'>
                        <div class='row mb-4'>
                            <div class='col-sm-6'>
                                <h2 class='text-primary'><i class='fas fa-file-invoice'></i> INVOICE</h2>
                                <p class='mb-1'><strong>Invoice #:</strong> INV-2025-001</p>
                                <p class='mb-1'><strong>Date:</strong> " + DateTime.Now.ToString("MMMM dd, yyyy") + @"</p>
                            </div>
                            <div class='col-sm-6 text-sm-end'>
                                <h4>Your Company Name</h4>
                                <p class='mb-1'>123 Business St</p>
                                <p class='mb-1'>City, State 12345</p>
                                <p>contact@company.com</p>
                            </div>
                        </div>

                        <hr>

                        <div class='row mb-4'>
                            <div class='col-sm-6'>
                                <h5>Bill To:</h5>
                                <p class='mb-1'><strong>Client Company</strong></p>
                                <p class='mb-1'>456 Client Ave</p>
                                <p>City, State 67890</p>
                            </div>
                        </div>

                        <div class='table-responsive'>
                            <table class='table table-bordered'>
                                <thead class='table-primary'>
                                    <tr>
                                        <th>Description</th>
                                        <th class='text-center'>Quantity</th>
                                        <th class='text-end'>Price</th>
                                        <th class='text-end'>Total</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>Web Development Services</td>
                                        <td class='text-center'>40</td>
                                        <td class='text-end'>$150.00</td>
                                        <td class='text-end'>$6,000.00</td>
                                    </tr>
                                    <tr>
                                        <td>UI/UX Design</td>
                                        <td class='text-center'>20</td>
                                        <td class='text-end'>$125.00</td>
                                        <td class='text-end'>$2,500.00</td>
                                    </tr>
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <td colspan='3' class='text-end'><strong>Subtotal:</strong></td>
                                        <td class='text-end'><strong>$8,500.00</strong></td>
                                    </tr>
                                    <tr>
                                        <td colspan='3' class='text-end'>Tax (10%):</td>
                                        <td class='text-end'>$850.00</td>
                                    </tr>
                                    <tr class='table-primary'>
                                        <td colspan='3' class='text-end'><strong>Total Due:</strong></td>
                                        <td class='text-end'><strong>$9,350.00</strong></td>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>

                        <div class='alert alert-info mt-4'>
                            <i class='fas fa-info-circle'></i> Payment is due within 30 days. Thank you for your business!
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>";

var invoicePdf = renderer.RenderHtmlAsPdf(bootstrapInvoice);
invoicePdf.SaveAs("bootstrap-invoice.pdf");
$vbLabelText   $csharpLabel

输出:专业会议日程安排,使用Bootstrap的卡片网格、flexbox对齐、徽章组件和响应式布局——所有这些都准确地呈现在PDF中。

XFINIUM.PDF:有限的 HTML 和框架支持

XFINIUM.PDF专注于PDF生成和操作,而不是HTML到PDF的转换。 该库在 Bootstrap 和现代 CSS 框架方面存在显著限制:

无原生HTML渲染: XFINIUM.PDF不包括内置的HTML到PDF转换引擎

  • 仅限基本HTML支持:仅限于简单的HTML结构,不支持高级CSS
  • 不支持Bootstrap:不支持现代Bootstrap框架(4/5)的flexbox和CSS Grid
  • 需要解决方案: 开发者必须使用低级PDF API手动重建布局
  • 外部工具需求: 可能需要与外部HTML渲染引擎集成

开发影响:使用Bootstrap或现代CSS框架的应用程序无法直接使用XFINIUM.PDF将其UI转换为PDF。 开发人员必须:

  1. 使用 XFINIUM.PDF 的低级绘图 API 重建布局(显著开发时间)
  2. 集成外部 HTML 渲染工具(增加复杂性和依赖关系)
  3. 维护与 Web UI 平行的单独 PDF 布局代码(维护开销)

对于需要使用现代框架进行HTML到PDF转换的项目,XFINIUM.PDF的限制需要大量额外开发。

有关完整的Bootstrap和现代CSS框架支持,请参阅Bootstrap & Flexbox CSS指南。

有哪些定价和许可选项?

XFINIUM.PDF 定价和许可

每个包都有两个版本:用于PDF生成/编辑的Generator版,以及包含所有Generator功能加上PDF渲染和查看的Viewer版。

每位开发者都需要一个许可证。 免版税分发到不限数量的桌面/服务器。 援助订阅包括一年的更新/支持。

价格范围为每年$290.00到$872.00。

IronPDF 定价和许可

IronPDF在开发过程中是免费的,并可以随时获得商业用途许可。选项包括单项目许可、单个开发者、代理商、跨国组织和SaaS/OEM再分发。 所有许可证均包含30天退款保证、一年的支持/升级服务、开发/测试/生产环境的有效性以及永久许可证(一次性购买)。 Lite套餐起价为$799,没有经常性费用。

我应该选择哪个PDF库?

IronPDF库无需专用API即可简化PDF创建。"HTML-To-PDF"将HTML、JS、CSS、JPG、PNG、GIF和SVG等开放标准文档转换为像素完美的PDF。 它建立在现有的开发者技能之上。 您可以下载文档、通过电子邮件发送,或保存到云端,创建账单、报价、报告、合同和其他文件。 它适用于 ASP.NET、ASP.NET Core、webforms、MVC、.NET Framework 和 .NET Core Web API。

XFINIUM.PDF为初学者和高级PDF开发人员提供功能。 无论您是需要创建报告、填写PDF表单、构建作品集、编辑信息,还是将PDF转换为多页TIFF,它都提供了必要的工具。 基本的对象模型遵循PDF规范。 代码在所有平台上均可无修改编译。

XFINIUM.PDF许可证起价为$290(生成器版)和$387(查看器版)。 IronPDF 起价 $799。 IronPDF提供单用户和多用户许可证,而XFINIUM.PDF需要按开发者获取许可证。 IronPDF的Professional License($799)支持无限用户。

IronPDF在PDF操作上所需的代码行数比XFINIUM.PDF少,从而减少程序员的工作负担。

Iron Software通过两次点击即可提供其完整的套件。 以两个库的价格,您目前可以获得所有五个库,并享受持续支持。

请注意XFINIUM.PDF 是其各自所有者的注册商标。 本网站与 XFINIUM.PDF 无关,不背书或支持。 所有产品名称、徽标和品牌均为各自所有者的财产。 比较仅供参考,反映撰写时公开可用的信息。)}]

常见问题解答

IronPDF进行HTML到PDF转换的关键功能是什么?

IronPDF利用.NET Chromium引擎将HTML转换为PDF。它支持HTML5、CSS、JavaScript和图像集成,使其成为从网页内容创建PDF的综合解决方案。

XFINIUM.PDF与其他.NET PDF库相比如何?

XFINIUM.PDF是一个提供两种版本的跨平台库:生成器和查看器。它在PDF创建、编辑、渲染方面表现出色,并包括安全性、数字签名和条形码支持等功能。

IronPDF可以用于像Azure和AWS这样的云平台吗?

可以,IronPDF兼容各种平台,包括Azure和AWS,允许在云环境中灵活部署PDF解决方案。

在.NET项目中,有哪些IronPDF安装选项?

IronPDF可以通过Visual Studio的NuGet包管理器、开发者命令提示符安装,或直接下载NuGet包或库DLL。

IronPDF的PDF编辑功能有哪些?

IronPDF允许广泛的PDF编辑,包括填写表单字段、合并文档以及提取文本和图像。它还支持添加页眉、页脚和注释。

IronPDF和XFINIUM.PDF的许可选项有何不同?

XFINIUM.PDF提供每位开发人员$290起的许可证,支持免费发行。IronPDF提供更宽泛的许可选项,包括针对无限用户的专业许可证。

XFINIUM.PDF提供什么安全功能?

XFINIUM.PDF支持如用户和拥有者密码、文档访问权限、RC4和AES加密、内容隐藏等安全功能,以确保文档安全。

开发人员为何可能选择IronPDF用于他们的项目?

开发人员可能会选择IronPDF因为其简化的PDF操作,仅需较少的代码行,并且在单用户和多用户许可证方面灵活多变。

IronPDF如何处理PDF中的表单填写?

IronPDF提供工具用于填写PDF内的表单字段,允许动态创建文档和用户互动。

这些PDF库有哪些数字签名功能?

IronPDF和XFINIUM.PDF均支持数字签名,使得文档真实性和完整性得到安全验证。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me