PDF Text Extraction

SkillFiles & storage

Extract text from PDF files using Python libraries (PyPDF2, pdfplumber) for content analysis and classification.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the PDF Text Extraction skill

What this skill tells your AI

The instructions your AI receives, as published by cxcscmu/skilllearnbench in skills/b1-one-shot-claude-opus-4-6/organize-messy-files/pdf-text-extraction/SKILL.md and read by ahel’s review.

Overview

Extract text content from PDF files to analyze their content and classify them by subject.

Installation

pip install pdfplumber PyPDF2

Usage Examples

Using pdfplumber (Recommended)

import pdfplumber

def extract_pdf_text(pdf_path, max_chars=5000):
    """Extract text from PDF with character limit for efficiency"""
    try:
        with pdfplumber.open(pdf_path) as pdf:
            text = ""
            # Read first few pages to get representative content
            for page_num in range(min(3, len(pdf.pages))):
                text += pdf.pages[page_num].extract_text() or ""
                if len(text) > max_chars:
                    break
            return text[:max_chars]
    except Exception as e:
        return f"Error reading PDF: {str(e)}"

Using PyPDF2 (Fallback)

from PyPDF2 import PdfReader

def extract_pdf_text_pypdf(pdf_path):
    """Alternative PDF text extraction"""
    try:
        reader = PdfReader(pdf_path)
        text = ""
        for page in reader.pages[:3]:  # First 3 pages
            text += page.extract_text()
        return text
    except Exception as e:
        return f"Error: {str(e)}"

Best Practices

  • Extract from first 2-3 pages only (faster, usually contains abstracts/titles)
  • Handle errors gracefully for corrupted PDFs
  • Cache extracted text to avoid re-processing
  • Use reasonable character limits (3000-5000 chars) for classification

Signals

GitHub stars
83
Forks
5
Last commit
Jul 2026
Advanced
Catalog kind
skill
Gateway key
pdf-text-extraction
Source
github.com/cxcscmu/skilllearnbench