Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

pdf-extraction

БесплатноБез исполняемых скриптовНе проверен

PDF text, layout, and figure extraction for RAG pipelines. Covers PyMuPDF (fitz), pdfplumber, Docling (IBM layout-aware), LlamaParse (LLM-based), Marker…

claude-dev-suiteот claude-dev-suite★ 51 звезда на GitHub

Об этом скилле

PDF Extraction

Tool Comparison

Tool Speed Layout Quality Tables Images Best For
PyMuPDF (fitz) Very fast Good Basic Yes Bulk text extraction
pdfplumber Slow Excellent Very good Yes Tables + coordinates
Docling Medium Excellent (layout model) Excellent Yes Structured docs, RAG
LlamaParse Slow (API) Excellent (LLM) Excellent Yes Complex layouts, forms
Marker Medium (GPU) Excellent Very good Yes PDF to markdown
pypdf Fast Poor No No Simple linear text only

PyMuPDF (fitz) — Fast Text + Metadata

import fitz  # PyMuPDF

def extract_pdf_pymupdf(path: str) -> list[dict]:
    doc = fitz.open(path)
    pages = []
    for page_num, page in enumerate(doc):
        text = page.get_text("text")
        blocks = page.get_text("dict")["blocks"]
        pages.append({
            "page": page_num + 1,
            "text": text,
            "blocks": blocks,
            "width": page.rect.width,
            "height": page.rect.height,
        })
    doc.close()
    return pages

Heading Detection via Font Size

def detect_headings(path: str) -> list[dict]:
    doc = fitz.open(path)
    # Collect font size distribution
    sizes = []
    for page in doc:
        for block in page.get_text("dict")["blocks"]:
            if block.get("type") != 0:
                continue
            for line in block["lines"]:
                for span in line["spans"]:
                    sizes.append(span["size"])
    body_size = max(set(sizes), key=sizes.count)  # mode = body text

    headings = []
    for page_num, page in enumerate(doc):
        for block in page.get_text("dict")["blocks"]:
            if block.get("type") != 0:
                continue
            for line in block["lines"]:
                for span in line["spans"]:
                    if span["size"] > body_size * 1.2:
                        level = 1 if span["size"] > body_size * 1.8 else 2
                        headings.append({
                            "page": page_num + 1,
                            "text": span["text"].strip(),
                            "size": span["size"],
                            "level": level,
                            "bold": bool(span["flags"] & 2**4),
                        })
    doc.close()
    return headings

Extract Images and Figures

def extract_images(path: str, out_dir: str):
    doc = fitz.open(path)
    for page_num, page in enumerate(doc):
        for img_index, img in enumerate(page.get_images(full=True)):
            xref = img[0]
            pix = fitz.Pixmap(doc, xref)
            if pix.n - pix.alpha > 3:  # CMYK
                pix = fitz.Pixmap(fitz.csRGB, pix)
            pix.save(f"{out_dir}/p{page_num+1}_img{img_index}.png")
            pix = None
    doc.close()

pdfplumber — Tables and Coordinates

import pdfplumber

with pdfplumber.open("report.pdf") as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        tables = page.extract_tables()
        for table in tables:
            # table is list[list[str]]
            for row in table:
                print(row)
        # Word-level coordinates for custom layout
        words = page.extract_words(keep_blank_chars=False)
        for w in words:
            print(w["text"], w["x0"], w["top"], w["fontname"], w["size"])

Docling — IBM Layout-Aware Parser

from docling.document_converter import DocumentConverter
from docling.datamodel.pipeline_options import PdfPipelineOptions
from docling.datamodel.base_models import InputFormat
from docling.document_converter import PdfFormatOption

pipeline_options = PdfPipelineOptions()
pipeline_options.do_ocr = True
pipeline_options.do_table_structure = True
pipeline_options.table_structure_options.do_cell_matching = True

converter = DocumentConverter(
    format_options={
        InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options),
    }
)

result = converter.convert("paper.pdf")
markdown = result.document.export_to_markdown()
doc_json = result.document.export_to_dict()

# Iterate structured items with page + bbox
for item, level in result.document.iterate_items():
    print(item.label, item.text[:80] if hasattr(item, "text") else "")

LlamaParse — LLM-Based Parsing

from llama_parse import LlamaParse
import os

parser = LlamaParse(
    api_key=os.environ["LLAMA_CLOUD_API_KEY"],
    result_type="markdown",        # or "text", "json"
    parsing_instruction=(
        "This is a financial report. Preserve tables as markdown "
        "and keep section numbering."
    ),
    premium_mode=True,             # best quality, slower + costly
    verbose=True,
)

documents = parser.load_data("10k.pdf")
for doc in documents:
    print(doc.metadata["page"], doc.text[:200])

Marker — PDF to Markdown

from marker.
Полный SKILL.md на GitHub

Установить pdf-extraction в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob
Write
Edit

FAQ

Что делает скилл pdf-extraction?

PDF text, layout, and figure extraction for RAG pipelines. Covers PyMuPDF (fitz), pdfplumber, Docling (IBM layout-aware), LlamaParse (LLM-based), Marker (markdown conversion). Page metadata, heading heuristics, figure/image extraction. USE WHEN: user mentions "PDF extraction", "parse PDF", "PyMuPDF", "fitz", "pdfplumber", "Docling", "LlamaParse", "Marker", "PDF to markdown" DO NOT USE FOR: scanned PDFs requiring OCR - use `ocr`; table-only extraction - use `table-extraction`; general filetype partitioning - use `unstructured-io`

Как установить скилл pdf-extraction?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл pdf-extraction запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить pdf-extraction с