PDF Redaction

PDF redaction library for Python and JavaScript

Find and redact PII in PDFs from your own code. ScaleDP (Python) and ScaleDP-TS (JavaScript) chain OCR for scanned PDFs, AI entity detection and redaction in one pipeline, on your own servers or entirely in the browser.

Open source under the AGPL-3.0 license

Python
pip install scaledp
JavaScript / TypeScript
npm install @stabrise/scaledp

Redact PDFs in Python with ScaleDP

ScaleDP is an open-source Python library for document AI pipelines. Load PDFs into a Pandas or Spark DataFrame, run OCR, and detect PII with NER models to find what needs redacting.

AI-Powered Redaction

Automatically detects and redacts PII like names, locations, emails, and dates.

Context-Aware Accuracy

Leverages advanced AI to understand context and make precise redactions.

Scanned Documents (OCR)

Built-in OCR with Tesseract, EasyOCR, Surya or docTR detects and redacts text in scanned images and PDFs.

Runs Locally or on Spark

Use it as a plain Python library on one machine, or scale the same pipeline out on Apache Spark to redact thousands of documents.

Multilingual

Works with common languages: English, Spanish, German, Italian, Russian and more.

Fits Your Data Stack

Works with Pandas and Spark DataFrames, so redaction plugs into existing data workflows and machine learning pipelines.

Python example: OCR and PII detection

pip install scaledp
from scaledp import *

spark = ScaleDPSession()

pipeline = PipelineModel(stages=[
    PdfDataToImage(),
    TesseractOcr(),
    Ner(model="d4data/biomedical-ner-all"),
])

result = pipeline.transform(df)

Redact PDFs in JavaScript, right in the browser

ScaleDP-TS is the TypeScript sibling of ScaleDP. Install @stabrise/scaledp and the same kind of pipeline runs client-side in modern HTML5 browsers on onnxruntime-web, so documents are never uploaded.

No Upload, No Server

Documents never leave the browser. OCR, NER and redaction all run client-side.

Runs on onnxruntime-web

Models execute locally over WebAssembly or WebGPU, with no server round-trip.

Browser-Based OCR

PaddleOCR text recognition detects text in scanned images and PDFs.

Zero-Shot NER

GLiNER lets you define entity types like "person" or "email" at call time, with no retraining.

Signature & Face Detection

YOLO-based detectors locate signatures and faces for redaction.

Modular & Composable

Import only what you need (/pdf, /ocr, /ner, /detect) and chain stages with a simple Pipeline API.

TypeScript example: OCR and PII detection in the browser

npm install @stabrise/scaledp
import { Pipeline } from '@stabrise/scaledp'
import { PdfToImage } from '@stabrise/scaledp/pdf'
import { PaddleTextRecognizer } from '@stabrise/scaledp/ocr'
import { GlinerNer } from '@stabrise/scaledp/ner'

const pipeline = new Pipeline([
  new PdfToImage({ resolution: 300 }),
  new PaddleTextRecognizer({ preset: 'v6-small' }),
  new GlinerNer({ labels: ['person', 'email', 'phone'] }),
])

const rows = await pipeline.transform(file)

Library or API: Which Do You Need?

Open-source library

  • You run it: on your servers, your Spark cluster, or in the user's browser
  • Python (ScaleDP) or JavaScript and TypeScript (ScaleDP-TS)
  • Free under AGPL-3.0
  • You choose and manage the OCR and NER models

PDF Redaction API & SDK

  • Managed REST API, also available self-hosted
  • Call it from any language over HTTP
  • Free tier, then pay per page
  • Production-tuned detection of PII, signatures, photos and QR codes
See the PDF redaction API & SDK

How to redact a PDF in Python or JavaScript

Redacting a PDF in code takes three steps: get the text, find the sensitive parts, and remove them from the page. In a digital PDF the text is already in the file. A scanned PDF is an image, so the text has to come from OCR first. ScaleDP supports Tesseract, EasyOCR, Surya and docTR, so you can redact scanned PDFs in Python with the OCR engine that suits your documents.

Detection is where a library beats regular expressions. Patterns catch emails and phone numbers but miss names, addresses and medical terms. ScaleDP runs NER models from Hugging Face over the OCR output and returns each entity with its position on the page, ready for redaction. The same pipeline runs on one machine with Pandas, or across an Apache Spark cluster when you have thousands of files.

For web apps, ScaleDP-TS brings the pipeline to JavaScript and TypeScript. PDF rendering, PaddleOCR text recognition, GLiNER entity detection and YOLO signature and face detection all run in the browser over WebAssembly or WebGPU. Nothing is uploaded, which makes it a fit for HTML5 PDF redaction where documents must stay on the user's device.

Both libraries are free under AGPL-3.0, and you host and tune the models yourself. If you would rather call a managed service from any language, or keep AGPL obligations out of your codebase, use the PDF redaction API instead. For one-off documents, the online editor needs no code at all.

PDF redaction library FAQ

Is the PDF redaction library free and open source?
Yes. ScaleDP and ScaleDP-TS are open source under the GNU AGPL-3.0 license, so you can use, modify and self-host them for free. AGPL-3.0 requires that if you modify the code and make it available to others, including over a network, you share your changes under the same license.
How do I redact a PDF in Python?
Install ScaleDP with pip install scaledp and build a pipeline: convert PDF pages to images, run OCR (Tesseract, EasyOCR, Surya or docTR), and detect PII with an NER model. Each detected entity comes with its position on the page, which tells you which areas to black out. It runs on a single machine with Pandas or on Apache Spark.
Can I redact PDFs in the browser with JavaScript?
Yes. ScaleDP-TS (npm install @stabrise/scaledp) runs PDF rendering, OCR and entity detection client-side with onnxruntime-web, over WebAssembly or WebGPU. It works in modern HTML5 browsers, and documents never leave the user's device.
Should I use ScaleDP (Python) or ScaleDP-TS (JavaScript)?
Use ScaleDP for server-side and batch jobs in Python, on a single machine or scaled out on Apache Spark. Use ScaleDP-TS when documents must stay on the user's device: it runs OCR, PII detection and redaction in the browser with onnxruntime-web.
Do I need Apache Spark to use ScaleDP?
No. ScaleDP works as a regular Python library on a single machine with Pandas DataFrames. Apache Spark is optional and only needed when you want to distribute processing across a cluster.
Can the library redact scanned PDFs?
Yes. Both libraries include OCR. ScaleDP supports Tesseract, EasyOCR, Surya and docTR, and ScaleDP-TS runs PaddleOCR in the browser, so text in scanned pages and images can be detected and redacted.
Does ScaleDP-TS upload my documents to a server?
No. ScaleDP-TS runs entirely client-side: PDF rendering, OCR and entity recognition execute in the browser over WebAssembly or WebGPU. Only the model files are downloaded; your documents never leave the device.
When should I use the PDF redaction API instead of the library?
Choose the API if you want a managed service you can call from any programming language without hosting models yourself, or if you would rather not take on AGPL-3.0 obligations in your own codebase.

Build PDF redaction into your product

Need help fitting ScaleDP into your pipeline? Talk to the ML and data engineers who build it about OCR, PII detection and large document workloads.