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.11just released