# PDF Toolkit — Merge, Split, Rotate, Compress, PDF to Image (`openregistry/pdf-toolkit`) Actor

All-in-one PDF tools by URL: merge PDFs, split by ranges or every N pages, extract or rotate pages, lossless compression, convert pages to PNG/JPEG, read page count and metadata. Download links for every file. Pay per file.

- **URL**: https://apify.com/openregistry/pdf-toolkit.md
- **Developed by:** [Mahé Perrin](https://apify.com/openregistry) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 pdf files

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/running/actors-in-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 Toolkit — Merge, Split, Extract, Rotate, Compress, PDF to Image

Everyday PDF jobs as an API: **merge PDFs, split a PDF, extract or rotate pages, shrink a PDF, convert pages to PNG or
JPEG, and read page count and metadata**. Give a list of PDF links, pick an operation, and get a download link for
every file produced, plus one clean result row per document.

**$0.003 per PDF file, $0.002 per page image.** No API key, no subscription, no watermark; failed files are not
charged.

### What it does

| Operation | Result |
|---|---|
| `merge` | One PDF with all files joined in the order given (the same file can appear twice) |
| `split` | One PDF per range (`1-3, 4-10, 11-end`), per block of N pages, or per page |
| `extract` | A new PDF with only the pages you list, in your order (`5, 1-3`) |
| `rotate` | The same PDF with the chosen pages turned 90°, 180° or 270° |
| `compress` | A lossless rewrite (object streams, unused objects dropped); if no smaller file can be made you get the original and pay nothing |
| `toImages` | One PNG or JPEG per page at 72–600 DPI (150 by default), white background |
| `info` | Page count, page size in points and millimetres (A4, Letter…), orientation, title, author, subject, keywords, creator, producer, dates, PDF version, encryption |

Every row also carries the page count and file size of the input.

### Input

| Field | What it does |
|---|---|
| `pdfUrls` | Direct public links to PDF files (up to 100 MB each) |
| `operation` | `info` (default), `merge`, `split`, `extract`, `rotate`, `compress`, `toImages` |
| `pageRanges` | Pages to use: `1-3, 5, 8-` or `10-end`. Empty = all pages (required for `extract`) |
| `splitEvery` | Split into files of N pages when no ranges are given (0 or 1 = one file per page) |
| `rotation` | `90`, `180` or `270` (clockwise, added to the current rotation) |
| `imageFormat`, `dpi`, `jpegQuality` | Image options for `toImages` |
| `outputName` | Name of the merged file |
| `maxFiles` | Stops the run after this many input PDFs |

```json
{
  "pdfUrls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf", "https://www.irs.gov/pub/irs-pdf/fw4.pdf"],
  "operation": "merge",
  "outputName": "tax-forms"
}
```

```json
{ "pdfUrls": ["https://www.irs.gov/pub/irs-pdf/p17.pdf"], "operation": "toImages", "pageRanges": "1-5", "dpi": 150 }
```

### Output

Files are saved in the run's key-value store; every row gives their **public download links**.

| Field | Example |
|---|---|
| `pdfUrl`, `operation` | the input and what was done |
| `outputUrl`, `outputKey` | link and key of the produced PDF (`merge`, `extract`, `rotate`, `compress`) |
| `parts` | `split`: `[{ "pages": "1-20", "pageCount": 20, "url": "…", "sizeBytes": 412345 }]` |
| `images` | `toImages`: `[{ "page": 1, "url": "…/001-p17-page-001.png", "sizeBytes": 222839 }]` |
| `pageCount`, `outputPageCount`, `fileSizeBytes`, `outputSizeBytes`, `savedPercent` | 142, 20, 3088632… |
| `title`, `author`, `producer`, `creationDate`, `firstPageSize`, `pdfVersion`, `encrypted` | `info` fields |
| `error` | only on failed rows (not charged) |

Download the table as JSON, CSV or Excel, or call the Actor from the API, Make, Zapier or n8n and fetch the files from
the links.

### Pricing

Pay per event:

| Event | Price | Counted |
|---|---|---|
| PDF file | $0.003 | each input analysed (`info`), merged, extracted, rotated or compressed; each file produced by `split` |
| Page image | $0.002 | each page rendered by `toImages` |

Examples: merging 10 PDFs costs $0.03; splitting a 100-page PDF into 10 files costs $0.03; 50 page images cost $0.10.
Not charged: invalid links, web pages instead of PDFs, damaged or unreadable files, failed downloads, pages that could
not be rendered, and `compress` when no smaller file is possible. If you set a maximum charge per run, files that would
go over it are skipped before processing.

### Good to know

- **Encrypted PDFs**: `info` and `toImages` work on PDFs that open without a password; editing operations refuse
  password-protected or encrypted files.
- **Compression is lossless**: it rewrites the PDF structure and does not lower image quality. Typical savings are
  0–30 %; already optimised files stay as they are (not charged).
- Pages are rendered with the standard PDF fonts bundled, so documents without embedded fonts display correctly.
  Very large pages are capped at 40 megapixels per image. Up to 500 images per PDF in one run.
- Built on open-source libraries only: pdf-lib (MIT) for editing, Mozilla pdf.js (Apache-2.0, through unpdf, MIT) and
  @napi-rs/canvas (MIT) for rendering. Your files are processed inside the Actor and not sent to any third-party API.
- Only process documents you have the right to use; personal data they contain stays under your responsibility (GDPR).

# Actor input Schema

## `pdfUrls` (type: `array`):

Direct public links to PDF files (up to 100 MB each). For a merge, the files are joined in this order; the same file may appear several times.

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

What to do with the PDFs. Every operation also returns the page count and file size of each input.

## `pageRanges` (type: `string`):

Pages to use, for example 1-3, 5, 8- or 10-end. Split: each range becomes its own file. Extract (required): the pages kept, in this order. Rotate and images: the pages concerned. Empty = all pages.

## `splitEvery` (type: `integer`):

Split only, when Pages is empty: cut the document into files of N pages. 0 or 1 = one file per page.

## `rotation` (type: `string`):

Rotate only: angle added to the current rotation of the selected pages.

## `imageFormat` (type: `string`):

Images only: file format of the rendered pages.

## `dpi` (type: `integer`):

Images only: 72 = screen preview, 150 = good reading quality (default), 300 = print. Very large pages are capped at 40 megapixels.

## `jpegQuality` (type: `integer`):

Images only, JPEG: 30 (smallest) to 100 (best).

## `outputName` (type: `string`):

Merge only: name of the merged PDF (letters, digits and dashes are kept).

## `maxFiles` (type: `integer`):

Stop after this many input PDFs. To cap the cost, also set the maximum charge per run in Apify.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "operation": "info",
  "splitEvery": 0,
  "rotation": "90",
  "imageFormat": "png",
  "dpi": 150,
  "jpegQuality": 85,
  "outputName": "merged",
  "maxFiles": 100
}
```

# Actor output Schema

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

No description

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

No description

# 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 = {
    "pdfUrls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("openregistry/pdf-toolkit").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 = { "pdfUrls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("openregistry/pdf-toolkit").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 '{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ]
}' |
apify call openregistry/pdf-toolkit --silent --output-dataset

```

## MCP server setup

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

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/r09P7jKSSF1mP3kjn/builds/BNZzmRKVvDpdh8D79/openapi.json
