# PDF Password Protect & Unlock (Bulk, AES-256) (`toowl/pdf-password-protect`) Actor

Lock PDFs with a password in bulk (AES-256), each file with its own password if you like (payslips, statements, reports), and block printing, copying or editing. Or unlock PDFs you have the password for. Pay per PDF.

- **URL**: https://apify.com/toowl/pdf-password-protect.md
- **Developed by:** [Chalid Ade](https://apify.com/toowl) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 pdfs secured

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## PDF Password Protect & Unlock — bulk, AES-256, per-file passwords

Lock a whole batch of PDFs with a password in one run, or give **every file its own password**: payslips that open with the employee's ID, statements that open with the customer's birth date, reports for each client. You can also block **printing, copying and editing**, or remove the password from PDFs you're allowed to open.

Encryption is **AES-256**, the strongest the PDF format offers, and it opens in Adobe Acrobat, Chrome, Edge, macOS Preview and every modern phone. Done with [qpdf](https://qpdf.sourceforge.io/), no third-party upload service.

### What you get

- **Protect**: an open password (AES-256) plus permissions for printing, copying text/images, editing, comments, forms and page changes
- **Per-file passwords**: `{ "url": "…", "password": "…" }` per item, or a URL → password map
- **Restrictions only**: no open password, but no copying or printing
- **Owner password**: random by default (nobody can lift the restrictions), or your own
- **Unlock**: removes the open password and every restriction (give the password when the PDF asks for one). Wrong passwords are reported per file
- **One ZIP** with all results, plus a dataset row per PDF

### Input

Same password for all:

```json
{
  "operation": "protect",
  "files": [
    { "url": "https://example.com/report-q3.pdf" },
    { "url": "https://example.com/report-q4.pdf" }
  ],
  "password": "S3cret-2026",
  "allowPrint": true,
  "allowCopy": false
}
```

A password per file (API):

```json
{
  "operation": "protect",
  "files": [
    { "url": "https://example.com/payslips/emp-1001.pdf", "password": "1001-19900415" },
    { "url": "https://example.com/payslips/emp-1002.pdf", "password": "1002-19880102" }
  ]
}
```

Unlock:

```json
{
  "operation": "unlock",
  "files": [{ "url": "https://example.com/locked.pdf" }],
  "password": "the-open-password"
}
```

### Output

```json
{
  "name": "emp-1001.pdf",
  "operation": "protect",
  "opensWithPassword": true,
  "encryption": "AES-256",
  "sizeKb": 84.2,
  "pdfUrl": "https://api.apify.com/v2/key-value-stores/…/records/0001-emp-1001.pdf"
}
```

Passwords are never written to the dataset, the log or the key-value store. Store input passwords in Apify secrets (the fields are marked secret).

### Pricing

Pay per event: one `pdf-secured` per PDF protected or unlocked. Files that fail (wrong password, already protected, not a PDF) are free.

### Free browser version

One file? [Protect PDF](https://toowl.my.id/en/protect-pdf/) and [Unlock PDF](https://toowl.my.id/en/unlock-pdf/) on toowl.my.id do it in your browser for free, without uploading anything.

### Call it from your code

```bash
curl -X POST "https://api.apify.com/v2/acts/toowl~pdf-password-protect/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"operation":"protect","files":[{"url":"https://example.com/a.pdf","password":"s3cret"}]}'
```

The same call works from Python (`apify-client`), JavaScript, Make, Zapier and n8n (Apify app/node or a plain HTTP request).

### Use it from AI agents (MCP)

Add this Actor as a tool to Claude, Cursor, VS Code or any MCP client through Apify's MCP server:

```
https://mcp.apify.com/?actors=toowl/pdf-password-protect
```

The agent can then pass file URLs and read the results itself.

### More toowl file APIs

Speech to text & subtitles, AI vocal remover, text to speech, AI object remover, PDF to Markdown, PDF to Word & Excel, HTML/URL to PDF, OCR, Office to PDF, PDF compressor, PDF merge/split, PDF password protect, PDF to image, image to PDF, bulk watermark, image converter and compressor, background remover, AI upscaler, image to SVG, QR code and barcode generators, QR/barcode reader, favicon generator, video compressor, frame extractor and audio converter. All pay per file, all batch-friendly: [toowl.my.id/en/api](https://toowl.my.id/en/api/).

Questions or a format that fails? Open an issue on the Actor's **Issues** tab.

# Actor input Schema

## `operation` (type: `string`):

Protect adds a password and permissions; unlock removes them (you need the open password if the PDF asks for one).

## `files` (type: `array`):

Direct links to PDFs. Through the API each item can carry its own password: { "url": "…", "password": "…" }.

## `password` (type: `string`):

Protect: the password that will open the PDFs. Unlock: the password that opens them now. Used for every file without its own.

## `passwords` (type: `object`):

Optional map of PDF URL → password, e.g. one password per employee payslip.

## `restrictOnly` (type: `boolean`):

The PDF opens for anyone, but printing/copying/editing follow the permissions below.

## `allowPrint` (type: `boolean`):

Readers may print the PDF.

## `allowCopy` (type: `boolean`):

Readers may select and copy content.

## `allowModify` (type: `boolean`):

Readers may change the document.

## `allowAnnotate` (type: `boolean`):

Readers may add comments and highlights.

## `allowForms` (type: `boolean`):

Readers may fill in form fields.

## `allowAssemble` (type: `boolean`):

Readers may insert, rotate or delete pages.

## `ownerPassword` (type: `string`):

Guards the permissions. Leave empty for a random one nobody knows (the safest choice).

## `zip` (type: `boolean`):

Also saves pdfs.zip with every result.

## `maxFileSizeMb` (type: `integer`):

Larger files are skipped with an error (not charged).

## Actor input object example

```json
{
  "operation": "protect",
  "files": [
    {
      "url": "https://raw.githubusercontent.com/chalidade/tools/main/apify/samples/report.pdf"
    }
  ],
  "restrictOnly": false,
  "allowPrint": true,
  "allowCopy": false,
  "allowModify": false,
  "allowAnnotate": false,
  "allowForms": true,
  "allowAssemble": false,
  "zip": true,
  "maxFileSizeMb": 100
}
```

# Actor output Schema

## `results` (type: `string`):

One row per input PDF, with a link to the protected or unlocked file.

## `files` (type: `string`):

Result PDFs and pdfs.zip in the default key-value store, plus a SUMMARY record.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "files": [
        {
            "url": "https://raw.githubusercontent.com/chalidade/tools/main/apify/samples/report.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("toowl/pdf-password-protect").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "files": [{ "url": "https://raw.githubusercontent.com/chalidade/tools/main/apify/samples/report.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("toowl/pdf-password-protect").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "files": [
    {
      "url": "https://raw.githubusercontent.com/chalidade/tools/main/apify/samples/report.pdf"
    }
  ]
}' |
apify call toowl/pdf-password-protect --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,toowl/pdf-password-protect"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/LgcmeY7o1mSqn9XVP/builds/6sd6TpAzNWOQae3qE/openapi.json
