# Document Preprocessor

> Extracts text from documents (PDF, DOCX, TXT) and splits them into manageable chunks for processing. Use when you need to prepare documents for question answering, retrieval, or summarization tasks.

- Skill: `praveen7287/document-preprocessor` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add praveen7287/document-preprocessor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/praveen7287/document-preprocessor/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: Praveen7287 (https://skillmd.com/u/praveen7287)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/praveen7287/document-preprocessor

---

# Document Preprocessing Instructions

## Step-by-Step Process

1. **Detect file format** from the file extension
2. **Extract text content** using appropriate library:
   - PDF: Use PyPDF2 with fallback for scanned documents
   - DOCX: Use python-docx preserving headings and structure
   - TXT/MD: Read with UTF-8 encoding
3. **Clean the text** by removing excessive whitespace and special characters
4. **Split into chunks** using paragraph boundaries first, then sentence boundaries
5. **Add metadata** to each chunk including source file and position

## Implementation Details

```python
def process_document(file_path):
    # Implementation here
    pass
