
PDF Extraction
Extract text, tables, and metadata from PDFs using pdfplumber
Install
npx skills add claude-office-skills/skills --skill pdf-extraction -g -a claude-code -y- Repository
- claude-office-skills/skills556
- Category
- Engineering
- Updated
- 9mo ago
- License
- MIT
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
Extract text, tables, and metadata from PDFs using pdfplumber
PDF Extraction Skill
Overview
This skill enables precise extraction of text, tables, and metadata from PDF documents using pdfplumber - the go-to library for PDF data extraction. Unlike basic PDF readers, pdfplumber provides detailed character-level positioning, accurate table detection, and visual debugging.
How to Use
- Provide the PDF file you want to extract from
- Specify what you need: text, tables, images, or metadata
- I'll generate pdfplumber code and execute it
Example prompts:
- "Extract all tables from this financial report"
- "Get text from pages 5-10 of this document"
- "Find and extract the invoice total from this PDF"
- "Convert this PDF table to CSV/Excel"
Domain Knowledge
pdfplumber Fundamentals
import pdfplumber
# Open PDF
with pdfplumber.open('document.pdf') as pdf:
# Access pages
first_page = pdf.pages[0]
# Document metadata
print(pdf.metadata)
# Number of pages
print(len(pdf.pages))
PDF Structure
PDF Document
├── metadata (title, author, creation date)
├── pages[]
│ ├── chars (individual characters with position)
│ ├── words (grouped characters)
│ ├── lines (horizontal/vertical lines)
│ ├── rects (rectangles)
│ ├── curves (bezier curves)
│ └── images (embedded images)
└── outline (bookmarks/TOC)
Text Extraction
Basic Text
with pdfplumber.open('document.pdf') as pdf:
# Single page
text = pdf.pages[0].extract_text()
# All pages
full_text = ''
for page in pdf.pages:
full_text += page.extract_text() or ''
Advanced Text Options
# With layout preservation
text = page.extract_text(
x_tolerance=3, # Horizontal tolerance for grouping
y_tolerance=3, # Vertical tolerance
layout=True, # Preserve layout
x_density=7.25, # Chars per unit width
y_density=13 # Chars per unit height
)
