Link Search Menu Expand Document

PDF Password And Security

Merge PDF from two or more PDF files into a new one.

Available methods

[POST] /pdf/security/add

  • url required. URL to the source file. Must be a String. You can pass link to file from Google Drive, Dropbox or another online file service that can generate shareable links. You can also use built-in PDF.co cloud storage located at https://app.pdf.co/files or upload your file as temporary file right before making this API call (see Upload and Manage Files section for more details on uploading files via API).
  • ownerPassword - The main owner password that is used for documents encryption and for setting/removing restrictions.
  • userPassword - The optional user password will be asked for viewing and printing document.
  • encryptionAlgorithm - Encryption algorithm. Valid values: RC4_40bit, RC4_128bit, AES_128bit, AES_256bit. AES_128bit or higher is recommended.
  • allowAccessibilitySupport - 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 user enters Owner Password.
  • allowAssemblyDocument - Allow or prohibit assembling the document. true/false. Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if user enters Owner Password.
  • allowPrintDocument - Allow or prohibit printing PDF document. true/false. Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if user enters Owner Password.
  • allowFillForms - Allow or prohibit filling of interactive form fields (including signature fields) in PDF document. true/false. Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if user enters Owner Password.
  • allowModifyDocument - Allow or prohibit modification of PDF document. true/false.Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if user enters Owner Password.
  • allowContentExtraction - Allow or prohibit copying content from PDF document. true/false.Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if user enters Owner Password.
  • allowModifyAnnotations - Allow or prohibit interacting with text annotations and forms in PDF document. true/false.Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if user enters Owner Password.
  • printQuality - Allowed printing quality. Valid values: HighResolution, LowResolution. Note: this restriction applies when userPassword (if any) is entered. This restriction does not apply if user enters Owner Password.

  • encrypt optional. Enable encryption for output file when stored in output cloud storage. Must be one of: true, false.

  • async optional. Runs processing asynchronously. Returns Use JobId that you may use with /job/check to check state of the processing (possible states: working, failed, aborted and success). Must be one of: true, false.

  • name optional. name of the output file.

  • profiles optional. Must be a String. You can set additional and extra options using this parameter that allows you to set custom configuration. See profiles samples for examples.

Description

  • Method: POST
  • URL: /v1/pdf/security/add

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf",
    "ownerPassword": "12345",
    "userPassword": "54321",
    "EncryptionAlgorithm": "AES_128bit",
    "AllowPrintDocument": false,
    "AllowFillForms": false,
    "AllowModifyDocument": false,
    "AllowContentExtraction": false,
    "AllowModifyAnnotations": false,
    "PrintQuality": "LowResolution",
    "encrypt": false,
    "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 Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/pdf/security/add' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf",
    "ownerPassword": "12345",
    "userPassword": "54321",
    "EncryptionAlgorithm": "AES_128bit",
    "AllowPrintDocument": false,
    "AllowFillForms": false,
    "AllowModifyDocument": false,
    "AllowContentExtraction": false,
    "AllowModifyAnnotations": false,
    "PrintQuality": "LowResolution",
    "encrypt": false,
    "name": "output-protected.pdf",
    "async": false
}'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var raw = "{\n    \"url\": \"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf\",\n    \"ownerPassword\": \"12345\",\n    \"userPassword\": \"54321\",\n    \"EncryptionAlgorithm\": \"AES_128bit\",\n    \"AllowPrintDocument\": false,\n    \"AllowFillForms\": false,\n    \"AllowModifyDocument\": false,\n    \"AllowContentExtraction\": false,\n    \"AllowModifyAnnotations\": false,\n    \"PrintQuality\": \"LowResolution\",\n    \"encrypt\": false,\n    \"name\": \"output-protected.pdf\",\n    \"async\": false\n}";

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: raw,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/pdf/security/add", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/pdf/security/add',
	'headers': {
		'x-api-key': ''
	},
	body: '{\n    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf",\n    "ownerPassword": "12345",\n    "userPassword": "54321",\n    "EncryptionAlgorithm": "AES_128bit",\n    "AllowPrintDocument": false,\n    "AllowFillForms": false,\n    "AllowModifyDocument": false,\n    "AllowContentExtraction": false,\n    "AllowModifyAnnotations": false,\n    "PrintQuality": "LowResolution",\n    "encrypt": false,\n    "name": "output-protected.pdf",\n    "async": false\n}'

};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/pdf/security/add',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS =>'{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf",
    "ownerPassword": "12345",
    "userPassword": "54321",
    "EncryptionAlgorithm": "AES_128bit",
    "AllowPrintDocument": false,
    "AllowFillForms": false,
    "AllowModifyDocument": false,
    "AllowContentExtraction": false,
    "AllowModifyAnnotations": false,
    "PrintQuality": "LowResolution",
    "encrypt": false,
    "name": "output-protected.pdf",
    "async": false
}',
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = RequestBody.create(mediaType, "{\n    \"url\": \"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf\",\n    \"ownerPassword\": \"12345\",\n    \"userPassword\": \"54321\",\n    \"EncryptionAlgorithm\": \"AES_128bit\",\n    \"AllowPrintDocument\": false,\n    \"AllowFillForms\": false,\n    \"AllowModifyDocument\": false,\n    \"AllowContentExtraction\": false,\n    \"AllowModifyAnnotations\": false,\n    \"PrintQuality\": \"LowResolution\",\n    \"encrypt\": false,\n    \"name\": \"output-protected.pdf\",\n    \"async\": false\n}");
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/pdf/security/add")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/pdf/security/add");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			var body = @"{" + "\n" +
			@"    ""url"": ""https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf""," + "\n" +
			@"    ""ownerPassword"": ""12345""," + "\n" +
			@"    ""userPassword"": ""54321""," + "\n" +
			@"    ""EncryptionAlgorithm"": ""AES_128bit""," + "\n" +
			@"    ""AllowPrintDocument"": false," + "\n" +
			@"    ""AllowFillForms"": false," + "\n" +
			@"    ""AllowModifyDocument"": false," + "\n" +
			@"    ""AllowContentExtraction"": false," + "\n" +
			@"    ""AllowModifyAnnotations"": false," + "\n" +
			@"    ""PrintQuality"": ""LowResolution""," + "\n" +
			@"    ""encrypt"": false," + "\n" +
			@"    ""name"": ""output-protected.pdf""," + "\n" +
			@"    ""async"": false" + "\n" +
			@"}";
			request.AddParameter("text/plain", body,  ParameterType.RequestBody);
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/pdf/security/add"

payload = "{\n    \"url\": \"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf\",\n    \"ownerPassword\": \"12345\",\n    \"userPassword\": \"54321\",\n    \"EncryptionAlgorithm\": \"AES_128bit\",\n    \"AllowPrintDocument\": false,\n    \"AllowFillForms\": false,\n    \"AllowModifyDocument\": false,\n    \"AllowContentExtraction\": false,\n    \"AllowModifyAnnotations\": false,\n    \"PrintQuality\": \"LowResolution\",\n    \"encrypt\": false,\n    \"name\": \"output-protected.pdf\",\n    \"async\": false\n}"
headers = {
	'x-api-key': ''
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$body = "{`n    `"url`": `"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-merge/sample1.pdf`",`n    `"ownerPassword`": `"12345`",`n    `"userPassword`": `"54321`",`n    `"EncryptionAlgorithm`": `"AES_128bit`",`n    `"AllowPrintDocument`": false,`n    `"AllowFillForms`": false,`n    `"AllowModifyDocument`": false,`n    `"AllowContentExtraction`": false,`n    `"AllowModifyAnnotations`": false,`n    `"PrintQuality`": `"LowResolution`",`n    `"encrypt`": false,`n    `"name`": `"output-protected.pdf`",`n    `"async`": false`n}"

$response = Invoke-RestMethod 'https://api.pdf.co/v1/pdf/security/add' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

[POST] /pdf/security/remove

  • url required. URL to the source file. Must be a String. You can pass link to file from Google Drive, Dropbox or another online file service that can generate shareable links. You can also use built-in PDF.co cloud storage located at https://app.pdf.co/files or upload your file as temporary file right before making this API call (see Upload and Manage Files section for more details on uploading files via API).
  • password - The owner/user password to open file and to remove security features.

  • encrypt optional. Enable encryption for output file. Must be one of: true, false.
  • async optional. Runs processing asynchronously. Returns Use JobId that you may use with /job/check to check state of the processing (possible states: working, failed, aborted and success). Must be one of: true, false.
  • name optional. name of the output file.
  • profiles optional. Must be a String. You can set additional and extra options using this parameter that allows you to set custom configuration. See profiles samples for examples.

Description

  • Method: POST
  • URL: /v1/pdf/security/remove

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf",
    "password": "admin@123",
    "name": "unprotected"
}

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 Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/pdf/security/remove' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf",
    "password": "admin@123",
    "name": "unprotected"
}'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var raw = "{\n    \"url\": \"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf\",\n    \"password\": \"admin@123\",\n    \"name\": \"unprotected\"\n}";

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: raw,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/pdf/security/remove", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/pdf/security/remove',
	'headers': {
		'x-api-key': ''
	},
	body: '{\n    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf",\n    "password": "admin@123",\n    "name": "unprotected"\n}'

};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/pdf/security/remove',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS =>'{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf",
    "password": "admin@123",
    "name": "unprotected"
}',
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = RequestBody.create(mediaType, "{\n    \"url\": \"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf\",\n    \"password\": \"admin@123\",\n    \"name\": \"unprotected\"\n}");
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/pdf/security/remove")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/pdf/security/remove");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			var body = @"{" + "\n" +
			@"    ""url"": ""https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf""," + "\n" +
			@"    ""password"": ""admin@123""," + "\n" +
			@"    ""name"": ""unprotected""" + "\n" +
			@"}";
			request.AddParameter("text/plain", body,  ParameterType.RequestBody);
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/pdf/security/remove"

payload = "{\n    \"url\": \"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf\",\n    \"password\": \"admin@123\",\n    \"name\": \"unprotected\"\n}"
headers = {
	'x-api-key': ''
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$body = "{`n    `"url`": `"https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-security/ProtectedPDFFile.pdf`",`n    `"password`": `"admin@123`",`n    `"name`": `"unprotected`"`n}"

$response = Invoke-RestMethod 'https://api.pdf.co/v1/pdf/security/remove' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json