# PDF Toolkit: Merge, Split, Compress, Images to/from PDF (`quicktools/pdf-toolkit`) Actor

Merge PDFs, split by page ranges, compress (re-encode and downscale images), convert JPG/PNG images to PDF, and render PDF pages to PNG or JPEG. Upload files or give URLs; download links in the results. Pay per output.

- **URL**: https://apify.com/quicktools/pdf-toolkit.md
- **Developed by:** [T O](https://apify.com/quicktools) (community)
- **Categories:** Developer tools, Automation, Integrations
- **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 pdfs

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, Compress, Images to PDF, PDF to Images

Five everyday PDF jobs in one Actor, for **automations, back-office workflows and AI pipelines**: **merge PDFs**, **split by page ranges**, **compress** large scanned PDFs, turn **JPG/PNG images into a PDF**, and **render PDF pages to PNG or JPEG**. Upload files or give URLs; every output file gets a download link.

### Operations

| Operation | What it does | Output |
|---|---|---|
| **Merge** | Joins all files in the order given (bookmarks of each file kept) | 1 PDF |
| **Split** | `1-3,5,8-` style ranges; one PDF per page or one per range | 1 PDF per page/range |
| **Compress** | Re-encodes and downscales embedded images (quality and max size configurable), compresses page streams, removes duplicate objects | 1 smaller PDF per input |
| **Images to PDF** | JPEG, PNG, WebP, TIFF, GIF, BMP → one page each; A4 or Letter (auto landscape, fit with margin) or image size; EXIF rotation honored, transparency on white | 1 PDF |
| **PDF to images** | Renders pages to PNG or JPEG at 36–300 DPI | 1 image per page |

Password-protected PDFs work if you provide the password. Outputs are never encrypted.

### Input examples

```json
{ "operation": "merge", "fileUrls": ["https://example.com/a.pdf", "https://example.com/b.pdf"], "outputFileName": "combined" }
```

```json
{ "operation": "split", "fileUrls": ["https://example.com/report.pdf"], "pageRanges": "1-6,7-12", "splitMode": "ranges" }
```

```json
{ "operation": "pdfToImages", "fileUrls": ["https://example.com/slides.pdf"], "pageRanges": "1-3", "imageFormat": "png", "dpi": 150 }
```

### Output example (one dataset row per output file)

```json
{
  "operation": "compress",
  "status": "ok",
  "fileName": "scan-3p.pdf",
  "pages": 3,
  "inputBytes": 13082035,
  "bytes": 679160,
  "savedPercent": 94.8,
  "imagesRecompressed": 3,
  "outputKey": "a1b2c3d4-scan-3p-compressed.pdf",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/a1b2c3d4-scan-3p-compressed.pdf"
}
```

### Pricing (pay per event)

| Event | Price | Operations |
|---|---|---|
| PDF (output file) | **$0.003** | Merge, Compress, Images to PDF |
| Page (output page) | **$0.002** | Split, PDF to images |

Examples: merging 10 PDFs = **$0.003**; compressing 100 PDFs = **$0.30**; splitting a 20-page PDF into pages = **$0.04**. **Free:** failed files, wrong passwords, and compressions that save less than 1% (the PDF was already optimized — you get a `no_savings` row and pay nothing).

### Limits

- 50 MB per file by default (max 100 MB), 200 files and 500 pages per run by default (max 2,000).
- Rendering is capped at ~40 megapixels per page.
- Compression works on image-heavy PDFs (scans, photos). Text-only PDFs are usually already small.
- No OCR or text extraction — for that, use our *Office & PDF to Markdown for AI* Actor.

### FAQ

**Does it use an external API?** No. Everything runs inside the Actor with open-source pypdf, PDFium and Pillow.

**Where are my files?** In the run's default key-value store, linked from each result row. Download them before your storage retention period ends.

**Is my data private?** Files are processed only inside your own run.

### About

Built with AI assistance by QuickTools and tested on real sample PDFs before release. Something off? Open an issue on the Issues tab.

# Actor input Schema

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

Merge: all files into one PDF (in the order given). Split: page ranges into separate PDFs. Compress: smaller PDFs. Images to PDF: one PDF, one image per page. PDF to images: render pages to PNG/JPEG.

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

Upload files or paste public URLs. PDFs for merge/split/compress/PDF to images; JPEG, PNG, WebP, TIFF, GIF or BMP for Images to PDF.

## `fileUrls` (type: `array`):

Public file URLs, one per line, combined with the field above (in order). Up to 200 files.

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

e.g. 1-3,5,8- or last. Empty = all pages.

## `splitMode` (type: `string`):

Each page: one PDF per page. Ranges: one PDF per comma-separated range (1-3,4-6 gives two files).

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

PNG is lossless; JPEG is smaller for photos and scans.

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

150 is good for screens, 300 for print/OCR. Very large pages are capped at about 40 megapixels.

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

Used for JPEG page images and for Images to PDF.

## `pageSize` (type: `string`):

Images are scaled to fit with a small margin and never cropped.

## `outputFileName` (type: `string`):

Without extension. Default: merged / images.

## `compressImageQuality` (type: `integer`):

JPEG quality for re-encoded images inside the PDF. Lower = smaller.

## `compressMaxImagePx` (type: `integer`):

Images inside the PDF larger than this (longest side) are downscaled. 1600 px is about 200 DPI on a letter page.

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

For password-protected PDFs you are allowed to open. Outputs are not encrypted.

## `maxPagesPerRun` (type: `integer`):

Safety cap on the total pages processed in one run.

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

Larger files are skipped and not billed.

## Actor input object example

```json
{
  "operation": "merge",
  "fileUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "splitMode": "eachPage",
  "imageFormat": "png",
  "dpi": 150,
  "jpegQuality": 85,
  "pageSize": "A4",
  "compressImageQuality": 60,
  "compressMaxImagePx": 1600,
  "maxPagesPerRun": 500,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

## `overview` (type: `string`):

One item per output file (or failed input): operation, pages, sizes and download URL.

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

All output PDFs and images in the default key-value store.

# 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 = {
    "fileUrls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("quicktools/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 = { "fileUrls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("quicktools/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 '{
  "fileUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call quicktools/pdf-toolkit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,quicktools/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/G6a5QFogJrBX9ZMOE/builds/b8zuWYc3D3ft1etuP/openapi.json
