Etherdancer

Software Developer & Creator

← Back to Portfolio

How I Built OffGridDoc: An Offline OCR Document Redactor

Published: July 2026  |  Etherdancer

React Vite Tesseract.js PDF.js Offline PWA Privacy Canvas API

What is OffGridDoc?

OffGridDoc is a free, 100% offline Progressive Web App for redacting sensitive information from documents — PDFs and images alike. The core idea is simple: you should be able to strip private data from a scanned document without uploading it anywhere.

The flagship feature is automatic OCR-powered redaction. You press a single button and the app uses Tesseract.js — a full OCR engine running in your browser — to scan the document for Personally Identifiable Information (PII) and black it out automatically. No server. No API call. Zero bytes leave your device.

The hard rule that shaped everything: every single byte of processing happens client-side. If anything had to touch a server, the project would be a failure.

The Problem I Wanted to Solve

Most document redaction tools fall into one of two categories: expensive desktop software (Adobe Acrobat) or sketchy online tools that upload your file to a third-party server. Neither is great when you're dealing with scanned IDs, medical records, or legal paperwork that contain names, addresses, dates of birth, and phone numbers.

I wanted a tool that was completely trustworthy by design — not because of a privacy policy, but because it is architecturally impossible to exfiltrate your data when there's no network connection involved.

Redaction Tools

The app has four redaction modes:

🖌 BrushFree-hand painting redaction. Draw directly over text.
➖ LineRedact a full horizontal line with adjustable thickness.
⬜ AreaDraw a resizable rectangle around a region. Confirm to apply.
✨ Auto-RedactOCR scans the document and blacks out PII automatically.

All four tools write directly to an HTML Canvas layer that sits on top of the rendered PDF or image. Undo/Redo is fully supported via a history stack of ImageData snapshots.

The Technical Core: OCR Auto-Redaction

The auto-redact feature is the most complex part. Here's how it works end-to-end:

  1. The current page is rendered to a Canvas using PDF.js.
  2. That canvas is passed as an image to Tesseract.js, which runs optical character recognition entirely in a Web Worker.
  3. Tesseract returns not just the text, but per-word bounding boxes — exact pixel coordinates of where each word sits on the page.
  4. A set of regex patterns checks each detected word/group against known PII patterns.
  5. Any match gets its bounding box filled with solid black on the canvas.

Multilingual PII Patterns

Documents from different countries use different field labels. A Croatian ID card says Ime i prezime, a German one says Name, a French one says Nom. The auto-redact engine handles 40+ languages worth of field labels for categories including:

The OCR language can also be set manually — supporting over 100 languages via Tesseract's language packs, which are downloaded on demand.

Handling Scanned PDFs vs Digital PDFs

This was one of the trickier engineering problems. A digital PDF has real text layer data — PDF.js can extract text positions directly. A scanned PDF is just a sequence of rasterised images: there's no text layer at all. OCR is the only way to extract information from it.

OffGridDoc handles both: it renders every PDF page to Canvas (making it image-based by default) and runs Tesseract on the result. This means even digital PDFs with perfect text layers go through OCR, which is actually an advantage — it ensures consistent bounding box coordinates that align with what's drawn on screen.

Metadata Stripping

Redacting visible text is only half the story. Images often contain hidden EXIF metadata — GPS coordinates, device serial numbers, timestamps, camera model. OffGridDoc uses piexifjs to strip all EXIF data from JPEG exports before download. For PNGs and PDFs, the re-render through Canvas naturally discards any embedded metadata.

Export

Once redaction is done, the user exports the result. Supported formats:

Tech Stack

Try It

OffGridDoc is completely free and open source. Load a PDF or image, use the brush or press the auto-redact wand, and export a clean file. Your document never leaves your machine.

Try OffGridDoc live