# Ocr And Documents

Extract text from PDFs, images, scans, and Word documents using Python libraries and...

- Repository: https://github.com/taracodlabs/aiden (868 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-19
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add taracodlabs/aiden --skill ocr-and-documents -g -a claude-code -y`
Codex: `npx skills add taracodlabs/aiden --skill ocr-and-documents -g -a codex -y`
Cursor: `npx skills add taracodlabs/aiden --skill ocr-and-documents -g -a cursor -y`
Gemini CLI: `npx skills add taracodlabs/aiden --skill ocr-and-documents -g -a gemini-cli -y`

## Description

Extract text from PDFs, images, scans, and Word documents using Python libraries and CLI tools

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# OCR and Document Text Extraction

Extract readable text from PDFs, scanned images, and Word documents using Python libraries available in most environments. No cloud API required.

## When to Use

- User wants to read text from a PDF file
- User wants to extract text from a scanned image or photo of a document
- User wants to read a `.docx` Word document programmatically
- User wants to convert a multi-page document to plain text for analysis
- User wants to extract specific pages or sections from a PDF

## How to Use

### 1. Extract text from a PDF (pymupdf, fastest)

```python
import fitz  # pip install pymupdf

doc  = fitz.open("document.pdf")
text = "\n\n".join(page.get_text() for page in doc)
print(text[:2000])  # preview first 2000 chars
doc.close()
```

### 2. Extract text from a PDF (pdf-parse via Node.js)

```javascript
// requires: npm install pdf-parse (already in DevOS dependencies)
const pdfParse = require('pdf-parse')
const fs       = require('fs')
const data     = await pdfParse(fs.readFileSync('document.pdf'))
console.log(data.text.slice(0, 2000))
console.log(`Pages: ${data.numpages}`)
```

### 3. OCR a scanned image (Tesseract)

Requires Tesseract installed: `winget install UB-Mannheim.TesseractOCR`

```python
import pytesseract          # pip install pytesseract
from PIL import Image       # pip install Pillow

img  = Image.open("scan.png")
text = pytesseract.image_to_string(img, lang="eng")
print(text)
```

### 4. OCR with preprocessing for better accuracy

```python
import pytesseract
from PIL import Image, ImageFilter, ImageOps

img = Image.open("scan.jpg")
img = ImageOps.grayscale(img)
img = img.filter(ImageFilter.SHARPEN)
img = img.point(lambda p: 255 if p > 128 else 0)  # binarize
text = pytesseract.image_to_string(img, config="--psm 6")
print(text)
```

### 5. Extract text from a Word .docx file

```python
from docx import Document   # pip install python-docx

The rest: https://github.com/taracodlabs/aiden/blob/HEAD/workspace-templates/skills/ocr-and-documents/SKILL.md
