Encrypt
Protect a PDF with passwords and permissions.
The encrypt action protects the PDF with AES-256. user_password is needed to open it;
owner_password is needed to change it (leave user_password out and anyone can open it, with
the permissions enforced). permissions (optional) is the sum of what readers may do without the
owner password: 1 print, 2 modify, 4 copy, 8 annotate, 16 fill forms, 32 assemble pages. By
default they may print and fill forms.
encrypt must be the last action and the output must be PDF, since nothing can work on the file
once it is encrypted.
Cost: 1 unit per action.
Lock a payslip
curl https://api.nexpdf.dev/v1/build \
-H "Authorization: Bearer $NEXPDF_API_KEY" \
-F doc=@payslip.pdf \
-F 'instructions={
"parts": [
{
"file": "doc"
}
],
"actions": [
{
"type": "encrypt",
"owner_password": "owner-secret",
"user_password": "employee-1042"
}
]
}' \
-o payslip-locked.pdfTo open an encrypted PDF in a build, give its password in the part: { "file": "doc", "password": "…" }.