How I Built OffGridDoc: An Offline OCR Document Redactor
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 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:
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:
- The current page is rendered to a Canvas using PDF.js.
- That canvas is passed as an image to Tesseract.js, which runs optical character recognition entirely in a Web Worker.
- Tesseract returns not just the text, but per-word bounding boxes — exact pixel coordinates of where each word sits on the page.
- A set of regex patterns checks each detected word/group against known PII patterns.
- 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:
- Full names (
name,ime i prezime,nom,nombre, etc.) - Dates of birth and all date formats (DD/MM/YYYY, MM-DD-YY, etc.)
- Phone numbers (international + local patterns)
- Email addresses (including OCR misreads like
&instead of@) - Addresses and place of residence
- Citizenship, nationality, gender
- Alphanumeric IDs (passport numbers, driving licence numbers)
- Postal codes and long numeric sequences
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:
- PDF — multi-page PDFs are reconstructed with jsPDF, one canvas image per page.
- PNG — lossless, no compression artefacts.
- JPEG — compressed, EXIF stripped.
Tech Stack
- React + TypeScript + Vite — fast build, tight types
- Tesseract.js — OCR engine running in a Web Worker
- PDF.js — PDF rendering to Canvas
- jsPDF — PDF reconstruction for export
- piexifjs — EXIF metadata stripping
- Canvas API — all drawing, redaction, and export happens here
- Vite PWA Plugin — Service Worker for full offline capability
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.