# Krakt Blackt (`kurtholes/krakt-blackt`) Actor

Batch PDF redaction that actually deletes the text, not just a black box on top. Emails, phones, SSNs, cards, IBANs, your own terms and regex. Verified removal report per file. About $0.01 per file.

- **URL**: https://apify.com/kurtholes/krakt-blackt.md
- **Developed by:** [Kurt Holes](https://apify.com/kurtholes) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 1,000 file redacteds

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

## Krakt Blackt: PDF redaction that actually deletes the text

A black box drawn over a PDF hides nothing: select, copy, paste, and the "redacted" SSN is right there. Blackt **deletes the text underneath**, then re-opens the result and checks. **About $0.01 per file.**

- **Real removal**: PyMuPDF redaction annotations + `apply_redactions`. Glyphs are deleted from the content stream, the file is fully rewritten (no incremental-save leftovers).
- **Batch it**: 1 PDF or 1,000. URLs, an upload, or key-value store records.
- **Built-in PII presets**: emails, phone numbers, US SSNs, credit cards (Luhn-checked), IBANs (mod-97 checked).
- **Your own rules**: exact terms/phrases and Python regexes. Optional page ranges like `1-3,5,10-`.
- **Proof, not promises**: every file gets a removal report: counts by type, pages hit, and a verification pass that re-extracts the text and re-runs every search. `verified: true` means zero hits.
- **Metadata scrubbed** by default (title, author, keywords, XMP).
- **Pay for results**: failed downloads and broken PDFs are free.

### What it won't do (read this)

- **No OCR.** Scanned or image-only pages have no text to find, so nothing is redacted there. We flag them in `imageOnlyPages` so you know to check by hand.
- **Detection is pattern-based.** Presets catch common formats, not every format on earth. Names, addresses and free text need search terms or a regex.
- **Text must be extractable.** Weird font encodings or text drawn as vector paths can hide matches. Those show up as misses, not as errors, so spot-check sensitive files.
- **Phrases wrapped across lines** are found, but each word in the phrase is then removed wherever it appears on that page (we over-redact rather than leak).
- Password-protected PDFs are skipped. Annotations, form field values and attachments outside the matched areas are not touched.
- Verification proves the matched text no longer extracts. It is not a legal certification. Have a human review anything that goes to court.

### Quick start

```json
{
  "pdfUrls": ["https://example.com/contracts/acme.pdf"],
  "presets": ["emails", "phones", "ssns", "creditCards", "ibans"],
  "searchTerms": ["Project Nightingale", "Jane Doe"],
  "customRegexes": ["\\bEMP-\\d{6}\\b"],
  "pageRanges": "1-5"
}
```

| Field | Default | What it does |
|---|---|---|
| `pdfUrls` | – | Direct links to PDFs |
| `pdfUpload` | – | Upload one PDF from the Console |
| `kvStoreRecords` | – | `storeId/key` (or `key` for this run's store) |
| `presets` | all five | `emails`, `phones`, `ssns`, `creditCards`, `ibans` |
| `searchTerms` | – | Exact words or phrases |
| `customRegexes` | – | Python regexes |
| `caseSensitive` | `false` | Case-sensitive term matching |
| `pageRanges` | all | e.g. `1-3,5,10-` |
| `boxColor` | `black` | `black`, `white`, `navy` |
| `replacementLabel` | – | Text inside each box, e.g. `[REDACTED]` |
| `redactImageAreas` | `true` | Blank image pixels under boxes |
| `scrubMetadata` | `true` | Wipe document metadata |
| `maxFiles` / `maxFileSizeMb` | 100 / 50 | Safety caps |

### Output

Key-value store: `001-name-redacted.pdf` and `001-name-report.json` per file. Dataset: one row per file:

```json
{
  "fileName": "hr-record.pdf", "status": "redacted", "verified": true,
  "totalRedactions": 36,
  "redactionsByType": { "emails": 6, "phones": 6, "ssns": 3, "creditCards": 6, "ibans": 6, "terms": 9 },
  "pagesRedacted": [{ "page": 1, "redactions": 12 }],
  "verification": { "passed": true, "removedStringsStillExtractable": 0, "residualMatchesByType": {} },
  "imageOnlyPages": [], "redactedPdfUrl": "https://api.apify.com/v2/key-value-stores/.../records/001-hr-record-redacted.pdf"
}
```

`status` is `redacted`, `no-matches` (still a clean, metadata-scrubbed copy) or `failed`.

### Pricing

**$0.01 per processed file** (pay per event). Failed files cost nothing. A run with no PDFs given redacts one public sample form (IRS W-9) for free (`demo: true`) so you can see the output. The report itself never contains the removed values.

Built by Krakt.

# Actor input Schema

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

Direct links to PDF files (public or signed URLs). One per line.

## `pdfUpload` (type: `string`):

Drop a single PDF here.

## `kvStoreRecords` (type: `array`):

Optional. PDFs already in an Apify key-value store, as 'storeId/key' (or 'key' for this run's store).

## `presets` (type: `array`):

Built-in detectors. Cards are Luhn-checked and IBANs mod-97 checked to cut false positives.

## `searchTerms` (type: `array`):

Exact words or phrases to remove (names, project codenames, account numbers...).

## `customRegexes` (type: `array`):

Python regular expressions, e.g. \bEMP-\d{6}\b

## `caseSensitive` (type: `boolean`):

Off = 'acme' also removes 'ACME'.

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

Optional, 1-based: '1-3,5,10-'. Empty = all pages.

## `boxColor` (type: `string`):

Fill color of the redaction box.

## `replacementLabel` (type: `string`):

Optional text printed in each box, e.g. \[REDACTED].

## `redactImageAreas` (type: `boolean`):

If a match overlaps an image, blank those pixels too.

## `scrubMetadata` (type: `boolean`):

Wipe title, author, subject, keywords and XMP metadata.

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

Safety cap per run. Each processed file is billed once.

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

Bigger downloads are skipped.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "presets": [
    "emails",
    "phones",
    "ssns",
    "creditCards",
    "ibans"
  ],
  "caseSensitive": false,
  "boxColor": "black",
  "redactImageAreas": true,
  "scrubMetadata": true,
  "maxFiles": 100,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

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

No description

## `store` (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("kurtholes/krakt-blackt").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("kurtholes/krakt-blackt").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 kurtholes/krakt-blackt --silent --output-dataset

```

## MCP server setup

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

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/DLswP3Xdi0Unqvij0/builds/7YpNFi2C4Qf8orfVI/openapi.json
