pdf-ingest

Extract text and tables from native and scanned PDFs into markdown chunks.

Updated Jun 15, 2026
One-click install
npx skills add https://github.com/kmjy98-sketch/khulaw --skill pdf-ingest-kmjy98-sketch
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: pdf-ingest
Source: https://github.com/kmjy98-sketch/khulaw/tree/main/.agent/skills/pdf-ingest
Command: npx skills add https://github.com/kmjy98-sketch/khulaw --skill pdf-ingest-kmjy98-sketch

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pypdf, pdfplumber, pymupdf, easyocr, and includes scripts (resource) components.

What problem does it solve? Converting Korean law textbooks and other PDFs into searchable markdown is tedious, especially when files are scanned images without a text layer or contain complex tables. This Skill automates PDF-to-markdown chunk extraction with OCR fallback, table detection, and page-boundary context repair. ## Core Features & Use Cases - Dual extraction paths: Native PDFs are parsed with pypdf/pdfplumber, while scanned PDFs are rendered with pymupdf and recognized with easyocr (Korean/English, CPU mode). - Automatic table detection: pdfplumber table regions and OCR bounding-box layout analysis are converted into markdown tables, with page-boundary sentence merging for broken context. - Batch chunking with index: Splits large PDFs into 30-page markdown chunks and maintains a chunks_index.json with legal keyword extraction (article and case numbers). - Use Case: Extract a 600-page scanned criminal law textbook into markdown chunks, place them under sync/_교재원문/, then run qmd update and qmd embed for RAG indexing. ## Quick Start Extract the PDFs in my textbook folder into markdown chunks using the pdf-ingest skill, falling back to OCR for any scanned volumes.

Frequently Asked Questions about pdf-ingest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract text from a scanned PDF in Python?▼

Scanned PDFs lack a text layer, so pypdf returns empty strings. Render each page with pymupdf at 200 DPI and run easyocr with Korean and English models in CPU mode to recognize the text.

How to convert PDF tables into markdown tables?▼

Use pdfplumber's find_tables() to detect table regions in native PDFs and format rows as markdown. For OCR output, cluster bounding boxes by Y coordinate into rows and repeated X positions into columns, then emit markdown table syntax.

Does easyocr work without a GPU for Korean text?▼

Yes, easyocr runs in CPU mode with gpu=False and supports Korean and English recognition. Expect roughly 3 to 6 seconds per page at 200 DPI, with a one-time model download on first run.

Why does pypdf return empty text for my PDF?▼

Empty output means the PDF is a scanned image without an embedded text layer. The skill treats pages with fewer than 50 characters as scanned and switches to the OCR extraction path using pymupdf and easyocr.

How do I split a large PDF into smaller text chunks?▼

Run the batch extraction script with a chunk-size option, which defaults to 30 pages per markdown file. Each chunk is named with its page range and registered in a chunks_index.json for incremental reprocessing.