如何使用IronPDF在C#中签署PDF文件 | IronPDF教程

使用 C# 对 PDF 进行数字签名的开发人员指南

This article was translated from English: Does it need improvement?
Translated
View the article in English

本综合指南向 C# 开发人员展示了如何使用 IronPDF 对 PDF 进行数字签名,内容包括基于证书的签名、可视化图章和交互式表单字段,以确保文档的真实性和安全性。

在许多应用程序中,向 PDF 文档添加签名是一个常见的需求,但"签名"可能意味着不同的事情。 对于某些人来说,这涉及使用安全证书应用防篡改的数字签名。 对其他人来说,这可能是在文件上加盖可视的手写签名图像,或添加一个交互式表单字段供用户以电子方式签名。

本指南为 C# 开发人员提供了一个全面的操作指南,教您如何使用 IronPDF for .NET 库 完成所有这些任务。 我们将介绍从应用安全 X509Certificate2 数字签名到加盖图形签名和创建交互式签名字段的所有方面,确保您的 PDF 文档是可信、安全和专业的。

副标题:2(快速入门:利用 IronPDF 轻松数字签署 PDF)

通过简单、直接的过程,快速开始使用 IronPDF 来数字签署您的 PDF 文档。 此示例演示如何使用 .pfx 证书验证和签署 PDF 文件,确保文档的完整性和真实性。 请按照以下步骤将数字签名无缝集成到您的应用程序中。

Nuget Icon立即开始使用 NuGet 创建 PDF 文件:

  1. 使用 NuGet 包管理器安装 IronPDF

    PM > Install-Package IronPdf

  2. 复制并运行这段代码。

    new IronPdf.Signing.PdfSignature("certificate.pfx", "password").SignPdfFile("input.pdf");
  3. 部署到您的生产环境中进行测试

    立即开始在您的项目中使用 IronPDF,免费试用!
    arrow pointer

如何使用证书对 PDF 应用数字签名?

您可以使用数字证书文件(例如 .pfx.p12)对 PDF 文档应用数字签名,以保证文档的真实性和完整性。 此过程确保自签署以来文档未被更改。 如需全面了解数字签名功能,请浏览我们的综合数字签名指南

IronPDF 为此目的提供了一个直接的 API,支持多种应用数字签名的方法。 此功能的核心围绕 PdfSignature 类,封装了证书和签名的所有相关元数据。

签署方法说明
<代码>签名使用您创建和配置的 PdfSignature 对象签署 PDF。
<代码>SignWithFile使用位于磁盘上的数字签名证书文件(.pfx.p12)签署 PDF。
<代码>SignWithStore使用来自计算机证书存储的数字签名签署 PDF,该数字签名由 thumbprint ID 标识。

使用 X509Certificate2 对象

为了最大限度地控制,您可以从您的证书文件创建一个 X509Certificate2 对象。IronPDF 完全符合 X509Certificate2 标准,提供了一种强大且安全的数字签名实现方法。 创建证书对象时,请确保将 X509KeyStorageFlags 设置为 Exportable ,因为底层加密 API 要求这样做。在我们的代码库中查看实用的数字签名示例

Install-Package IronPdf
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Create a new PDF from an HTML string for demonstration.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>");

// Load the certificate from a .pfx file with its password.
// The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
var cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);

// Create a PdfSignature object using the loaded certificate.
var signature = new PdfSignature(cert);

// Apply the signature to the PDF document.
pdf.Sign(signature);

// Save the securely signed PDF document.
pdf.SaveAs("Signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Create a new PDF from an HTML string for demonstration.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>");

// Load the certificate from a .pfx file with its password.
// The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
var cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);

// Create a PdfSignature object using the loaded certificate.
var signature = new PdfSignature(cert);

// Apply the signature to the PDF document.
pdf.Sign(signature);

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

上述代码首先生成一个简单的 PDF。 然后它将 .pfx 证书文件加载到 X509Certificate2 对象中。 代表数字身份的该对象传递给 PdfSignature 构造函数。 最后,pdf.Sign 方法在保存文档之前应用此签名。 For more information on the X509Certificate2 class, you can refer to the official Microsoft documentation.

在数字签名中添加细节

一个数字签名可以包含的不仅仅是证书; 您可以嵌入丰富的元数据以提供签名的上下文。 这包括签名位置、原因、联系信息和来自可信机构的安全时间戳。 您还可以设置和编辑元数据,以获得更多文档属性。

添加这些细节可以改进文档的审核轨迹,并为验证者提供有价值的信息。 IronPDF 还支持使用现代 SHA256SHA512 哈希算法的时间戳服务器。

using IronPdf;
using IronPdf.Signing;
using IronSoftware.Drawing;
using System;

// Load an existing PDF document to be signed.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create a PdfSignature object directly from the certificate file and password.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Add detailed metadata to the signature for a comprehensive audit trail.
// These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now;
signature.SigningContact = "legal@ironsoftware.com";
signature.SigningLocation = "Chicago, USA";
signature.SigningReason = "Contractual Agreement";

// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = new Uri("[http://timestamp.digicert.com](http://timestamp.digicert.com)");
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256;

// Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, new Rectangle(350, 750, 200, 100));

// Sign the PDF document with the configured signature object.
pdf.Sign(signature);

// Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf");
using IronPdf;
using IronPdf.Signing;
using IronSoftware.Drawing;
using System;

// Load an existing PDF document to be signed.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create a PdfSignature object directly from the certificate file and password.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Add detailed metadata to the signature for a comprehensive audit trail.
// These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now;
signature.SigningContact = "legal@ironsoftware.com";
signature.SigningLocation = "Chicago, USA";
signature.SigningReason = "Contractual Agreement";

// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = new Uri("[http://timestamp.digicert.com](http://timestamp.digicert.com)");
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256;

// Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, new Rectangle(350, 750, 200, 100));

// Sign the PDF document with the configured signature object.
pdf.Sign(signature);

// Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf");
$vbLabelText   $csharpLabel

如果签名证书不在系统的可信存储中,某些 PDF 查看器中可能会看到警告图标。 要获得绿色勾号,证书必须添加到查看器的可信身份中。

如何为数字签名添加视觉表示?

尽管数字签名是加密嵌入 PDF 中的,但通常在页面上有一个视觉表示是有用的。 这可以是公司徽标、手写签名图像或其他图形。 IronPDF 使添加图像到 PdfSignature 对象中变得简单。

您可以从文件或流中加载图像,并将其精确定位在 PDF 的任何页面上。 支持的图像格式包括 PNG、JPEG、GIF、BMP、TIFF 和 WebP。这种技术类似于在 PDF 文档上给文本和图像盖章。

using IronPdf.Signing;
using IronSoftware.Drawing;

// This example demonstrates various ways to add a visual image to a PDF signature.

// Create a PdfSignature object.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Define the position and size for the signature image on the first page (index 0).
// Rectangle parameters: x position, y position, width, height
var signatureRectangle = new Rectangle(350, 750, 200, 100);

// Option 1: Set the SignatureImage property directly.
// This is the most straightforward approach
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle);

// Option 2: Use the LoadSignatureImageFromFile method.
// This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle);

// Option 3: Load an image from a stream. This is useful for images generated in memory.
// Perfect for scenarios where images are retrieved from databases or web services
AnyBitmap image = AnyBitmap.FromFile("assets/visual-signature.png");
using (var imageStream = image.ToStream())
{
    signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle);
}

// After configuring the signature image, apply it to a PDF.
var pdf = PdfDocument.FromFile("invoice.pdf");
pdf.Sign(signature);
pdf.SaveAs("VisualSignature.pdf");
using IronPdf.Signing;
using IronSoftware.Drawing;

// This example demonstrates various ways to add a visual image to a PDF signature.

// Create a PdfSignature object.
var signature = new PdfSignature("IronSoftware.pfx", "123456");

// Define the position and size for the signature image on the first page (index 0).
// Rectangle parameters: x position, y position, width, height
var signatureRectangle = new Rectangle(350, 750, 200, 100);

// Option 1: Set the SignatureImage property directly.
// This is the most straightforward approach
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle);

// Option 2: Use the LoadSignatureImageFromFile method.
// This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle);

// Option 3: Load an image from a stream. This is useful for images generated in memory.
// Perfect for scenarios where images are retrieved from databases or web services
AnyBitmap image = AnyBitmap.FromFile("assets/visual-signature.png");
using (var imageStream = image.ToStream())
{
    signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle);
}

// After configuring the signature image, apply it to a PDF.
var pdf = PdfDocument.FromFile("invoice.pdf");
pdf.Sign(signature);
pdf.SaveAs("VisualSignature.pdf");
$vbLabelText   $csharpLabel

此代码展示了三种等效的方法来为数字签名添加视觉组件。 无论您是有一个磁盘上的图像还是在内存中的图像,都可以轻松地作为签名过程的一部分将它加盖到 PDF 上。 这弥合了不可见的加密安全性和可见的文档批准之间的差距。

签署后如何控制文档权限?

当您签署文档时,您可能想要指定在签署后可允许的更改。 例如,您可能希望完全锁定文档,或仅允许用户填写表单字段。 IronPDF 允许您使用 SignaturePermissions 枚举来设置这些权限。 有关更高级的权限控制,请参阅我们的设置 PDF 密码和权限指南。

设置签名权限是管理文档生命周期的关键部分。 它确保在应用签名后根据您的规则维护文档的完整性。 如果用户执行了不允许的操作,签名将失效。

<代码>签名权限成员定义
<代码>不允许更改不得进行任何形式的修改。该文件已被锁定。
<代码>允许填写表格只允许填写现有表单字段和签名。
<代码>允许注释和表格填写允许填写表格、签名、创建或修改注释。

Saving and Signing a Specific PDF Revision

PDFs can store a history of changes, much like a version control system. This is known as incremental saving. When you sign a PDF, the signature applies to a specific revision of the document. This is crucial for workflows where a document goes through multiple stages of approval. Learn more about managing PDF revision history in our detailed guide.

In the following example, we load a PDF, make edits, and then sign the current revision while allowing only form-filling as a future change. We use SaveAsRevision to commit the current state to the document's history before saving the file.

using IronPdf.Signing;

// Load a PDF file with change tracking enabled.
// This enables incremental save functionality for revision management
var pdf = PdfDocument.FromFile("annual_census.pdf", ChangeTrackingModes.EnableChangeTracking);

// Placeholder for edits: You might add text, fill forms, or add annotations here.
// For example: pdf.Annotations.Add(new TextAnnotation(...));
// Or: pdf.Form["fieldName"].Value = "New Value";

// Sign the current state of the document using SignWithFile for convenience.
// We set permissions to allow further signatures and form filling.
pdf.SignWithFile(
    "assets/IronSignature.p12", 
    "password", 
    SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed);

// Save the current state as a distinct revision within the PDF's history.
// This creates a snapshot that can be referenced later
PdfDocument pdfWithRevision = pdf.SaveAsRevision();

// Save the final PDF with its full revision history to a new file.
pdfWithRevision.SaveAs("annual_census_signed.pdf");
using IronPdf.Signing;

// Load a PDF file with change tracking enabled.
// This enables incremental save functionality for revision management
var pdf = PdfDocument.FromFile("annual_census.pdf", ChangeTrackingModes.EnableChangeTracking);

// Placeholder for edits: You might add text, fill forms, or add annotations here.
// For example: pdf.Annotations.Add(new TextAnnotation(...));
// Or: pdf.Form["fieldName"].Value = "New Value";

// Sign the current state of the document using SignWithFile for convenience.
// We set permissions to allow further signatures and form filling.
pdf.SignWithFile(
    "assets/IronSignature.p12", 
    "password", 
    SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed);

// Save the current state as a distinct revision within the PDF's history.
// This creates a snapshot that can be referenced later
PdfDocument pdfWithRevision = pdf.SaveAsRevision();

// Save the final PDF with its full revision history to a new file.
pdfWithRevision.SaveAs("annual_census_signed.pdf");
$vbLabelText   $csharpLabel

Understanding incremental saves is key to advanced PDF workflows. While a simple viewer might only show the latest version, a tool like Adobe Acrobat can reveal the entire revision history, showing who signed which version and what changes were made between signatures. IronPDF gives you full programmatic control over this process.

For businesses managing complex document workflows that require high security and compliance, a comprehensive solution may be needed. Iron Software offers Iron Suite, which includes IronPDF for signing and manipulation, plus other libraries for a wide range of document processing tasks, available for a single one-time payment.

How Can I Manage and Verify Signatures Across Revisions?

A PDF document can have multiple signatures applied across its various revisions. IronPDF provides tools to manage this history effectively.

  • Roll Back to a Previous Revision: You can revert a document to an earlier state using the GetRevision method. This will discard all changes and signatures made after that revision.
  • Verify All Signatures: The VerifySignatures method checks the validity of all signatures across all revisions of the document. It returns true only if every signature is valid and no unauthorized changes have been made.
  • Remove Signatures: The RemoveSignatures method will strip all digital signatures from every revision of the document, creating a clean, unsigned version.
// Load a PDF with a complex signature history.
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");

// Verify all signatures across all revisions.
// This ensures document integrity throughout its entire history
bool allSignaturesValid = pdf.VerifySignatures();
Console.WriteLine($"All signatures are valid: {allSignaturesValid}");

// Roll back to the first revision (index 0).
// Useful for reviewing the original document state
if (pdf.RevisionCount &gt; 1)
{
    PdfDocument firstRevision = pdf.GetRevision(0);
    firstRevision.SaveAs("report_first_revision.pdf");
}

// Create a completely unsigned version of the document.
// This removes all digital signatures while preserving content
pdf.RemoveSignatures();
pdf.SaveAs("report_unsigned.pdf");
// Load a PDF with a complex signature history.
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");

// Verify all signatures across all revisions.
// This ensures document integrity throughout its entire history
bool allSignaturesValid = pdf.VerifySignatures();
Console.WriteLine($"All signatures are valid: {allSignaturesValid}");

// Roll back to the first revision (index 0).
// Useful for reviewing the original document state
if (pdf.RevisionCount &gt; 1)
{
    PdfDocument firstRevision = pdf.GetRevision(0);
    firstRevision.SaveAs("report_first_revision.pdf");
}

// Create a completely unsigned version of the document.
// This removes all digital signatures while preserving content
pdf.RemoveSignatures();
pdf.SaveAs("report_unsigned.pdf");
$vbLabelText   $csharpLabel

How Do I Stamp a Handwritten Signature onto a PDF?

Sometimes, you don't need the cryptographic security of a digital signature but simply want to apply a visual, electronic signature, like a scanned handwritten signature. This is often referred to as stamping. IronPDF can do this using its Watermark or Stamp features. For more advanced watermarking options, explore our custom watermarks guide.

Let's start with a sample invoice PDF and a .png image of a handwritten signature.

The original invoice PDF before stamping a signature.

Here is the signature image we will apply:

Handwritten signature sample showing 'IRON' in black ink for PDF stamping tutorial A sample handwritten signature image.

The following code uses the Watermark property to stamp this image onto the bottom-right corner of the PDF.

using IronPdf.Editing;

// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create an HtmlStamp containing our signature image.
// HtmlStamp allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamp("&lt;img src='assets/signature.png'/&gt;")
{
    // Configure the stamp's position and appearance.
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Right,
    Margin = 10,  // Add some space from the edge.
    Opacity = 90  // Make it slightly transparent for a more authentic look.
};

// Apply the stamp to all pages of the PDF.
// You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp);

// Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf");
using IronPdf.Editing;

// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");

// Create an HtmlStamp containing our signature image.
// HtmlStamp allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamp("&lt;img src='assets/signature.png'/&gt;")
{
    // Configure the stamp's position and appearance.
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Right,
    Margin = 10,  // Add some space from the edge.
    Opacity = 90  // Make it slightly transparent for a more authentic look.
};

// Apply the stamp to all pages of the PDF.
// You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp);

// Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf");
$vbLabelText   $csharpLabel

What Does the Stamped PDF Result Look Like?

After running the code, the signature image is stamped onto the document, creating a visually signed invoice.

The final PDF with the handwritten signature image stamped in the bottom-right corner.

How Can I Add an Interactive Signature Field to a PDF?

For documents that need to be signed by an end-user in a PDF viewer like Adobe Acrobat, you can add an interactive signature form field. This creates an empty, clickable area that prompts the user to apply their own digital signature. For a complete guide on PDF forms, see our creating PDF forms tutorial.

You can create a SignatureFormField and add it to the PDF's form collection. You have precise control over its location and size on the page. This is particularly useful for documents that require multiple signatures or when you need to collect signatures from external parties.

using IronPdf.Forms;
using IronSoftware.Drawing;

// Create a new PDF to add the signature field to.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>请在下面签名</h1>");

// Define the properties for the signature form field.
string fieldName = "ClientSignature";  // Unique identifier for the field
int pageIndex = 0;  // Add to the first page (zero-indexed)
var fieldRect = new Rectangle(50, 200, 300, 100);  // Position: (x, y), Size: (width, height)

// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, fieldRect);

// Add the signature field to the PDF's form.
pdf.Form.Add(signatureField);

// Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf");
using IronPdf.Forms;
using IronSoftware.Drawing;

// Create a new PDF to add the signature field to.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>请在下面签名</h1>");

// Define the properties for the signature form field.
string fieldName = "ClientSignature";  // Unique identifier for the field
int pageIndex = 0;  // Add to the first page (zero-indexed)
var fieldRect = new Rectangle(50, 200, 300, 100);  // Position: (x, y), Size: (width, height)

// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, fieldRect);

// Add the signature field to the PDF's form.
pdf.Form.Add(signatureField);

// Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf");
$vbLabelText   $csharpLabel

When a user opens this PDF, they will see a clickable field, allowing them to complete the signing process using their own digital ID. You can learn more about creating and managing interactive forms in our How-To guide on creating PDF forms.

PDF editor showing unsigned signature field with 'Click to sign' prompt in document titled 'testing' An unsigned, interactive signature field added programmatically to a PDF document.

How Do I Retrieve the Signer Name from Verified Signatures?

To obtain the common name of the certificate owner who signed a signature, we can use the VerifiedSignature class to access the SignerName property. Below is a code snippet demonstrating how to accomplish this.

:path=/static-assets/pdf/content-code-examples/how-to/signing-find-signer-name.cs
using IronPdf;
using System;

// Import the Signed PDF report
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");

// Using GetVerifiedSignatures() obtain a list of `VerifiedSignature` objects from the PDF
pdf.GetVerifiedSignatures().ForEach(signature =>
{
    // Print out the SignerName of each `VerifiedSignature` object
    Console.WriteLine($"SignatureName: {signature.SignerName}");
});
$vbLabelText   $csharpLabel

导入签名的 PDF 文件后,我们使用 GetVerifiedSignatures 方法检索报告中的 VerifiedSignature 对象列表,并打印每个签名的 SignerName

请注意,该值是从证书的主体区分名称(SubjectDN)中提取的,如果 CN 字段不存在,则返回值为空。

使用 IronPDF 进行 PDF 签名的下一步是什么?

本指南展示了 IronPDF 强大而灵活的 PDF 签名功能。无论您是需要应用带有详细元数据的安全数字签名、管理文档修订、加盖可视化签名,还是创建交互式表单,IronPDF 都能提供一个全面且对开发人员友好的 API 来完成工作。

要继续探索,您可以下载 IronPDF library for .NET 并获得 免费试用许可证,以便在您的项目中测试其所有功能。有关更多高级文档操作技术,包括添加注释和使用表单字段,请查看我们丰富的文档和教程。

准备好了解您还能做些什么了吗?点击此处查看我们的教程页面:签署和保护 PDF

常见问题解答

如何使用 C# 中的证书对 PDF 进行数字签名?

有了 IronPDF,只需一行代码,您就可以使用 PdfSignature 类对 PDF 进行数字签名。只需用证书文件(.pfx 或 .p12)和密码创建一个新的 PdfSignature 对象,然后调用 SignPdfFile() 方法即可。例如:new IronPDF.Signing.PdfSignature("certificate.pfx", "password").SignPdfFile("input.pdf").这将使用你的 X509Certificate2 应用防篡改数字签名,以确保文档的真实性。

支持哪些类型的 PDF 签名?

IronPDF 支持三种主要的 PDF 签名类型:1)使用 X509Certificate2 证书进行身份验证和防篡改的数字签名;2)在文档中添加图形或手写签名图像的可视签名图章;3)允许用户对 PDF 进行电子签名的交互式签名表单字段。每种类型都能满足不同的文档安全和工作流程要求。

哪些证书格式可用于数字签名?

IronPdf 支持常见的数字证书格式,包括 .pfx(个人信息交换)和 .p12 文件。这些证书文件包含数字签名所需的公钥和私钥。IronPdf 中的 PdfSignature 类可以与任何 X509Certificate2 对象一起工作,从而为您加载和管理签名证书提供了灵活性。

我可以在数字签名中添加可视化表示吗?

是的,IronPDF 允许您在数字签名中添加可视化元素。您可以在加密签名旁添加图形表示,如手写签名图像、公司徽标或自定义印章。这将数字证书的安全性与可视化确认相结合,使签名文档既安全又具有专业性。

如何创建交互式签名字段供用户进行电子签名?

IronPDF 可让您在 PDF 文档中添加交互式签名表单字段。这些字段允许用户通过点击和绘制签名或上传签名图像来签署电子文档。该功能非常适合创建需要收集签名的文档,如需要多方签名的合同或表格。

签署 PDF 是否能确保文档的完整性?

是的,当您使用 IronPDF 使用 X509Certificate2 对 PDF 进行数字签名时,就会创建一个防篡改印章,确保文档的完整性。数字签名可保证文档在签署后未被篡改。签署后对 PDF 的任何修改都会导致签名无效,从而提醒接收者文档可能已被篡改。

Jacob Mellor,Team Iron 的首席技术官
首席技术官

Jacob Mellor 是 Iron Software 的首席技术官,是 C# PDF 技术的先锋工程师。作为 Iron Software 核心代码库的原始开发者,自公司成立以来,他就塑造了公司的产品架构,并与首席执行官 Cameron Rimington 一起将其转变成一家公司,拥有50多人,服务于 NASA、特斯拉和全球政府机构。

Jacob 拥有曼彻斯特大学 (1998-2001) 的一级荣誉土木工程学士学位。1999 年在伦敦创办了自己的第一家软件公司,并于 2005 年创建了他的第一个 .NET 组件后,他专注于解决微软生态系统中的复杂问题。

他的旗舰 IronPDF 和 Iron Suite .NET 库在全球已获得超过 3000 万次的 NuGet 安装,其基础代码继续为全球使用的开发者工具提供支持。拥有 25 年商业经验和 41 年编程经验的 Jacob 仍专注于推动企业级 C#、Java 和 Python PDF 技术的创新,同时指导下一代技术领导者。

审核者
Jeff Fritz
Jeffrey T. Fritz
首席项目经理 - .NET 社区团队
Jeff 也是 .NET 和 Visual Studio 团队的首席项目经理。他是 .NET Conf 虚拟会议系列的执行制片人,并主持“Fritz and Friends”直播节目,每周两次与观众一起谈论技术并编写代码。Jeff 撰写研讨会、演示文稿并计划包括 Microsoft Build、Microsoft Ignite、.NET Conf 和 Microsoft MVP 峰会在内的最大型微软开发者活动的内容。
准备开始了吗?
Nuget 下载 17,012,929 | 版本: 2025.12 刚刚发布