convert-pdf-to-epub
БесплатноЗапускает вложенные скриптыНе проверенConvert PDF books to EPUB format for e-readers. Use when user asks to convert PDF to EPUB, create an e-book from PDF, make PDF readable on…
Об этом скилле
PDF to EPUB Converter
Convert PDF documents to high-quality EPUB files with automatic chapter detection, image optimization, and footnote hyperlinking.
Quick Start
# Run conversion (from skill directory)
python -m scripts.convert input.pdf output.epub
# Validate result
python -m scripts.validate input.pdf output.epub
Workflow Overview
The conversion follows a 3-phase process with an optional 4th phase for adaptation:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ 1. ANALYZE │ ──► │ 2. CONVERT │ ──► │ 3. VALIDATE │
│ - PDF structure│ │ - Apply config │ │ - Check quality│
│ - Generate cfg │ │ - Build EPUB │ │ - Report issues│
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ 4. ADAPT │
│ (if needed) │
│ - Tune config │
│ - Modify code │
└─────────────────┘
Phase 1: Analyze
Before converting, analyze the PDF to determine the best configuration:
# Open PDF and examine structure
import fitz # pymupdf
doc = fitz.open("input.pdf")
# Check for:
# 1. Number of pages
# 2. Presence of images
# 3. Multi-column layout (compare text block x-coordinates)
# 4. Footnotes/endnotes (numbers in margins or at page bottom)
# 5. Font sizes (for heading detection thresholds)
Generate initial config based on analysis:
- Fiction book: Use default
y_sortreading order - Academic paper: Enable
xy_cutfor columns - Magazine: Enable image optimization, use
xy_cut
Ask user to confirm the proposed configuration before proceeding.
Phase 2: Convert
Run the conversion with the generated config:
from conversion.converter import Converter
from conversion.models import ConversionConfig
config = ConversionConfig(
page_ranges=PageRanges(skip=[1, 2], content=(3, -3)),
exclude_regions=ExcludeRegions(top=0.05, bottom=0.05),
reading_order_strategy="y_sort", # or "xy_cut" for columns
image_optimization=ImageOptimizationConfig(enabled=True),
)
converter = Converter(strategy="simple")
result = converter.convert(pdf_path, epub_path, config)
# Check confidence
if result.reading_order_confidence < 0.7:
print("Warning: Low confidence in reading order")
Phase 3: Validate
Always validate the conversion result:
from validation.completeness_checker import CompletenessChecker
from validation.order_checker import OrderChecker
# Check text completeness
completeness = CompletenessChecker().check(pdf_text, epub_text)
print(f"Completeness: {completeness.score:.1%}") # Should be > 95%
# Check reading order
order = OrderChecker().check(pdf_chunks, epub_chunks)
print(f"Order score: {order.score:.1%}") # Should be > 80%
Quality gates:
- Completeness < 95%: Text is being lost
- Order score < 80%: Reading order is wrong
Phase 4: Adapt (if validation fails)
See Decision Tree below.
Decision Tree: When Things Go Wrong
Validation failed?
│
├─► Text loss > 5%?
│ ├─► Check exclude_regions (headers/footers being cut?)
│ │ → Try: exclude_regions.top: 0.03 (reduce from 0.05)
│ ├─► Check page_ranges (skipping too many pages?)
│ │ → Try: page_ranges.skip: [] (don't skip any)
│ └─► Still failing? → See reference/troubleshooting.md#text-loss
│
├─► Wrong reading order?
│ ├─► PDF has columns?
│ │ → Try: reading_order_strategy: "xy_cut"
│ ├─► Columns detected but wrong?
│ │ → Try: multi_column.threshold: 0.3 (more sensitive)
│ └─► Still failing? → See reference/troubleshooting.md#order
│
├─► Headings not detected?
│ ├─► Headings only slightly larger than body?
│ │ → Try: heading_detection.font_size_threshold: 1.1
│ └─► Custom font patterns?
│ │ → May need to modify structure_classifier.py (ADAPTABLE)
│
├─► Footnotes not linking?
│ ├─► Non-standard format (not [1] or (1))?
│ │ → Add pattern to FootnoteDetector.PATTERNS
│ └─► See reference/troubleshooting.md#footnotes
│
└─► Other issue?
└─► See reference/troubleshooting.md
Three-Layer Architecture
The codebase is organized into three layers with different modification policies:
Layer 1: FROZEN (Do Not Modify)
These files implement fixed specifications or deterministic algorithms:
| File | Reason |
|---|---|
core/epub_builder.py |
EPUB3 spec is fixed |
core/text_segmenter.py |
Validation depends on identical chunking |
validation/* |
Metrics must be reproducible |
Never modify these files unless there's a fundamental bug.
Layer 2: CONFIG
Установить convert-pdf-to-epub в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashGlobGrepВложенные файлы
FAQ
Что делает скилл convert-pdf-to-epub?
Convert PDF books to EPUB format for e-readers. Use when user asks to convert PDF to EPUB, create an e-book from PDF, make PDF readable on Kindle/phone/tablet, or extract book content from PDF. Handles: chapter detection, image extraction with optimization, footnotes/endnotes with hyperlinks, reading order for multi-column layouts. Validates conversion quality automatically.
Как установить скилл convert-pdf-to-epub?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл convert-pdf-to-epub запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse 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…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic