This guide explains how to secure PDF documents with password protection and control user permissions for viewing, printing, copying, and editing.

PDF passwords

PDF files can be protected with passwords to control who can access, modify, and print the contents of a document.

PDFs are protected with two types of passwords: the owner password and the user password.

  • Owner password — This password enables the owner of a PDF file to modify the file and change its permissions. The owner can change the user password, as well as set or modify the user permissions that control what users can do with the file.
  • User password — This password enables a user to open a PDF file with a set of permissions defined by the owner of the file. These permissions control what the user can do with the file, such as view, print, copy, or modify the contents. The user password can be used to protect the PDF file from unauthorized access by preventing users from viewing or modifying the file without the password.

PDF permissions

Specify what users can do to a password-protected document with the user_permissions parameter. The value of this parameter is an array, where each element is one of the following:

  • annotations_and_forms enables users to add or modify text annotations and fill in interactive form fields.
  • assemble enables users to insert, rotate, or delete pages and create document outline items or thumbnail images.
  • extract enables users to copy or otherwise extract text and graphics from the document.
  • extract_accessibility enables users to copy or otherwise extract text and graphics from the document using accessibility options.
  • fill_forms enables users to fill in existing interactive form fields (including signature fields).
  • modification enables users to modify the document in any way not covered by the other permissions settings.
  • print_high_quality enables users to print the document in high quality.
  • printing enables users to print the document.

Disable document printing:

Terminal window
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer your_api_key_here" \
-o result.pdf \
--fail \
-F document=@document.pdf \
-F instructions='{
"parts": [
{
"file": "document"
}
],
"output": {
"type": "pdf",
"owner_password": "owner-password",
"user_password": "user-password",
"user_permissions": [
"modification",
"extract",
"annotations_and_forms",
"fill_forms",
"extract_accessibility",
"assemble"
]
}
}'