Comprehensive PDF manipulation toolkit for extracting text and tables,
When & Why to Use This Skill
This Claude skill provides a comprehensive PDF manipulation toolkit designed for seamless text and table extraction, document merging, and programmatic PDF creation. By leveraging industry-standard Python libraries like pypdf, pdfplumber, and reportlab, it enables automated workflows for handling complex document structures, converting PDFs into structured data, and managing large-scale file operations with high precision.
Use Cases
- Automated Data Extraction: Extracting structured tables and text from financial statements, invoices, or research papers to populate databases or spreadsheets.
- Document Assembly and Organization: Merging multiple PDF reports into a single archive or splitting large documents into individual pages for easier distribution.
- Programmatic PDF Generation: Creating custom-branded PDFs, such as automated invoices, certificates, or dynamic reports using Python scripts.
- High-Volume Batch Processing: Utilizing command-line tools like qpdf and poppler-utils for fast, server-side PDF optimization and text conversion.
| name | |
|---|---|
| description | Comprehensive PDF manipulation toolkit for extracting text and tables, |
| version | 1.0.0 |
PDF Processing Guide
Quick Start
from pypdf import PdfReader, PdfWriter
# Read a PDF
reader = PdfReader("document.pdf")
print(f"Pages: {len(reader.pages)}")
# Extract text
text = ""
for page in reader.pages:
text += page.extract_text()
Python Libraries
pypdf - Basic Operations
Merge PDFs
from pypdf import PdfWriter, PdfReader
writer = PdfWriter()
for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
reader = PdfReader(pdf_file)
for page in reader.pages:
writer.add_page(page)
with open("merged.pdf", "wb") as output:
writer.write(output)
Split PDF
reader = PdfReader("input.pdf")
for i, page in enumerate(reader.pages):
writer = PdfWriter()
writer.add_page(page)
with open(f"page_{i+1}.pdf", "wb") as output:
writer.write(output)
pdfplumber - Text and Table Extraction
Extract Tables
import pdfplumber
import pandas as pd
with pdfplumber.open("document.pdf") as pdf:
all_tables = []
for page in pdf.pages:
tables = page.extract_tables()
for table in tables:
if table:
df = pd.DataFrame(table[1:], columns=table[0])
all_tables.append(df)
reportlab - Create PDFs
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("hello.pdf", pagesize=letter)
width, height = letter
c.drawString(100, height - 100, "Hello World!")
c.save()
Command-Line Tools
# Extract text (poppler-utils)
pdftotext input.pdf output.txt
# Merge PDFs (qpdf)
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf
# Split pages
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
Quick Reference
| Task | Best Tool | Command/Code |
|---|---|---|
| Merge PDFs | pypdf | writer.add_page(page) |
| Split PDFs | pypdf | One page per file |
| Extract text | pdfplumber | page.extract_text() |
| Extract tables | pdfplumber | page.extract_tables() |
| Create PDFs | reportlab | Canvas or Platypus |
| OCR scanned PDFs | pytesseract | Convert to image first |
Scientific Skill Interleaving
This skill connects to the K-Dense-AI/claude-scientific-skills ecosystem:
Graph Theory
- networkx [○] via bicomodule
- Universal graph hub
Bibliography References
general: 734 citations in bib.duckdb
Cat# Integration
This skill maps to Cat# = Comod(P) as a bicomodule in the equipment structure:
Trit: 0 (ERGODIC)
Home: Prof
Poly Op: ⊗
Kan Role: Adj
Color: #26D826
GF(3) Naturality
The skill participates in triads satisfying:
(-1) + (0) + (+1) ≡ 0 (mod 3)
This ensures compositional coherence in the Cat# equipment structure.