Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Development skills for AI coding agents. Plug into your favorite AI coding tool
| `shader-dev` | Comprehensive GLSL shader techniques for creating stunning visual effects — ray marching, SDF modeling, fluid simulation, particle systems, procedural generation, lighting, post-processing, and more. ShaderToy-compatible. | Official |
| `gif-sticker-maker` | Convert photos (people, pets, objects, logos) into 4 animated GIF stickers with captions. Funko Pop / Pop Mart style, powered by MiniMax Image & Video Generation API. | Official |
| `minimax-pdf` | Generate, fill, and reformat PDF documents with a token-based design system. CREATE polished PDFs from scratch (15 cover styles), FILL existing form fields, or REFORMAT documents into a new design. Print-ready output with typography and color derived from document type. | Official |
| `minimax-pdf-read` | Extract and analyze text content from PDF documents. Read PDF text, extract metadata, and parse content using pypdf. Complements minimax-pdf which handles PDF generation and editing. | Community |
| `pptx-generator` | Generate, edit, and read PowerPoint presentations. Create from scratch with PptxGenJS (cover, TOC, content, section divider, summary slides), edit existing PPTX via XML workflows, or extract text with markitdown. | Official |
| `minimax-xlsx` | Open, create, read, analyze, edit, or validate Excel/spreadsheet files (.xlsx, .xlsm, .csv, .tsv). Covers creating new xlsx from scratch via XML templates, reading and analyzing with pandas, editing existing files with zero format loss, formula recalculation, validation, and professional financial formatting. | Official |
| `minimax-docx` | Professional DOCX document creation, editing, and formatting using OpenXML SDK (.NET). Three pipelines: create new documents from scratch, fill/edit content in existing documents, or apply template formatting with XSD validation gate-check. | Official |
Expand Down
1 change: 1 addition & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| `shader-dev` | 全面的 GLSL 着色器技术,用于创建惊艳的视觉效果 — 光线行进、SDF 建模、流体模拟、粒子系统、程序化生成、光照、后处理等。兼容 ShaderToy。 | Official |
| `gif-sticker-maker` | 将照片(人物、宠物、物品、Logo)转换为 4 张带字幕的动画 GIF 贴纸。Funko Pop / Pop Mart 盲盒风格,基于 MiniMax 图片与视频生成 API。 | Official |
| `minimax-pdf` | 基于 token 化设计系统生成、填写和重排 PDF 文档。支持三种模式:CREATE(从零生成,15 种封面风格)、FILL(填写现有表单字段)、REFORMAT(将已有文档重排为新设计)。排版与配色由文档类型自动推导,输出即可打印。 | Official |
| `minimax-pdf-read` | 从 PDF 文档中提取和分析文本内容。使用 pypdf 读取 PDF 文本、提取元数据和解析内容。与 minimax-pdf(负责 PDF 生成和编辑)互补。 | Community |
| `pptx-generator` | 生成、编辑和读取 PowerPoint 演示文稿。支持用 PptxGenJS 从零创建(封面、目录、内容、分节页、总结页),通过 XML 工作流编辑现有 PPTX,或用 markitdown 提取文本。 | Official |
| `minimax-xlsx` | 打开、创建、读取、分析、编辑或验证 Excel/电子表格文件(.xlsx、.xlsm、.csv、.tsv)。支持通过 XML 模板从零创建 xlsx、使用 pandas 读取分析、零格式损失编辑现有文件、公式重算与验证、专业财务格式化。 | Official |
| `minimax-docx` | 基于 OpenXML SDK(.NET)的专业 DOCX 文档创建、编辑与排版。三条流水线:从零创建新文档、填写/编辑现有文档内容、应用模板格式并通过 XSD 验证门控检查。 | Official |
Expand Down
114 changes: 114 additions & 0 deletions skills/minimax-pdf-read/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
name: minimax-pdf-read
description: >
Extract and analyze text content from PDF documents. Use when: user shares a .pdf file
path (any message containing .pdf file extension) or uses any of these words/phrases
near a PDF: "read this PDF", "extract text from", "what does this PDF say", "analyze
this PDF", " summarize this PDF", "get text from", "parse this PDF", "tell me what's
in this PDF", "extract content from", "read the attached PDF".
Triggers: any message with a .pdf file extension, or any request to read, extract,
analyze, summarize, or parse a PDF document.
license: MIT
metadata:
version: "1.0"
category: document-processing
---

# minimax-pdf-read

Extract and analyze text content from PDF documents using Python.

## Prerequisites

- Python 3.9+
- Install dependencies: `pip install -r skills/minimax-pdf-read/scripts/requirements.txt`
- No external API keys required — uses local text extraction

## Quick Start

```bash
pip install -r skills/minimax-pdf-read/scripts/requirements.txt
python skills/minimax-pdf-read/scripts/extract.py --input document.pdf
```

## Scripts

| Script | Purpose | Usage |
|---|---|---|
| `extract.py` | Extract text and metadata from PDFs | See Usage below |
| `requirements.txt` | Python dependencies | `pip install -r requirements.txt` |

## Usage

### Extract all text from a PDF

```bash
python skills/minimax-pdf-read/scripts/extract.py --input document.pdf
```

### Extract text from specific pages

```bash
python skills/minimax-pdf-read/scripts/extract.py --input document.pdf --pages 1-5
```

### Extract to a file

```bash
python skills/minimax-pdf-read/scripts/extract.py --input document.pdf --output extracted.txt
```

### Get PDF metadata only

```bash
python skills/minimax-pdf-read/scripts/extract.py --input document.pdf --metadata
```

## Workflow

### Step 1: Detect PDF

The skill triggers when a message contains a `.pdf` file path or URL.

### Step 2: Extract text

Use the extraction script:

```bash
python skills/minimax-pdf-read/scripts/extract.py --input document.pdf
```

Or use pypdf directly for custom processing:

```python
from pypdf import PdfReader

reader = PdfReader("document.pdf")
for page in reader.pages:
text = page.extract_text()
print(text)
```

### Step 3: Present results

Return the extracted text clearly, preserving structure where possible.

## Output Format

```
## Extracted Text

[Full text content from the PDF, page by page]

## Metadata

- Pages: N
- Title: [if available]
- Author: [if available]
```

## Notes

- pypdf works best on text-based PDFs
- Scanned/image PDFs may require OCR (see vision-analysis skill)
- Large PDFs may need page-by-page extraction
100 changes: 100 additions & 0 deletions skills/minimax-pdf-read/scripts/extract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env python3
import argparse
import sys
from pathlib import Path

try:
from pypdf import PdfReader
except ImportError:
sys.exit("ERROR: pypdf is not installed. Run: pip install pypdf")


def extract_text(pdf_path: Path, pages: str = None) -> str:
reader = PdfReader(pdf_path)

if pages:
page_range = parse_page_range(pages, len(reader.pages))
pages_to_extract = [reader.pages[i] for i in page_range]
else:
pages_to_extract = reader.pages

output = []
for i, page in enumerate(pages_to_extract, 1):
text = page.extract_text()
output.append(f"--- Page {i} ---\n{text}")

return "\n\n".join(output)


def extract_metadata(pdf_path: Path) -> dict:
reader = PdfReader(pdf_path)
info = reader.metadata or {}

return {
"pages": len(reader.pages),
"title": info.get("/Title", "N/A"),
"author": info.get("/Author", "N/A"),
"subject": info.get("/Subject", "N/A"),
"creator": info.get("/Creator", "N/A"),
}


def parse_page_range(pages_str: str, total_pages: int) -> list:
result = []
parts = pages_str.split(",")
for part in parts:
part = part.strip()
if "-" in part:
start, end = part.split("-", 1)
start_idx = max(0, int(start.strip()) - 1)
end_idx = min(total_pages, int(end.strip()))
result.extend(range(start_idx, end_idx))
else:
result.append(max(0, min(total_pages - 1, int(part) - 1)))
return result


def main():
parser = argparse.ArgumentParser(
description="Extract text and metadata from PDF documents."
)
parser.add_argument(
"--input", "-i", required=True, help="Input PDF file path"
)
parser.add_argument(
"--output", "-o", help="Output text file path (default: stdout)"
)
parser.add_argument(
"--pages", "-p", help="Page range, e.g., '1-5' or '1,3,5-7'"
)
parser.add_argument(
"--metadata", "-m", action="store_true", help="Extract metadata only"
)

args = parser.parse_args()

pdf_path = Path(args.input)
if not pdf_path.exists():
sys.exit(f"ERROR: File not found: {pdf_path}")

if not pdf_path.suffix.lower() == ".pdf":
sys.exit("ERROR: Input file must be a PDF")

try:
if args.metadata:
meta = extract_metadata(pdf_path)
output = "\n".join(f"{k}: {v}" for k, v in meta.items())
else:
output = extract_text(pdf_path, args.pages)
except Exception as e:
sys.exit(f"ERROR: Failed to extract from PDF: {e}")

if args.output:
Path(args.output).write_text(output)
print(f"Written to {args.output}")
else:
print(output)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions skills/minimax-pdf-read/scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pypdf>=4.0.0