IRONSOFTWAREHOME
数字签名
from ironpdf import *

# Cryptographically sign an existing PDF in 1 line of code!
PdfSignature(r".\certificates\IronSoftware.p12", "123456").SignPdfFile("any.pdf")

##### Advanced example for more control #####

# Step 1. Create a PDF
renderer = ChromePdfRenderer()
doc = renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>")

# Step 2. Create a Signature.
# You may create a .pfx or .p12 PDF signing certificate using Adobe Acrobat Reader.
# Read: https://helpx.adobe.com/acrobat/using/digital-ids.html
signature = PdfSignature(r"certificates\IronSoftware.pfx", "123456")

# Step 3. 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"

# Step 4. Sign the PDF with the PdfSignature. Multiple signing certificates may be used
doc.Sign(signature)

# Step 5. The PDF is not signed until saved to file, steam or byte array.
doc.SaveAs("signed.pdf")
pip install ironpdf
数字签名

数字签名

此Python代码演示如何使用PDF库,如PyPDF2,对现有PDF进行密码签名并创建带有数字签名的PDF。

如何在Python中生成数字签名

  1. 下载Python模块以生成数字签名。 您可以使用诸如reportlab来进行数字签名。

  2. 渲染一个新的PDF文档。 使用reportlab来创建新的PDF或修改现有的PDF。

  3. 实例化PdfSignature类并导入数字证书。 下面的代码片段展示了如何使用一个假想的PdfSignature类来实现此功能。 用您选择的库的实际方法替换以添加签名。

  4. 根据需要添加附加信息。 指定元数据、外观或签名的位置。

  5. 使用sign方法签署该文档。 下面是一个使用PyPDF2附加数字签名的Python代码。

注意:使用PyPDF2对PDF进行数字签名是一个复杂过程,可能会涉及到不同的库,具体取决于需求。 在实现时,请确保您拥有必要的证书和密码学原理的理解。

在 GitHub 上查看数字签名 PDF 示例
在 GitHub 上查看

准备开始了吗?

版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥。

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

OR
bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥。
无需信用卡或创建账户
Python 模块下载 PDF
using pip 安装

版本: 2026.9

  1. 下载 并安装 Python 3.7+。
  2. 如果尚未安装,请从 pypi.org 安装 pip。
  3. 在终端中执行上述命令。
Python PDF 模块
下载 模块

版本: 2026.9

手动安装到您的项目中

  1. 下载软件包
  2. 在终端中运行此命令
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

$999 起