在生產環境中測試,無水印。
在任何需要的地方都能運行。
獲得 30 天的全功能產品。
在幾分鐘內上手運行。
試用產品期間完全訪問我們的支援工程團隊
x509certificate2 可用於獲取現有證書的重要資訊(有效日期、發行者等)。 IronPDF 允許您使用 C# 來數位簽署 PDF。 您可以建立新文件或簽署現有的 PDF 文件。只需一行代碼,如下簡單步驟所示。
PdfSignature
類別SignPdfFile
方法來開啟和簽署現有的PDF首先,將 IronPDF 安裝到您的 Visual Studio 專案中。 無論哪種方式對您來說更簡單,您都可以從DLL 下載或在NuGet 網站上獲取。 在 Visual Studio 中存取 C# 函式庫,然後我們來新增一個簽章。
Install-Package IronPdf
數位簽名就像電子駕駛執照或護照,用於證明您的身份。 數位身分識別通常包含您的姓名和電子郵件地址、發行該身分識別的組織名稱、序列號以及到期日期。 數位 ID 用於憑證安全和數位簽名。 這需要使用 Adobe Acrobat 來創建才能正常運作。
現在,讓我們看看使用C#創建x509certificate2
以數位簽署PDF的步驟。
今天,IronPDF 庫提供了一種簡單的方法來應用簽名,只需一行程式碼即可節省時間和精力。 您可以在開發過程中免費使用它來測試您的作品。 然後,決定你的專案。 您是要創建新文件還是簽署現有 PDF?
在下面的代碼範例中,使用 C# 表單允許用戶選擇他們想要的 PDF,該 PDF 可以通過單擊一次來接收數位簽名。
應準備一個.pfx 檔案
(個人資訊交換格式),用於在私鑰的幫助下傳輸證書。
SignPdfFile(FileName)
方法來自 PdfSignature
類別,是數位簽名的主要方法。 只需選擇所需的文件。
/**
Digitally Sign a PDF
anchor-digitally-sign-a-pdf
**/
using System.Drawing;
using System.Windows.Forms;
using IronPdf;
namespace DigitalSign
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
//select the desired PDF file
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
//The PDFSignature method to digitally sign the Existing PDF
new PdfSignature("Ironpdf.pfx", "123456").SignPdfFile(textBox1.Text);
//Used as confirmation
label3.Text = "Completed !";
label3.BackColor = Color.LightGreen;
label3.ForeColor = Color.Black;
}
}
}
/**
Digitally Sign a PDF
anchor-digitally-sign-a-pdf
**/
using System.Drawing;
using System.Windows.Forms;
using IronPdf;
namespace DigitalSign
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
//select the desired PDF file
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
//The PDFSignature method to digitally sign the Existing PDF
new PdfSignature("Ironpdf.pfx", "123456").SignPdfFile(textBox1.Text);
//Used as confirmation
label3.Text = "Completed !";
label3.BackColor = Color.LightGreen;
label3.ForeColor = Color.Black;
}
}
}
'''
'''Digitally Sign a PDF
'''anchor-digitally-sign-a-pdf
'''*
Imports System.Drawing
Imports System.Windows.Forms
Imports IronPdf
Namespace DigitalSign
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'select the desired PDF file
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
textBox1.Text = openFileDialog1.FileName
End If
End Sub
Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'The PDFSignature method to digitally sign the Existing PDF
Call (New PdfSignature("Ironpdf.pfx", "123456")).SignPdfFile(textBox1.Text)
'Used as confirmation
label3.Text = "Completed !"
label3.BackColor = Color.LightGreen
label3.ForeColor = Color.Black
End Sub
End Class
End Namespace
如以下輸出所示,只要選擇了一個PDF文件並點擊匯入簽名按鈕,該文件就會成功地進行數位簽章。 使用 IronPDF,只需一行代碼。
IronPDF 是使用 C# 處理 PDF 相關任務的理想工具。 IronPDF 提供開發人員將PDF 文件渲染為圖像以及從 PDF 中提取文本和內容的方法。 此外,IronPDF 還能在 PDF 中呈現圖表,使用 IronBarcode 函式庫添加條碼,通過密碼增強安全性和添加水印,甚至還能以程式化方式處理 PDF 表單。