Converts PDF, DOCX, images, and scanned documents to clean, LLM-friendly text using OCR, pandoc, and Python libraries. Run before other skills when processing documents.
Ships in pinakdhabu-exam-prompt. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Base preprocessing skill — Converts any document format to clean, structured text that LLMs can process effectively. Must be run BEFORE any other skill (notes, answers, analysis, etc.) when working with documents.
LLMs cannot directly read:
This skill converts them all to clean text first.
| Format | Extension | Conversion Method | Notes |
|---|---|---|---|
| PDF (text-based) | .pdf | pdftotext or PyPDF2 | Direct text extraction |
| PDF (scanned/image) | .pdf | OCR via tesseract | Requires image preprocessing |
| Word Document | .docx, .doc | pandoc or python-docx | Preserves structure |
| Plain Text | .txt, .md | Direct read | No conversion needed |
| Images | .png, .jpg, .jpeg, .tiff | OCR via tesseract | For handwritten/printed text |
| PowerPoint | .pptx | pandoc | Extracts slide content |
| EPUB | .epub | pandoc | E-books |
| HTML | .html, .htm | pandoc or lynx | Web pages |
# Simple text-based PDF
pdftotext input.pdf output.txt
# With layout preservation
pdftotext -layout input.pdf output.txt
# Extract specific pages
pdftotext -f 1 -l 10 input.pdf output.txt
def extract_pdf_text(pdf_path):
try:
from pypdf import PdfReader
except ImportError:
from PyPDF2 import PdfReader
reader = PdfReader(pdf_path)
return '\n'.join(page.extract_text() or '' for page in reader.pages)
# Convert PDF pages to images first
pdftoppm -png input.pdf output_prefix
# Run OCR on each image
for img in output_prefix-*.png; do
tesseract "$img" "${img%.png}" -l eng
done
# Combine all text files
cat output_prefix-*.txt > final_output.txt
import pytesseract
from PIL import Image
def ocr_image(image_path):
image = Image.open(image_path)
text = pytesseract.image_to_string(image)
return text
# Using pandoc
pandoc input.docx -t plain -o output.txt
# Or with python-docx
from docx import Document
def extract_docx_text(docx_path):
doc = Document(docx_path)
text = "\n".join([para.text for para in doc.paragraphs])
return text
After extraction, apply these cleaning steps:
import re
def clean_text(text):
# 1. Remove excessive whitespace
text = re.sub(r'\n\s*\n', '\n\n', text)
text = re.sub(r' +', ' ', text)
# 2. Remove page numbers/headers/footers (common patterns)
text = re.sub(r'(?m)^\d+\s*$', '', text) # Page numbers
text = re.sub(r'(?m)^Page \d+.*$', '', text)
# 3. Fix broken words (hyphenation at line breaks)
text = re.sub(r'(\w)-\n(\w)', r'\1\2', text)
# 4. Merge lines that belong together
lines = text.split('\n')
merged = []
for line in lines:
if merged and not merged[-1].endswith(('.', '!', '?', ':')):
merged[-1] += ' ' + line.strip()
else:
merged.append(line)
return '\n'.join(merged)
The converted text is structured as:
====================================================
DOCUMENT METADATA
====================================================
Source: [filename]
Pages: [page count]
Converted: [timestamp]
Type: [PDF/DOCX/Image/etc.]
OCR Used: [Yes/No]
====================================================
EXTRACTED TEXT
====================================================
[Clean, structured text content here]
====================================================
END OF DOCUMENT
====================================================
User: "Read this PDF: /path/to/syllabus.pdf"
Skill:
1. Detects PDF format
2. Runs pdftotext
3. Cleans output
4. Returns structured text
User: "Convert this scanned PDF: /path/to/old-notes.pdf"
Skill:
1. Detects scanned PDF
2. Converts pages to images
3. Runs OCR
4. Cleans and structures output
User: "Process these files: syllabus.pdf, notes.docx, formulae.png"
Skill:
1. Processes each format appropriately
2. Combines into single text output
3. Ready for next skill (notes-generator, etc.)
This skill integrates with the session config system (deps/session-profile.json). Before
executing, check for an existing session profile:
deps/session-profile.json exists, read university, subject, pattern, and exam_type
fields to auto-configure the skill.setup-exam-prompt (or npm run init) first.After document conversion, pass the text to:
| Next Skill | How to Use |
|---|---|
| universal-notes-generator | Feed extracted syllabus/topics |
| universal-a-plus-answer-writer | Use content for answer generation |
| universal-pyq-analyzer | Process question papers |
| universal-imp-topics-generator | Analyze extracted content |
| universal-flashcard-generator | Create flashcards from text |
| universal-formula-sheet-generator | Extract formulas |
| universal-mcq-practice-generator | Generate MCQs from content |
| universal-session-config | Read university/department for format hints |
sudo apt update
sudo apt install -y poppler-utils tesseract-ocr pandoc python3 python3-pip
sudo apt install -y python3-pypdf python3-pytesseract python3-pil python3-docx
sudo dnf install -y poppler-utils tesseract pandoc python3 python3-pip
sudo dnf install -y python3-pypdf python3-pytesseract python3-pillow python3-docx
sudo pacman -S poppler tesseract tesseract-data-eng pandoc python python-pip
sudo pacman -S python-pypdf python-pytesseract python-pillow
# python-docx is in AUR: yay -S python-docx (or: pip install python-docx)
sudo apk add poppler tesseract-ocr pandoc python3 py3-pip
sudo apk add py3-pypdf py3-pytesseract py3-pillow py3-docx
sudo zypper install poppler-tools tesseract pandoc python3 python3-pip
sudo zypper install python3-pypdf python3-pytesseract python3-pillow python3-docx
brew install poppler tesseract pandoc python3
pip3 install pypdf pytesseract Pillow python-docx
# Option A: winget (built-in Windows 10/11 — recommended)
winget install XP89DCGQ3K6VLD # poppler (pdftotext)
winget install UBMFFKJRRR9W2K # tesseract (OCR)
winget install 9NBLGGH4W8GQ # pandoc
winget install 9PJPW5LDXLZ5 # Python 3
pip install pypdf pytesseract Pillow python-docx
# Option B: Chocolatey
choco install poppler tesseract pandoc python3 -y
pip install pypdf pytesseract Pillow python-docx
# Option C: Scoop
scoop install poppler tesseract pandoc python
pip install pypdf pytesseract Pillow python-docx
# Same as Linux Ubuntu/Debian instructions
sudo apt update && sudo apt install -y poppler-utils tesseract-ocr pandoc python3-pip
sudo apt install -y python3-pypdf python3-pytesseract python3-pil python3-docx
Before using this skill, verify required tools are installed:
# Check all dependencies
./scripts/check-deps.sh
# Or manually check:
which pdftotext # PDF text extraction
which tesseract # OCR for scanned docs
which pandoc # Document conversion
python3 -c "import PyPDF2; print('PyPDF2 OK')"
python3 -c "import pytesseract; print('pytesseract OK')"
# Install all dependencies at once (system packages preferred)
sudo apt update && sudo apt install -y poppler-utils tesseract-ocr pandoc python3-pip
sudo apt install -y python3-pypdf python3-pytesseract python3-pil python3-docx
sudo pacman -S poppler tesseract tesseract-data-eng pandoc python python-pip
sudo pacman -S python-pypdf python-pytesseract python-pillow
# python-docx is in AUR: yay -S python-docx
sudo dnf install -y poppler-utils tesseract pandoc python3-pip
sudo dnf install -y python3-pypdf python3-pytesseract python3-pillow python3-docx
| Error | Cause | Solution |
|---|---|---|
| "PDF is encrypted" | Password-protected PDF | Provide password or use decrypted version |
| "No text extracted" | Scanned/image PDF | Use OCR mode (see Method 3) |
| "File not found" | Wrong path | Check file path, use absolute paths |
| "Corrupt file" | Damaged document | Re-download or get clean copy |
| "OCR failed" | Poor image quality | Improve image quality: contrast, DPI > 300 |
| "pdftotext not found" | Missing poppler-utils | sudo apt install poppler-utils |
| "tesseract not found" | Missing OCR | sudo apt install tesseract-ocr |
| "pandoc not found" | Missing converter | sudo apt install pandoc |
| "Permission denied" | File locked | Check file permissions |
| "OCR confidence low" | Poor scan quality (<80%) | Increase DPI to 300+, adjust contrast/brightness |
| "OCR language uncertain" | Mixed language document | Specify language: -l eng+hin for bilingual |
| "Fatal OCR error" | Image corruption or format | Re-save image as PNG, verify file integrity |
| "Multi-column garbled" | PDF has 2+ columns | Use -layout flag or column-detection OCR mode |
| "Table structure lost" | Tabular data extracted as loose text | Use OCR with table recognition, or camelot/tabula |
| "Image contains only handwriting" | Handwritten notes | Use specialized handwriting OCR (e.g., Google Vision) |
When processing multi-column PDFs (common in research papers and textbooks), apply these steps:
pdftotext -layout which preserves whitespace alignmenttesseract --psm 6 (uniform block)# Column-aware extraction
pdftotext -layout input.pdf output.txt
# Column-aware OCR (scanned)
tesseract page.png output -l eng --psm 6
# Column-aware OCR with table detection (scanned)
tesseract page.png output -l eng --psm 4
If the extracted text has garbled column ordering, fall back to single-column extraction and note to the user that some interleaving may have occurred.
# Text-based PDF
pdftotext input.pdf output.txt
# Scanned PDF → OCR
pdftoppm -png input.pdf page && tesseract page-1.png output
# DOCX → TXT
pandoc input.docx -t plain -o output.txt
# Image → Text
tesseract image.png output -l eng
# Full pipeline (using wrapper script)
./scripts/process-document.sh input.pdf notes-generator
# Install tools (pick one)
winget install XP89DCGQ3K6VLD # pdftotext via winget
winget install UBMFFKJRRR9W2K # tesseract via winget
winget install 9NBLGGH4W8GQ # pandoc via winget
# Text-based PDF
pdftotext input.pdf output.txt
# DOCX → TXT
pandoc input.docx -t plain -o output.txt
# Image → Text
tesseract image.png output -l eng
# Or use Python (any OS - no native tools needed)
python -c "from pypdf import PdfReader; open('output.txt','w').write(''.join((p.extract_text() or '') for p in PdfReader('input.pdf').pages))"
from pypdf import PdfReader
# Extract PDF text
reader = PdfReader('input.pdf')
text = ''.join(page.extract_text() or '' for page in reader.pages)
with open('output.txt', 'w') as out:
out.write(text)
Note:
PyPDF2is deprecated. Usepypdfinstead (or PyPDF2 if already installed).
See the Installation Requirements section above for full per-OS instructions (Ubuntu, Fedora, Arch, Alpine, openSUSE, macOS, Windows, WSL).
Quick reference:
# Linux (Ubuntu/Debian)
sudo apt install -y poppler-utils tesseract-ocr pandoc python3-pip
pip3 install pypdf pytesseract Pillow python-docx
# macOS
brew install poppler tesseract pandoc python3
pip3 install pypdf pytesseract Pillow python-docx
# Windows (PowerShell Admin - winget)
winget install XP89DCGQ3K6VLD UBMFFKJRRR9W2K 9NBLGGH4W8GQ 9PJPW5LDXLZ5
pip install pypdf pytesseract Pillow python-docx
# Option A: Using wrapper script (recommended)
./scripts/process-document.sh notes.pdf notes-generator
# Option B: Manual conversion
pdftotext notes.pdf notes.txt
# Then use notes.txt with any skill
# Convert then generate notes
pdftotext syllabus.pdf - | notes-generator
# Convert then create flashcards
pandoc lecture.docx -t plain | flashcard-generator
# Convert then analyze PYQs
pdftotext pyq.pdf - | pyq-analyzer
This skill is Stage 1 of a 3-stage pipeline:
Stage 1: PDF/DOCX → TXT [universal-document-reader] ← You are here
Stage 2: TXT → MD [Manual or AI authoring]
Stage 3: MD → PDF [universal-document-generator / scripts/convert-to-pdf.*]
After extracting text with this skill:
scripts/convert-to-pdf.py or scripts/convert-to-pdf.jsuniversal-document-generator skill for full instructions┌─────────────────┐
│ User Input │
│ (PDF/DOCX/etc) │
└────────┬────────┘
│
▼
┌─────────────────────────┐
│ universal-document- │
│ reader │ ← Stage 1: Convert to clean text
│ (PDF/DOCX → TXT) │
└────────┬────────────────┘
│
▼
┌─────────────────────────┐
│ Manual / AI Authoring │ ← Stage 2: Structure into MD
│ (TXT → MD) │
└────────┬────────────────┘
│
▼
┌─────────────────────────┐
│ universal-document- │
│ generator │ ← Stage 3: Convert to PDF
│ (MD → PDF) │
└────────┬────────────────┘
│
▼
┌─────────────────┐
│ Print-Ready │
│ PDF Output │
└─────────────────┘
Before passing extracted text to downstream skills, verify:
tesseract page.png output -l eng --psm 6 and check log)If any check fails, either retry with a different method (e.g., pdftotext -layout → OCR → manual entry) or report the limitation to the user with suggested fixes.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
30 skills in this plugin
/universal-agent-normalizerUniversal agent normalizer that detects which AI coding agent is running and maps the Exam Prompt skill system to the agent's native configuration format. Supports 20+ coding agents as of June 2026. Ensures every agent can discover, load, and invoke all 30+ skills regardless of its native skill mechanism. Run this skill first whenever you are onboarding a new agent or if skills fail to load. Works for any university worldwide.
/universal-a-plus-answer-writerGenerates exam-ready A+ answers for ANY university worldwide — SPPU, VTU, IITs, NITs, MIT, Oxford, Cambridge, Harvard, NUS, and 50+ more. Covers ALL question types (theory, numerical, MCQ, case study, derivation, diagram, design, etc.), ALL mark levels (1-100+), ALL exam conditions (closed/open book, online, oral, lab, take-home), ALL Bloom's levels, and ALL command words. Pre-configured with SPPU Computer Engineering intelligence. Universally adaptable via syllabus PDF input. Trigger on ANY exam answer request. Never trigger for lab practical reports, project documentation, or coding assignments unless asked.
Other plugins' skills for the same job
/universal-assignment-writerGenerates assignment-ready content for any university worldwide across all assignment types (theory, numerical, case study, research, literature review, project proposals, design, analysis, comparison, critical review, problem-solving, and diagram/illustration). Supports multiple output formats, evaluation depth mapping, marking scheme generation, and citation requirements. University-agnostic.
/pinakdhabu-exam-prompt:universal-document-readerfrom pinakdhabu-exam-prompt
pinakdhabu-exam-prompt@awesome-skills-plugins-for-students is listed by studentsuite/awesome-skills-plugins-for-students — review the source before installing
npx claudepluginhub studentsuite/awesome-skills-plugins-for-students --plugin pinakdhabu-exam-prompt