# PDF Operations Toolkit (`nexgenwatch/pdf-operations-toolkit`) Actor

Runs split / merge / reorder / compress / rasterize on supplied PDFs and returns a per-operation manifest reconciling every input page to an output page (no silent page loss), with per-artifact SHA-256, byte-size delta, and warnings. Artifacts written to the run key-value store.

- **URL**: https://apify.com/nexgenwatch/pdf-operations-toolkit.md
- **Developed by:** [NexGen Watch](https://apify.com/nexgenwatch) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $33.50 / 1,000 pdf operations toolkit verdicts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Operations Toolkit

Runs split / merge / reorder / compress / rasterize on supplied PDFs and returns, per operation, a manifest that RECONCILES every input page to an output page (no silent page loss) plus per-artifact SHA-256, a byte-size delta, and warnings. Output artifacts are written to the run key-value store.

### What you submit

`operations` — pdf operations. Each operation is an object: {op, inputs, params}. op is split | merge | reorder | compress | rasterize. inputs is a list of PDFs, each a base64 string (optionally a data: URL) or a key naming an entry in the run key-value store. Every completed operation emits a manifest that RECONCILES input pages to output pages (no silent page loss), with per-artifact SHA-256, byte-size delta, and warnings; output artifacts are written to the run key-value store. Untrusted-file guards: byte-size and page ceilings, a decompression-bomb guard, encrypted/corrupted inputs rejected loudly, and embedded JavaScript / auto-actions reported as warnings, never executed. One charge per completed, reconciled operation.

### Untrusted-file guards

Every input PDF is treated as untrusted: a per-file byte-size cap and a page cap reject oversized inputs before work, a decompression-bomb guard applies, encrypted and corrupted PDFs are rejected loudly, and embedded JavaScript / auto-actions (`/JavaScript`, `/JS`, `/OpenAction`, `/Launch`, `/AA`) are **reported as warnings, never executed**.

### Output & billing

One row per operation. An operation bills **once if it completes AND its page map fully reconciles input pages to output** (no silent loss). A guard rejection (oversized / encrypted / corrupted / bad op) or an operation that would drop pages is delivered as an unbilled `rejected` status. Push-then-charge: every row is delivered **before** its charge, so a billing hiccup can only ever undercharge.

### Pricing

| Event | Price | When |
| --- | --- | --- |
| `apify-actor-start` | $0.02 | once when the run starts (reserved; never charged in code) |
| `pdf_operation_check` | $0.05 | once per **completed, page-reconciled operation** (rejected / non-reconciling operations never bill) |

Volume tiers reduce the per-verdict price as usage grows: $0.05 → $0.045 → $0.04 → $0.0335.

### Why this and not the obvious alternative

split / merge / reorder / compress / rasterize with a page-map that reconciles every input page to an output page (no silent loss) plus per-artifact hashes and a size-delta ledger — an evidence-grade PDF operations toolkit, not a black-box converter.

# Actor input Schema

## `operations` (type: `array`):

Each operation is an object: {op, inputs, params}. op is split | merge | reorder | compress | rasterize. inputs is a list of PDFs, each a base64 string (optionally a data: URL) or a key naming an entry in the run key-value store. Every completed operation emits a manifest that RECONCILES input pages to output pages (no silent page loss), with per-artifact SHA-256, byte-size delta, and warnings; output artifacts are written to the run key-value store. Untrusted-file guards: byte-size and page ceilings, a decompression-bomb guard, encrypted/corrupted inputs rejected loudly, and embedded JavaScript / auto-actions reported as warnings, never executed. One charge per completed, reconciled operation.

## `maxBytes` (type: `integer`):

Reject any single input PDF larger than this (decompression-bomb guard).

## `maxPages` (type: `integer`):

Reject inputs with more pages than this.

## `rasterizeDpi` (type: `integer`):

Render resolution for the rasterize op.

## `userAgent` (type: `string`):

Override the transparent crawler UA.

## Actor input object example

```json
{
  "operations": [
    {
      "op": "split",
      "inputs": [
        "<base64-or-kvs-key>"
      ],
      "params": {
        "ranges": [
          [
            1,
            1
          ]
        ]
      }
    }
  ],
  "maxBytes": 52428800,
  "maxPages": 1000,
  "rasterizeDpi": 150,
  "userAgent": "Mozilla/5.0 (compatible; NexGenWatchBot/1.0; +https://apify.com/nexgenwatch)"
}
```

# Actor output Schema

## `results` (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 = {
    "operations": [
        {
            "op": "split",
            "inputs": [
                "<base64-or-kvs-key>"
            ],
            "params": {
                "ranges": [
                    [
                        1,
                        1
                    ]
                ]
            }
        }
    ],
    "maxBytes": 52428800,
    "maxPages": 1000,
    "rasterizeDpi": 150,
    "userAgent": "Mozilla/5.0 (compatible; NexGenWatchBot/1.0; +https://apify.com/nexgenwatch)"
};

// Run the Actor and wait for it to finish
const run = await client.actor("nexgenwatch/pdf-operations-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 = {
    "operations": [{
            "op": "split",
            "inputs": ["<base64-or-kvs-key>"],
            "params": { "ranges": [[
                        1,
                        1,
                    ]] },
        }],
    "maxBytes": 52428800,
    "maxPages": 1000,
    "rasterizeDpi": 150,
    "userAgent": "Mozilla/5.0 (compatible; NexGenWatchBot/1.0; +https://apify.com/nexgenwatch)",
}

# Run the Actor and wait for it to finish
run = client.actor("nexgenwatch/pdf-operations-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 '{
  "operations": [
    {
      "op": "split",
      "inputs": [
        "<base64-or-kvs-key>"
      ],
      "params": {
        "ranges": [
          [
            1,
            1
          ]
        ]
      }
    }
  ],
  "maxBytes": 52428800,
  "maxPages": 1000,
  "rasterizeDpi": 150,
  "userAgent": "Mozilla/5.0 (compatible; NexGenWatchBot/1.0; +https://apify.com/nexgenwatch)"
}' |
apify call nexgenwatch/pdf-operations-toolkit --silent --output-dataset

```

## MCP server setup

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