VOOZH about

URL: https://ironpdf.com/nodejs/examples/security-and-metadata/

⇱ Code Example: Set Passwords & Metadata | IronPDF .NET 10 Node.js


Skip to footer content
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",
 });
})();

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

Ready to Get Started?
Version: 2026.5 just released

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.

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

Have a question? Get in touch with our development team.

Now you've installed with NPM
Your browser is now downloading IronPDF

Next step: Start free 30-day Trial

No credit card required

  • Test in a live environment
  • Fully-functional product
  • 24/5 technical support

Thank You

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:
πŸ‘ badge_greencheck_in_yellowcircle
The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Have a question? Get in touch with our development team.
No credit card or account creation required
Now you've installed with NPM
Your browser is now downloading IronPDF

Next step: Start free 30-day Trial

No credit card required

  • Test in a live environment
  • Fully-functional product
  • 24/5 technical support
Thank you.
View your license options:
Thank you.
If you'd like to speak to our licensing team:
Have a question? Get in touch with our development team.
Have a question? Get in touch with our development team.
Talk to Sales Team

Book a No-obligation Consult

How we can help:
  • Consult on your workflow & pain points
  • See how other companies solve their .NET document needs
  • All your questions answered to make sure you have all the information you need. (No commitment whatsoever.)
  • Get a tailored quote for your project's needs
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
Book Free Live Demo

Book a 30-minute, personal demo.

No contract, no card details, no commitments.

Here's what to expect:
  • A live demo of our product and its key features
  • Get project specific feature recommendations
  • All your questions are answered to make sure you have all the information you need.
    (No commitment whatsoever.)
CHOOSE TIME
YOUR INFO
Book your free Live Demo

Trusted by Millions of Engineers Worldwide

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me