March 11, 20266 min read
PDF Encryption: Password Protection and Permission Controls
Lock PDFs with user and owner passwords, restrict printing, copying, and editing. AES-256 encryption made simple.
encryptionpasswordsecurityaes-256
Two types of PDF passwords
PDFs support two password types:
- User password: Required to open/view the PDF
- Owner password: Required to bypass permission restrictions (print, copy, edit)
Encrypting a PDF
const res = await fetch('https://pdfrelay.com/api/v1/convert', {
method: 'POST',
headers: { 'Authorization': 'Bearer sk_live_...', 'Content-Type': 'application/json' },
body: JSON.stringify({
source: 'html',
content: html,
options: {
encrypt: true,
user_password: 'viewerpass',
owner_password: 'adminpass',
no_print: true,
no_copy: true,
no_modify: true,
},
}),
});
AES-256 encryption. Works with both the Rust engine and any PDF viewer that supports the standard.