Skills

Ocr And Documents

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

Install

npx skills add taracodlabs/aiden --skill ocr-and-documents -g -a claude-code -y
Repository
taracodlabs/aiden868
Category
Engineering
Updated
16d ago
License
Apache-2.0
Context cost
Lightabout 867 tokens
Runs scripts
No, instructions only

What it does

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

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)

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)

// 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

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

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

from docx import Document   # pip install python-docx
Read the whole SKILL.md on GitHub

More in Engineering