IRONSOFTWAREHOME
密码、安全性和元数据
from ironpdf import *

# Open an Encrypted File, alternatively create a new PDF from Html
pdf = PdfDocument.FromFile("encrypted.pdf", "password")

# Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = Now()

# The following code makes a PDF read only and will disallow copy & paste and printing
pdf.SecuritySettings.RemovePasswordsAndEncryption()
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserFormData = False
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights

# Change or set the document encryption password
pdf.SecuritySettings.OwnerPassword = "top-secret"  # password to edit the pdf
pdf.SecuritySettings.UserPassword = "sharable"  # password to open the pdf
pdf.SaveAs("secured.pdf")
pip install ironpdf
密码、安全性和元数据

密码、安全性和元数据

IronPDF for Python提供对PDF文档安全性和元数据的全面控制——包括作者信息、关键词、密码和用户权限限制。

开始

加载一个SecuritySettings对象上的属性,然后保存。 元数据和安全设置一起应用于单次保存操作。

元数据属性

  • MetaData.Author: 设置在PDF属性中可见的文档作者姓名。
  • MetaData.Keywords: 设置与文档相关的有利于SEO的关键字。
  • MetaData.ModifiedDate: 记录文档最后修改的时间。 Now()插入当前时间戳。

安全设置

  • SecuritySettings.RemovePasswordsAndEncryption(): 在应用新设置之前清除文档中的任何现有密码和加密。
  • SecuritySettings.MakePdfDocumentReadOnly(key): 限制文档的编辑。 key是一个内部签名密钥,不是面向用户的密码。
  • SecuritySettings.AllowUserAnnotations: 当False时,用户无法在PDF查看器中添加注释。
  • SecuritySettings.AllowUserCopyPasteContent: 当False时,阻止从PDF中复制文本。
  • SecuritySettings.AllowUserFormData: 当False时,表单字段不能由用户填写。
  • SecuritySettings.AllowUserPrinting: 控制打印权限。 PdfPrintSecurity.FullPrintRights允许打印; 使用其他值来限制它。
  • SecuritySettings.OwnerPassword: 需要密码才能在PDF查看器中编辑或更改安全设置。
  • SecuritySettings.UserPassword: 需要密码才能打开和阅读PDF。
学习使用IronPDF for Python 保护PDF文档!

准备开始了吗?

版本:2026.9刚刚发布

Key in blue circle

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

Your trial license will be sent to your email address

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

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

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

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