Protect PDF
Purpose
This API allows you to password protect a PDF file or overwrite the permissions of an already protected PDF file.
Quick Reference
| Property | Value |
|---|---|
| Method | POST |
| Request URL | https://{zohoapis_domain}/pdfeditor/api/v1/pdf/protect |
Body Parameters
| Parameter | Value | Mandatory/Optional | Description |
|---|---|---|---|
| file | File or String | Mandatory | Upload the PDF file from your local drive or desktop. If the PDF is available via a publicly accessible web URL, you can provide the URL using the same parameter. |
| input_options | { "password": "***" } | Mandatory | If the input PDF is already password protected, specify the password to unlock it. |
| output_settings | { "name": "<document_name>", "encryption_algorithm": "AES128" | "AES256" | "RC4128", "password": "***", "restrictions": { "password": "***", "permissions": ["document.copy", "document.print", ...] } } | Mandatory | name(optional) – Name of the output PDF after protection. encryption_algorithm(optional) – Encryption type. Supported values: AES128, AES256, RC4128. Default: AES128. password(optional) – Password to be set for the output PDF. Allowed character limit: 6 to 255. restrictions(optional) – Specify restriction settings. If restrictions is passed, both password and permissions fields are mandatory. password – Password to enable or override restricted permissions. Allowed character limit: 6 to 255. permissions – Specify the actions that need to be restricted in the PDF. |
permissions
| Permission Key Name | Description |
|---|---|
| document.copy | Copy content from the PDF. |
| document.copy.accessibility | Copy content for use with accessibility tools (e.g., screen readers). |
| document.fill | Fill in form fields within the PDF. |
| document.print | Print content from the PDF. |
| document.print.low_quality | Print the PDF in low quality. |
| document.annotate | Add comments, annotations, or markups to the PDF. |
| document.assemble_document | Insert, rotate, delete, or rearrange pages in the PDF. |
Notes and Limits
- The maximum file size allowed for the input PDF is 50 MB. It cannot be more than 150 pages.
- AES256 encryption is supported only for PDF version 1.7 or above.
- If the restrictions param is passed, both password and permissions fields are mandatory.
- To use this API, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL
Possible Errors
Refer to the following pages for the list of possible errors for this API:
Sample Request
Copiedcurl --location --request POST "https:///www.zohoapis.com/pdfeditor/api/v1/pdf/protect" \
--header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
--form 'file=@/Users/username/Documents/Original.pdf' \
--form 'input_options={"password": "abc123"}' \
--form 'output_settings={"name": "protected_document.pdf", "encryption_algorithm": "AES256", "password": "user123", "restrictions": {"password": "owner123", "permissions": ["document.copy", "document.print", "document.fill"]}}'
Once the process begins, you will initially receive the 'status_url'. By invoking the 'status_url', you will be able to monitor the status of the scheduled job.
Sample Response
Copied{
"status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/protect/job/f931a01183b33",
"status": "inprogress"
}
Success Response
Copied{
"download_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/protect/download/f931a01183b33",
"status": "success"
}