domains / documents / pdf-to-markdown-extraction / pdf-extract

pdf-extract

Skill card

combined

The two skills share the name 'pdf-extract' but implement fundamentally different procedures. The first (LeoYeAI) is a thin wrapper around the `pdftotext` binary (poppler-utils) for simple text extraction. The second (aipoch) is a complex Python-based workflow using `pdfplumber` and `pymupdf` that extracts text and images, normalizes paragraphs, and outputs a structured Markdown file with per-page headings and image links. They use different dependencies, different commands, and produce different outputs (plain text vs. structured Markdown with images). Crowning one would hide the other's specific utility (e.g., image extraction and Markdown structuring vs. simple text dumping).

Repositories

RepositoryPath
LeoYeAI/openclaw-master-skillsskills/pdf-extract/SKILL.md
aipoch/medical-research-skillsscientific-skills/Other/pdf-extract/SKILL.md

Other copies

RoleRepositoryPath
peerLeoYeAI/openclaw-master-skillsskills/pdf-extract/SKILL.md
peeraipoch/medical-research-skillsscientific-skills/Other/pdf-extract/SKILL.md

Combined skill

---
name: pdf-extract
description: "Extract text and/or images from PDF files. Use pdftotext for simple text extraction or the Python script for structured Markdown with images."
---

# PDF Extract

This skill provides two methods for extracting content from PDFs. Choose the method based on your output requirements.

## Method 1: Simple Text Extraction (pdftotext)

Use this when you only need plain text and do not require page structure or images.

**Dependencies:**
- `poppler-utils` (provides `pdftotext`)

**Install:**
```bash
sudo dnf install poppler-utils
# or: sudo apt-get install poppler-utils
```

**Usage:**
```bash
# Extract all text
pdftotext "document.pdf" -

# Extract specific pages
pdftotext -f 1 -l 5 "document.pdf" -
```

## Method 2: Structured Markdown with Images (Python)

Use this when you need to preserve page structure, extract images (tables/figures), and generate a Markdown file for LLM processing or PPT creation.

**Dependencies:**
- `pdfplumber`
- `pymupdf`
- `pytesseract` (optional, for OCR filtering)

**Install:**
```bash
pip install pdfplumber pymupdf pytesseract
```

**Usage:**
```bash
python scripts/extract_pdf.py \
  --input input.pdf \
  --output output.md \
  --image-dir images \
  --image-mode segment \
  --filter-text on \
  --text-threshold 0.25
```

**Key Options:**
- `--image-mode`: `segment` (default, blocks), `embedded` (raw images), or `page` (full page render).
- `--filter-text`: Removes text-heavy images via OCR.
- `--filter-match`: Removes images that match extracted page text.

**Output:**
- A Markdown file with `# <filename>` and `## Page XX` headings.
- Normalized text paragraphs.
- Image links corresponding to the selected mode.

## Validation

Before running, ensure the input PDF exists and is readable.
- For Method 1: Verify `pdftotext` is in PATH.
- For Method 2: Run `python scripts/extract_pdf.py --help` to verify the script and dependencies are available.