视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
skill-119【文档与办公】Extract text, tables, and images from PDF files using pdfplumber and PyMuPDF. Use when analyzing PDF documents, brand materials, reports, or any content that requires structured extraction from PDF format. Supports table detection, layout preservation, and high-quality image extraction.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Extract comprehensive content from PDF files including text, tables, images, and metadata using industry-standard Python libraries.
Use this skill when:
This skill combines two powerful libraries:
pip install pdfplumber pymupdf pillow
python scripts/extract_pdf.py <path/to/document.pdf> --output-dir ./output
The script creates the following output:
output/
├── extracted_text.md # All text content with page numbers
├── extracted_tables.json # Structured table data
├── metadata.json # PDF metadata and page info
└── images/ # Extracted images
├── page_1_image_1.png
├── page_2_image_1.jpeg
└── ...
When a user provides a PDF file for analysis:
scripts/extract_pdf.py with the PDF pathExample workflow:
# Step 1: Extract PDF content
python scripts/extract_pdf.py "brand_document.pdf" --output-dir ./brand_analysis
# Step 2: Read extracted text
cat ./brand_analysis/extracted_text.md
# Step 3: Analyze tables
cat ./brand_analysis/extracted_tables.json
# Step 4: Check images
ls ./brand_analysis/images/
The script uses layout=True to preserve formatting and spacing, which is crucial for:
pdfplumber automatically detects tables using:
PyMuPDF extracts images in their original format (JPEG, PNG) without re-encoding, preserving:
If the script fails with import errors:
pip install --upgrade pdfplumber pymupdf pillow
For password-protected PDFs, use PyMuPDF's authentication:
import pymupdf
doc = pymupdf.open("encrypted.pdf")
doc.authenticate("password")
For very large PDFs (>100MB), process pages in batches to manage memory usage.
| Feature | pdfplumber | PyMuPDF |
|---|---|---|
| Text extraction | ⭐⭐⭐ (Best layout preservation) | ⭐⭐ (Fast, good quality) |
| Table detection | ⭐⭐⭐ (Excellent) | ⭐ (Basic) |
| Image extraction | ⭐ (Basic) | ⭐⭐⭐ (Best performance) |
| Speed | ⭐⭐ (Moderate) | ⭐⭐⭐ (Very fast) |
| Memory usage | ⭐⭐ (Higher) | ⭐⭐⭐ (Lower) |
Using both libraries provides optimal results:
This combination ensures comprehensive extraction without compromise.
python scripts/extract_pdf.py "company_brand_guidelines.pdf" --output-dir ./brand_analysis
Expected output:
python scripts/extract_pdf.py "design_brief.pdf" --output-dir ./brief_analysis
Expected output:
After extracting brand guidelines:
After extracting research documents: