🍋
Menu
PDF

Encryption

PDF Encryption

Password-based or certificate-based protection that restricts access to PDF content.

Technical Detail

Encryption in PDF operates at two levels: a user password (required to open the document) and an owner password (required to change permissions like printing or editing). Modern PDF encryption uses AES-256, replacing the older RC4 algorithm that was vulnerable to known-plaintext attacks. The encryption applies to the document's stream data and strings, while the file structure itself remains readable by PDF parsers for metadata extraction.

Example

```javascript
// PDF encryption settings
const encryptedPdf = await PDFDocument.create();
await encryptedPdf.encrypt({
  userPassword: 'view-password',    // required to open
  ownerPassword: 'admin-password',   // required to edit
  permissions: {
    printing: 'lowResolution',
    modifying: false,
    copying: false,
  }
});
```

Related Formats

Related Tools

Related Terms