Free plan

Encrypt / Decrypt

Lock a PDF with a password or remove its password
POST
/v1/pdfs/security

About this tool

This tool protects a PDF with a password, or takes the protection off one. When you lock it, you set a password to open the file and can set what is allowed, such as printing or copying. To unlock a PDF you must type its current password. Keep your passwords safe, because a lost password cannot be recovered.
For example, you lock a PDF with your bank details so it needs a password to open before you e-mail it.

How to use it

  1. Choose this tool.
  2. Add your PDF.
  3. Choose to lock (encrypt) or to unlock (decrypt) it.
  4. Type the password. When locking, you can also set a separate password for permissions and choose what is allowed.
  5. Press Generate, then download the new PDF.

What you get back

You get a new PDF that is locked with your password, or one with the password removed. You can download it.
TEST IT LIVE

Try Encrypt / Decrypt in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
PDFs
Plan
Free
Method
POST
Endpoint
/v1/pdfs/security
Tool ID
pdfs.security
Authentication
API key
Accepts
PDF
Background jobs
Yes
Usage group
Pdf
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/pdfs/security" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'file=@document.pdf' \
  -F 'operation=encrypt' \
  -F 'keyLength=256' \
  -F 'output_bundle=zip'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.pdfs.security({
    "file": 'document.pdf',
    "operation": "encrypt",
    "keyLength": 256,
    "output_bundle": "zip"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->pdfs()->security([
    'file' => 'document.pdf',
    'operation' => 'encrypt',
    'keyLength' => 256,
    'output_bundle' => 'zip',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Lock a PDF with a password or remove its password. It can do several jobs from one endpoint: operation, enum-field, items.

Encrypt / Decrypt accepts PDF. You can send several files in one request.

Encrypt / Decrypt is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/pdfs/security with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.