IRONSOFTWAREHOME
密码、安全性和元数据

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.security.PdfPrintSecurity;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Date;

// Open an encrypted file (or create a new one from HTML)
PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/encrypted.pdf"), "password");

// Edit file metadata
MetadataManager metadata = pdf.getMetadata();
metadata.setAuthor("Satoshi Nakamoto");
metadata.setKeywords("SEO, Friendly");
metadata.setModifiedDate(new Date().toString());

// Edit file security settings
// The code below makes the PDF read only and disallows users to copy, paste, and print
SecurityOptions securityOptions = new SecurityOptions();
securityOptions.setAllowUserCopyPasteContent(false);
securityOptions.setAllowUserAnnotations(false);
securityOptions.setAllowUserPrinting(PdfPrintSecurity.FULL_PRINT_RIGHTS);
securityOptions.setAllowUserFormData(false);
securityOptions.setOwnerPassword("top-secret");
securityOptions.setUserPassword("sharable");

// Change or set the document encryption password
SecurityManager securityManager = pdf.getSecurity();
securityManager.removePasswordsAndEncryption();
securityManager.makePdfDocumentReadOnly("secret-key");


securityManager.setSecurityOptions(securityOptions);
pdf.saveAs(Paths.get("assets/secured.pdf"));
mvn install
密码、安全性和元数据

密码、安全性和元数据

IronPDF可以修改PDF的元数据和安全设置。 在安全性方面,这包括使PDF为只读、不可打印、受密码保护和加密的能力。 对于元数据,这包括定义新属性和编辑现有属性的功能。

要在IronPDF for Java中管理PDF的元数据,开发人员首先必须获取其MetadataManager的引用。 此类提供直接访问和修改PDF元内容的方法。 开发人员可以使用具有相同名称的getter和setter快速读取和编辑文档上定义的常用元属性。

下面是具有便捷getter和setter的完整属性列表:

  • Producer
  • CreationDate
  • Creator
  • Author
  • Keywords
  • Subject
  • Title
  • ModifiedDate

代码示例使用setModifiedDate方法来修改工作文档的作者、标题和关键词。

要获取和设置之前未列出的属性,请使用setAnyMetadata方法以及所需属性的名称。

同样,必须通过SecurityManager访问和修改PDF文档的安全设置。 在SecurityManager的引用,并根据预期用途使用它来限制对PDF的访问。

Java开发人员可以使用SecurityOptions对象对PDF安全设置进行更精细的控制。

探索用于 Java PDF 管理的 MetadataManager API
在 GitHub 上查看

准备开始了吗?

版本:2026.6刚刚发布

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 天试用密钥。
无需信用卡或创建账户
Java Maven PDF 库
using Maven 安装

版本: 2026.6

<dependency>
   <groupId>com.ironsoftware</groupId>
   <artifactId>ironpdf</artifactId>
   <version>2026.6.1</version>
</dependency>
https://central.sonatype.com/artifact/com.ironsoftware/ironpdf/2026.6.1
or
Java PDF JAR
下载 JAR

版本: 2026.6

手动安装到您的项目中