# PDF Page Integrity Packager — Mapping & Hash Evidence (`damdamdoom/pdf-page-integrity-packager`) Actor

Rebuild up to three PDF page packages from one or two inline PDFs with deterministic mapping and integrity hashes.

- **URL**: https://apify.com/damdamdoom/pdf-page-integrity-packager.md
- **Developed by:** [Masatoshi Shimada](https://apify.com/damdamdoom) (community)
- **Categories:** Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## PDF Page Integrity Packager — Mapping & Hash Evidence

Rebuild pages from one or two inline Base64 PDFs into up to three packages, preserving requested selection, order, duplicates, merge/split, and 90-degree rotations together with source-to-output mapping and SHA-256 evidence. Runtime network and filesystem operations are always zero.

Input contains only `sources[].pdfBase64` and `packages[].pages[]` with `sourceIndex`, 1-based `pageNumber`, and clockwise `rotate` (`0|90|180|270`). Canonical standard RFC 4648 Base64 is required. URLs, paths, passwords, metadata, output names, unknown fields, and boolean integers are rejected.

### Fixed boundary

- one or two sources, 2 MiB decoded total, 50 source pages total
- one to three packages, one to 50 page references each
- 4 MiB total output Base64
- resolved graph: 10,000 objects and depth 64 per scan
- in-memory `BytesIO` only; no temporary file, external request, Browser, Proxy, or Secret

Before copying, the Actor strictly parses the PDF and resolves its forward object graph. Encrypted, malformed, incomplete, zero-page, over-limit, unresolved, unknown, or unsafe cyclic graphs fail. Any action dictionary or Additional Action, OpenAction, JavaScript, Launch, SubmitForm, ImportData, RichMedia/multimedia, AcroForm/XFA, attachment, EmbeddedFiles/EF/AF, FileAttachment, or unknown action type fails without output or charge.

Only page content, resources, MediaBox/CropBox and related page boxes, and normalized rotation are copied into a new empty writer. Annotations are inspected before removal and are never inherited. Source metadata, outline/bookmarks, forms, attachments, name trees, open actions, transition/structure keys, and other page keys are not inherited. Output is parsed and scanned again before the single Dataset item is pushed.

`sourcePdfHash` hashes decoded source bytes. `packageId` hashes all source hashes plus requested page references. `mappingHash` hashes the output-order mapping, and `outputPdfHash` hashes rebuilt PDF bytes. pypdf output is deterministic for the same fixed input, actor parser, and dependency version.

Annotation removal is reported only as `PAGE_ANNOTATIONS_REMOVED` plus a count. Raw source Base64/binary, PDF objects, text, images, and metadata are not emitted or normally logged. Successful output necessarily retains source page content, which may contain PII or confidential information. This is not a redaction, signature-preservation, malware-analysis, OCR, extraction, repair, or compression product.

### Dependency gate and local verification

Official PyPI JSON checked 2026-08-15: `pypdf==6.16.1`, BSD-3-Clause, Python >=3.9, non-yanked pure-Python `py3-none-any` wheel, and no default runtime dependency on Python 3.14. A synthetic in-memory gate verified deterministic copy/reorder/rotation, annotation removal, document-level non-inheritance, unsafe-marker rejection, and unresolved/cycle/depth/object fail-closed handling. The initial probe also found that `PageObject.rotate()` can retain 360, so the Actor explicitly writes `(sourceRotation + rotate) % 360`.

```
..\..\.venv\Scripts\python.exe -m unittest discover -s tests -v
..\..\.venv\Scripts\python.exe tools/local_actor_smoke.py
```

Valid requests create exactly one default Dataset item and one built-in `apify-default-dataset-item`; all failures create zero. No actor-start or custom PPE event is used.

Unapproved pricing hypothesis: $0.005 per successful summary Dataset item, at most $0.005/run. Real-PDF compatibility, signed-PDF impact, Cloud memory/cold-start/cost, demand, revenue, profit, margin, and break-even remain null.

# Actor input Schema

## `sources` (type: `array`):

One or two inline PDF sources, with decoded bytes limited to 2 MiB total.

## `packages` (type: `array`):

One to three ordered page packages to rebuild.

## Actor input object example

```json
{}
```

# Actor output Schema

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

Rebuilt PDF Base64, page mappings, warnings, hashes, and parser provenance.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("damdamdoom/pdf-page-integrity-packager").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("damdamdoom/pdf-page-integrity-packager").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 '{}' |
apify call damdamdoom/pdf-page-integrity-packager --silent --output-dataset

```

## MCP server setup

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

```

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/CH0x9sJ3MVjoIAbKr/builds/8cP30gTcDA4rrRLBr/openapi.json
