Data Encryption & Decryption#
PDF.co platform provides built-in user controlled data encryption that you can use for input and output files.
User-controlled encryption and decryption can be applied in almost any API endpoint that reads input files and/or writes output files. Just use the profiles
parameter to pass user-controlled encryption and/or decryption options like encryption algorithm, password, initialization vector (aka 2nd password).
Note
For the detailed information on options and encryption algorithms available, please check User-Controlled Encryption.
Popular Use Cases#
Automatically encrypt output files with strong AES encryption and copy these files into cloud storage like Google Drive or Dropbox. With user controlled encrypted data inside, cloud storage services can not even scan the content of your files.
Automatically read encrypted documents provided and previously encrypted by by 3rd party services like Salesforce, Zapier_Integration, Make_Integration and others (including
javascript
,php
,java
,.net
custom apps).Add another layer of security by using user-controlled data encryption for processing documents. With user-controlled encryption even temporary files requires further decryption to be readable. This way even if a temporary link to a file is leaked, it is not possible to read this file without applying decryption with your custom provided password.
Read Custom Encrypted PDF#
This sample request demonstrates how to set profiles with built-in decryption options for AES encrypted document (doc
/docx
) to pdf
endpoint.
Method: POST
Endpoint: /v1/pdf/info
Note
We are using the profiles
parameter to decrypt here.
Query parameters#
No query parameters accepted.
Payload 3#
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf",
"async": false,
"profiles": "{ 'DataDecryptionAlgorithm': 'AES128', 'DataDecryptionKey': 'HelloThisKey1234', 'DataDecryptionIV': 'TreloThisKey1234' }"
}
Response 2#
{
"info": {
"PageCount": 1,
"Author": "Hiren Patel",
"Title": "",
"Producer": "Microsoft® Word 2016",
"Subject": "",
"CreationDate": "2021-01-10T10:10:54+05:30",
"Bookmarks": "",
"Keywords": "",
"Creator": "Microsoft® Word 2016",
"Encrypted": false,
"PasswordProtected": false,
"PageRectangle": {
"Location": {
"IsEmpty": true,
"X": 0,
"Y": 0
},
"Size": "612, 792",
"X": 0,
"Y": 0,
"Width": 612,
"Height": 792,
"Left": 0,
"Top": 0,
"Right": 612,
"Bottom": 792,
"IsEmpty": false
},
"ModificationDate": "2021-01-10T10:10:54+05:30",
"AttachmentCount": 0,
"EncryptionAlgorithm": "None",
"PermissionPrinting": true,
"PermissionModifyDocument": true,
"PermissionContentExtraction": true,
"PermissionModifyAnnotations": true,
"PermissionFillForms": true,
"PermissionAccessibility": true,
"PermissionAssemble": true,
"PermissionHighQualityPrint": true,
"CustomProperties": []
},
"error": false,
"status": 200,
"credits": 7,
"duration": 446,
"remainingCredits": 98320547
}
CURL#
curl --location --request POST 'https://api.pdf.co/v1/pdf/info' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf",
"async": false,
"profiles": "{ '\''DataDecryptionAlgorithm'\'': '\''AES128'\'', '\''DataDecryptionKey'\'': '\''HelloThisKey1234'\'', '\''DataDecryptionIV'\'': '\''TreloThisKey1234'\'' }"
}'
Custom encrypted Docx to PDF#
This sample request demonstrates how to set profiles with built-in decryption options for AES encrypted document (doc/docx) to pdf endpoint.
Method: POST
Endpoint: /v1/pdf/convert/from/doc
Query parameters#
No query parameters accepted.
Payload 3#
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.docx",
"name": "result.pdf",
"async": false,
"profiles": "{ 'DataDecryptionAlgorithm': 'AES128', 'DataDecryptionKey': 'HelloThisKey1234', 'DataDecryptionIV': 'TreloThisKey1234' }"
}
Response 2#
{
"url": "https://pdf-temp-files.s3.amazonaws.com/GB6XMWN2VGDTUMKBQBRI24EWYSFRLLLL/result.pdf",
"pageCount": 1,
"error": false,
"status": 200,
"name": "result.pdf",
"credits": 21,
"duration": 2903,
"remainingCredits": 98320505
}
CURL#
curl --location --request POST 'https://api.pdf.co/v1/pdf/convert/from/doc' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.docx",
"name": "result.pdf",
"async": false,
"profiles": "{ '\''DataDecryptionAlgorithm'\'': '\''AES128'\'', '\''DataDecryptionKey'\'': '\''HelloThisKey1234'\'', '\''DataDecryptionIV'\'': '\''TreloThisKey1234'\'' }"
}'
Read QR Code From Encrypted PNG#
This sample request demonstrates how to set profiles with built-in decryption options for QR Code decoding from AES encrypted PNG image file.
Method: POST
Endpoint: /v1/barcode/read/from/url
Query parameters#
No query parameters accepted.
Payload 3#
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/barcode_encrypted_aes128.png",
"types": "QRCode",
"inline": true,
"async": false,
"profiles": "{ 'DataDecryptionAlgorithm': 'AES128', 'DataDecryptionKey': 'Qweasd1234567890', 'DataDecryptionIV': '0mDI&qLv*ivTCd$*' }"
}
Response 2#
{
"barcodes": [
{
"Value": "]Q3\\01695046551543111713033110TEST5632",
"RawData": "",
"Type": 14,
"Rect": "11, 11, 75, 75",
"Page": 0,
"File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/barcode_encrypted_aes128.png",
"Confidence": 1,
"Metadata": "",
"TypeName": "QRCode"
}
],
"pageCount": 1,
"error": false,
"status": 200,
"credits": 35,
"duration": 375,
"remainingCredits": 98320470
}
CURL#
curl --location --request POST 'https://api.pdf.co/v1/barcode/read/from/url' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/barcode_encrypted_aes128.png",
"types": "QRCode",
"inline": true,
"async": false,
"profiles": "{ '\''DataDecryptionAlgorithm'\'': '\''AES128'\'', '\''DataDecryptionKey'\'': '\''Qweasd1234567890'\'', '\''DataDecryptionIV'\'': '\''0mDI&qLv*ivTCd$*'\'' }"
}'
PDF Encrypted by SalesForce with AES128 To JPG#
This sample request demonstrates how to set profiles with built-in decryption options for PDF to JPG conversion PDF file that was previously encrypted with AES 128 in SalesForce.
Method: POST
Endpoint: /v1/pdf/convert/to/jpg
Query parameters#
No query parameters accepted.
Payload 3#
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf",
"name": "result.jpg",
"inline" : true,
"pages": "0",
"async": false,
"profiles": "{ 'DataDecryptionAlgorithm': 'AES128', 'DataDecryptionKey': 'HelloThisKey1234', 'DataDecryptionIV': 'TreloThisKey1234' }"
}
Response 2#
{
"urls": [
"https://pdf-temp-files.s3.amazonaws.com/0C38ED7DQO0NB5UEJTAP35MEPPAPJXAT/result.jpg"
],
"pageCount": 1,
"error": false,
"status": 200,
"name": "result.jpg",
"credits": 12,
"duration": 408,
"remainingCredits": 98320458
}
CURL#
curl --location --request POST 'https://api.pdf.co/v1/pdf/convert/to/jpg' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf",
"name": "result.jpg",
"inline" : true,
"pages": "0",
"async": false,
"profiles": "{ '\''DataDecryptionAlgorithm'\'': '\''AES128'\'', '\''DataDecryptionKey'\'': '\''HelloThisKey1234'\'', '\''DataDecryptionIV'\'': '\''TreloThisKey1234'\'' }"
}'
Merge PDFs encrypted by SalesForce to new PDF encrypted for SalesForce#
This sample request demonstrates how to set profiles with built-in decryption options for merging multiple PDF files previously encrypted with AES 128 encryption in SalesForce. Also, it enables user-controlled encryption for output PDF file so output PDF is also user-encrypted and will require applying AES decryption before processing in SalesForce or another platforms.
Method: POST
Endpoint: /v1/pdf/merge
Query parameters#
No query parameters accepted.
Payload 3#
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf, https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf",
"name": "result.pdf",
"pages": "0",
"async": false,
"profiles": "{ 'DataDecryptionAlgorithm': 'AES128', 'DataDecryptionKey': 'HelloThisKey1234', 'DataDecryptionIV': 'TreloThisKey1234', 'DataEncryptionAlgorithm': 'AES128', 'DataEncryptionKey': 'HelloThisKey1234', 'DataEncryptionIV': 'TreloThisKey1234' }"
}
Response 2#
{
"url": "https://pdf-temp-files.s3.amazonaws.com/DH86OQ2JRK7CZ3WCVTICA84TLPUVJCCS/result.pdf",
"pageCount": 2,
"error": false,
"status": 200,
"name": "result.pdf",
"credits": 4,
"duration": 457,
"remainingCredits": 98320454
}
CURL#
curl --location --request POST 'https://api.pdf.co/v1/pdf/merge' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf, https://pdfco-test-files.s3.us-west-2.amazonaws.com/encryption/sample_encrypted_aes128.pdf",
"name": "result.pdf",
"pages": "0",
"async": false,
"profiles": "{ '\''DataDecryptionAlgorithm'\'': '\''AES128'\'', '\''DataDecryptionKey'\'': '\''HelloThisKey1234'\'', '\''DataDecryptionIV'\'': '\''TreloThisKey1234'\'', '\''DataEncryptionAlgorithm'\'': '\''AES128'\'', '\''DataEncryptionKey'\'': '\''HelloThisKey1234'\'', '\''DataEncryptionIV'\'': '\''TreloThisKey1234'\'' }"
}'
Footnotes
- 1
Supports publicly accessible links from any source, including Google Drive, Dropbox, and PDF.co Built-In Files Storage. To upload files via the API, check out the File Upload section. Note: If you experience intermittent Access Denied or Too Many Requests errors, please try adding
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.- 2(1,2,3,4,5)
Main response codes as follows:
Code
Description
200
Success
400
Bad request. Typically happens because of bad input parameters, or because the input URLs can’t be reached, possibly due to access restrictions like needing a login or password.
401
Unauthorized
402
Not enough credits
445
Timeout error. To process large documents or files please use asynchronous mode (set the
async
parameter totrue
) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using thepages
parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.Note
For more see the complete list of available response codes.
- 3(1,2,3,4,5)
PDF.co Request size: API requests do not support request sizes of more than
4
megabytes in size. Please ensure that request sizes do not exceed this limit.