Passwords, Security & Metadata

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
Passwords, Security & Metadata

Passwords, Security & Metadata

IronPDF can make modifications to PDF metadata and security settings. In terms of security, this includes the ability to make PDFs read-only, unprintable, password protected, and encrypted. For metadata, this includes the ability to define new properties and edit existing ones.

To manage a PDF's metadata in IronPDF for Java, the developer must first retrieve a reference to its MetadataManager. This class provides methods for direct access and modification of the PDF's meta content. Developers can quickly read and edit commonly defined meta properties defined on PDF documents using getters and setters with the same name.

The full list of properties with convenient getters and setters is below:

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

The code example uses the setAuthor, setTitle, setKeywords, and setModifiedDate methods to modify the working document's author, title, and keywords.

To get and set properties other than the ones previously listed, use the getAnyMetadata and setAnyMetadata methods with the name of the desired property.

Likewise, accessing and modifying security settings on a PDF document must be done through a SecurityManager. Call getSecurity on a PdfDocument to retrieve a reference to its SecurityManager and use it to restrict access to the PDF as required for the intended use.

Java developers can use a SecurityOptions object for more granular control over PDF security settings.

Explore MetadataManager API for Java PDF Management
View on GitHub

Ready to Get Started?

Version:2026.10just released