PDF Toolkit
Manipulate and read PDF files using open-source Python libraries:
pypdf (BSD) for page operations,
pdfplumber (MIT) for text/table
extraction, and OCRmyPDF (MPL-2.0)
for OCR.
When to Use
- Extract text or tables from a PDF.
- Merge several PDFs into one, or split / extract page ranges.
- Rotate pages or add a watermark/stamp.
- OCR a scanned (image-only) PDF to make it searchable.
For converting a PDF to clean Markdown for analysis, prefer the
markitdown-converterskill. Use this skill for structural PDF operations.
Setup
pip install pypdf pdfplumber
# OCR (optional) also needs the system tools:
pip install ocrmypdf # plus Tesseract + Ghostscript installed
How to Use
A bundled CLI (scripts/pdf_tools.py) covers the common operations:
# merge
python scripts/pdf_tools.py merge a.pdf b.pdf c.pdf -o combined.pdf
# split into one file per page, OR extract specific ranges
python scripts/pdf_tools.py split in.pdf -o pages_dir/
python scripts/pdf_tools.py split in.pdf --ranges 1-3 8 10-12 -o excerpt.pdf
# rotate (90/180/270)
python scripts/pdf_tools.py rotate in.pdf --deg 90 -o rotated.pdf
# extract text (stdout or -o file)
python scripts/pdf_tools.py text in.pdf -o out.txt
# watermark every page with a 1-page stamp PDF
python scripts/pdf_tools.py watermark in.pdf --stamp mark.pdf -o stamped.pdf
Tables
For table extraction, use pdfplumber directly — it exposes per-page tables:
import pdfplumber
with pdfplumber.open("report.pdf") as pdf:
for page in pdf.pages:
for table in page.extract_tables():
print(table) # list of rows
OCR a scanned PDF
ocrmypdf input_scanned.pdf output_searchable.pdf
This adds a searchable text layer (requires Tesseract + Ghostscript installed on the system).
Notes & Limits
pypdfhandles structure (pages, rotation, merge, overlays) but does not re-flow or re-render content.pdfplumberreads the embedded text layer; for image-only PDFs run OCR first.- Encrypted PDFs may need a password (
PdfReader(path).decrypt(pw)).
Credits
Original skill by Rinu (l3ad3r1) in collaboration with Claude (Anthropic). Powered by pypdf (BSD-3-Clause), pdfplumber (MIT), and OCRmyPDF (MPL-2.0). All credit for the underlying capabilities belongs to those projects' authors.