Command Palette

Search for a command to run...

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

pdf

БесплатноЗапускает вложенные скриптыНе проверен

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…

mateaixот mateaix★ 1 218 звёзд на GitHub

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

Important: All scripts/ paths are relative to this skill directory. Use run_skill_script tool to execute scripts, or run with: cd {this_skill_dir} && python scripts/...

PDF Processing Guide

Prerequisites

  • pypdf: core PDF reading and writing
  • pdfplumber: text and table extraction
  • reportlab: PDF creation
  • pdftotext (poppler-utils): command-line text extraction
  • pdftoppm (poppler-utils): PDF-to-image conversion
  • qpdf: PDF manipulation (merge, split, rotate, decrypt)

Tool Selection Decision Table

Choose the right approach before starting:

Input Condition Recommended Tool
URL PDF accessible via URL web_extract(url) — fastest, no download needed
Local file Text-native PDF (generated by software) pymupdf — ~25 MB install, instant extraction
Local file Scanned/image-only PDF (no selectable text) marker-pdf — OCR with layout preservation (~5 GB, needs GPU or CPU)
Local file Form filling or page manipulation pypdf / pdfplumber + form scripts
Local file NLP editing or semantic search nano-pdf — sentence-level operations

URL-first rule: If the user provides a URL, always try URL extraction first before downloading.

Overview

This guide covers essential PDF processing operations using Python libraries and command-line tools.

URL-First Extraction

If the user provides a URL pointing to a PDF, extract it without downloading:

web_extract(url="https://example.com/report.pdf")

Fall back to download + local processing only if web_extract returns empty or errors.


Fast Extraction: pymupdf (fitz)

Best for: Text-native PDFs (digital, not scanned). Install: pip install pymupdf (~25 MB).

import fitz  # pymupdf

doc = fitz.open("document.pdf")
print(f"Pages: {doc.page_count}")

# Extract all text (fast)
full_text = "\n".join(page.get_text() for page in doc)

# Extract with layout blocks (tables, columns)
for page in doc:
    blocks = page.get_text("blocks")  # (x0,y0,x1,y1,text,block_no,block_type)
    for block in blocks:
        print(block[4])  # text content

# Extract images
for page in doc:
    for img in page.get_images():
        xref = img[0]
        base = doc.extract_image(xref)
        with open(f"img_{xref}.{base['ext']}", "wb") as f:
            f.write(base["image"])

pymupdf is 5-10× faster than pypdf for text extraction and preserves layout better.


OCR Extraction: marker-pdf

Best for: Scanned PDFs, image-only PDFs, or documents where pymupdf returns garbled text. Install: pip install marker-pdf (~5 GB with models).

# Single file
marker_single document.pdf output_dir/ --batch_multiplier 2

# Batch
marker input_dir/ output_dir/ --workers 4

Outputs Markdown with preserved headings, tables, and code blocks.

Decision signal: Run pymupdf first. If extracted text has <50% printable characters or looks like garbage, switch to marker-pdf.


NLP Editing: nano-pdf

Best for: Semantic search, sentence-level edits, keyword replacement in text-native PDFs. Install: pip install nano-pdf.

from nano_pdf import NanoPDF

doc = NanoPDF("document.pdf")

# Search sentences
results = doc.search("termination clause", top_k=5)
for r in results:
    print(r.page, r.text, r.score)

# Replace text (produces new PDF)
doc.replace("old phrase", "new phrase", output="modified.pdf")

Python Libraries

pypdf - Basic Operations

Merge PDFs

from pypdf import PdfWriter, PdfReader

writer = PdfWriter()
for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
    reader = PdfReader(pdf_file)
    for page in reader.pages:
        writer.add_page(page)

with open("merged.pdf", "wb") as output:
    writer.write(output)

Split PDF

reader = PdfReader("input.pdf")
for i, page in enumerate(reader.pages):
    writer = PdfWriter()
    writer.add_page(page)
    with open(f"page_{i+1}.pdf", "wb") as output:
        writer.write(output)

Extract Metadata

reader = PdfReader("document.pdf")
meta = reader.metadata
print(f"Title: {meta.title}")
print(f"Author: {meta.author}")

Rotate Pages

reader = PdfReader("input.pdf")
writer = PdfWriter()
page = reader.pages[0]
page.rotate(90)  # Rotate 90 degrees clockwise
writer.add_page(page)
with open("rotated.pdf", "wb") as output:
    writer.write(output)

pdfplumber - Text and Table Extraction

Extract Text with Layout

import pdfplumber

with pdfplumber.open("document.pdf") as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        print(text)

Extract Tables

with pdfplumber.open("document.pdf") as pdf:
    for i, page in enumerate(pdf.pages):
        tables = page.extract_tables()
        for j, table in enumerate(tables):
            print(f"Table {j+1} on page {i+1}:")
            for row in table:
Полный SKILL.md на GitHub

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

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

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

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

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

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

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

LICENSE.txtforms.mdreference.mdscripts/check_bounding_boxes.pyscripts/check_fillable_fields.pyscripts/convert_pdf_to_images.pyscripts/create_validation_image.pyscripts/extract_form_field_info.pyscripts/extract_form_structure.pyscripts/fill_fillable_fields.pyscripts/fill_pdf_form_with_annotations.py

FAQ

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

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

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

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

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

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

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

Сравнить pdf с