Link Search Menu Expand Document

PDF Password And Security

Explore Samples

Add password and security limitations to PDF or remove existing limits and password from existing PDF files.

Available Methods

[POST] /pdf/security/add

Attributes
url required
URL to the source file. Supports links from Google Drive, Dropbox, and PDF.co built-in files storage. To upload files via API, Check out the Files Upload section.

Note: If you experience intermittent Too Many Requests or Access Denied errors, please try to add cache: to enable built-in URL caching. (e.g cache:https://example.com/file1.pdf)

For data security, you have the option to encrypt output files and decrypt input files. Learn more about user-controlled data encryption.
ownerPassword required
The main owner password that is used for document encryption and for setting/removing restrictions.
userPassword optional
The optional user password will be asked for viewing and printing document.
encryptionAlgorithm optional
Encryption algorithm. Valid values: RC4_40bit, RC4_128bit, AES_128bit, AES_256bit. AES_128bit or higher is recommended.
allowAccessibilitySupport optional
Allow or prohibit content extraction for accessibility needs. true/false. Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
allowAssemblyDocument optional
Allow or prohibit assembling the document. true/false. Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
allowPrintDocument true/false
Allow or prohibit printing PDF document.
Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
allowFillForms true/false
Allow or prohibit the filling of interactive form fields (including signature fields) in the PDF documents.
Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
allowModifyDocument true/false
Allow or prohibit modification of PDF document.
Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
allowContentExtraction true/false
Allow or prohibit copying content from PDF document.
Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
allowModifyAnnotations true/false
Allow or prohibit interacting with text annotations and forms in PDF document.
Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
printQuality optional
Allowed printing quality. Valid values: HighResolution, LowResolution.
Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if the user enters Owner Password.
async optional
Set async to true for long processes to run in the background, API will then return a jobId which you can use with /job/check endpoint to check the status of the process and retrieve the output while you can proceed with other tasks without waiting for this process to finish.
name optional
File name for the generated output.
expiration optional
Set the expiration time for the output link in minutes (default is 60 i.e 60 minutes or 1 hour), After this specified duration, any generated output file(s) will be automatically deleted from PDF.co temporary files storage. The maximum duration for link expiration varies based on your current subscription plan. Learn more

To store permanent input files (e.g. re-usable images, pdf templates, documents), Consider using PDF.co built-in Files Storage.
profiles optional
Use this parameter to set additional configurations for fine-tuning and extra options. Data must need to be in a “string” format. Explore PDF.co knowledgebase for profile examples.
  • Method: POST
  • URL: /v1/pdf/security/add

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-merge/sample1.pdf",
    "ownerPassword": "12345",
    "userPassword": "54321",
    "EncryptionAlgorithm": "AES_128bit",
    "AllowPrintDocument": false,
    "AllowFillForms": false,
    "AllowModifyDocument": false,
    "AllowContentExtraction": false,
    "AllowModifyAnnotations": false,
    "PrintQuality": "LowResolution",
    "name": "output-protected.pdf",
    "async": false
}

Example responses

/pdf/security/add
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/eaa441ade38548b8a3a96d8014c4f463/sample1.pdf",
    "pageCount": 1,
    "error": false,
    "status": 200,
    "name": "sample1.pdf",
    "remainingCredits": 616208,
    "credits": 14
}

Code Snippet

CURL
curl --location --request POST 'https://api.pdf.co/v1/pdf/security/add' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-merge/sample1.pdf",
    "ownerPassword": "12345",
    "userPassword": "54321",
    "EncryptionAlgorithm": "AES_128bit",
    "AllowPrintDocument": false,
    "AllowFillForms": false,
    "AllowModifyDocument": false,
    "AllowContentExtraction": false,
    "AllowModifyAnnotations": false,
    "PrintQuality": "LowResolution",
    "name": "output-protected.pdf",
    "async": false
}'

[POST] /pdf/security/remove

Attributes
url required
URL to the source file. Supports links from Google Drive, Dropbox, and PDF.co built-in files storage. To upload files via API, Check out the Files Upload section.

Note: If you experience intermittent Too Many Requests or Access Denied errors, please try to add cache: to enable built-in URL caching. (e.g cache:https://example.com/file1.pdf)

For data security, you have the option to encrypt output files and decrypt input files. Learn more about user-controlled data encryption.
password required
The owner/user password to open files and remove security features.
async optional
Set async to true for long processes to run in the background, API will then return a jobId which you can use with /job/check endpoint to check the status of the process and retrieve the output while you can proceed with other tasks without waiting for this process to finish.
name optional
File name for the generated output.
expiration optional
Set the expiration time for the output link in minutes (default is 60 i.e 60 minutes or 1 hour), After this specified duration, any generated output file(s) will be automatically deleted from PDF.co temporary files storage. The maximum duration for link expiration varies based on your current subscription plan. Learn more

To store permanent input files (e.g. re-usable images, pdf templates, documents), Consider using PDF.co built-in Files Storage.
profiles optional
Use this parameter to set additional configurations for fine-tuning and extra options. Data must need to be in a “string” format. Explore PDF.co knowledgebase for profile examples.
  • Method: POST
  • URL: /v1/pdf/security/remove

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-security/ProtectedPDFFile.pdf",
    "password": "admin@123",
    "name": "unprotected",
    "async": false
}

Example responses

/pdf/security/remove
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/9f2a754f76db46ac93781b3d2c6694c3/ProtectedPDFFile.pdf",
    "pageCount": 1,
    "error": false,
    "status": 200,
    "name": "ProtectedPDFFile.pdf",
    "remainingCredits": 616187,
    "credits": 21
}

Code Snippet

CURL
curl --location --request POST 'https://api.pdf.co/v1/pdf/security/remove' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-security/ProtectedPDFFile.pdf",
    "password": "admin@123",
    "name": "unprotected",
    "async": false
}'

Samples