IRONSOFTWAREHOME
Passwords, Security & Metadata
import {PdfDocument} from "@ironsoftware/ironpdf";

(async () => {
    // Import a PDF document or create a new PDF from Html
    const pdf = await PdfDocument.open("encrypted.pdf", "password");

    // Create an empty Map
    const newMetadata = new Map();

    // Add key-value pairs of metadata
    newMetadata.set("Author", "Satoshi Nakamoto");
    newMetadata.set("Keywords", "SEO, Friendly");

    await pdf.overrideMetadata(newMetadata);

    await pdf.removePasswordsAndEncryption();
    // Make PDF read-only
    await pdf.makePdfDocumentReadOnly("secret-key");

    // Configure permissions
    const permissions = {
        AllowAnnotations: false,
        AllowExtractContent: false,
        AllowFillForms: false,
        AllowPrint: true,
    };

    await pdf.setPermission(permissions);
    
    // Change or set the document encrpytion password
    await pdf.saveAs("secured.pdf", {
        ownerPassword: "top-secret",
        userPassword: "my-password",
    });
})();
npm i @ironsoftware/ironpdf
Passwords, Security & Metadata

Passwords, Security & Metadata

IronPDF allows the ability to encrypt, decrypt, modify metadata, and set certain permissions regarding annotations, copying and pasting content, form fields, and printing.

To open a password-protected PDF document, use the open method and provide the password as the second parameter. Setting metadata requires creating a new map and inputting key-value pairs corresponding to the metadata information. Pass the new metadata map into the overrideMetadata method to override the old metadata.

The removePasswordsAndEncryption method is used to remove any passwords from the document. The makePdfDocumentReadOnly method will make this PDF document read-only, encrypting content at 128 bits and disallowing copy and paste of content, annotations, and form editing.

Configure permissions by creating a permission object with permission settings and pass it to the setPermission method.

Lastly, the saveAs method can facilitate an object with ownerPassword and userPassword properties to be set respectively.

For more detailed information about the capabilities and uses of IronPDF, visit the IronPDF product page or explore more about Iron Software's other products on their website.

Explore Security & Metadata Examples on GitHub
View on GitHub

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Node.js Module Download for PDF
Install with npm

Version: 2026.8

  1. Download and install Node.js 12+.
  2. Execute the above command in the terminal.

Licenses from $999