Python PDF toolkit — merge, split, rotate, compress, extract text, encrypt, decrypt, and 14 more operations. Powered by pypdf.
Project description
peasy-pdf
Python PDF toolkit — merge, split, rotate, compress, extract text, encrypt, decrypt, and 14 more operations. Powered by pypdf.
Try the interactive tools at peasypdf.com — Merge PDF, Split PDF, Compress PDF
Install
pip install peasy-pdf
With extras:
pip install "peasy-pdf[cli]" # CLI with typer + rich
pip install "peasy-pdf[mcp]" # MCP server for AI assistants
pip install "peasy-pdf[api]" # REST API client for peasypdf.com
pip install "peasy-pdf[all]" # Everything
Quick Start
from peasy_pdf import merge, split, rotate, compress, info, extract_text
# Merge multiple PDFs
merged = merge("report1.pdf", "report2.pdf")
# Split into individual pages
pages = split("document.pdf")
# Split every 5 pages
chunks = split("document.pdf", every=5)
# Rotate all pages 90°
rotated = rotate("document.pdf", angle=90)
# Compress to reduce file size
compressed = compress("large-file.pdf")
# Get PDF info
pdf_info = info("document.pdf")
print(f"Pages: {pdf_info.pages}, Title: {pdf_info.title}")
# Extract text
text = extract_text("document.pdf", pages="1-3")
print(text.full_text)
What You Can Do
Page Manipulation
| Function | Description |
|---|---|
merge() |
Merge multiple PDFs into one |
split() |
Split by page ranges or every N pages |
rotate() |
Rotate pages (90°, 180°, 270°) |
reorder() |
Reorder pages in any sequence |
reverse() |
Reverse the page order |
delete_pages() |
Remove specific pages |
extract_pages() |
Extract specific pages |
odd_even() |
Filter odd or even pages |
duplicate_pages() |
Duplicate specific pages |
insert_blank() |
Insert blank pages at positions |
Document Operations
| Function | Description |
|---|---|
compress() |
Compress PDF streams to reduce size |
resize() |
Resize pages to standard sizes (A4, Letter, etc.) |
crop() |
Crop page margins |
flatten() |
Flatten form fields (make non-editable) |
Text & Metadata
| Function | Description |
|---|---|
extract_text() |
Extract text with per-page breakdown |
info() |
Get page count, metadata, encryption status |
get_metadata() |
Read PDF metadata |
set_metadata() |
Update PDF metadata |
strip_metadata() |
Remove all metadata |
Security
| Function | Description |
|---|---|
encrypt() |
Add password protection |
decrypt() |
Remove password protection |
Page Specs
All page-aware functions use 1-indexed page specs:
rotate("doc.pdf", pages="1") # Page 1 only
rotate("doc.pdf", pages="1,3,5") # Pages 1, 3, and 5
rotate("doc.pdf", pages="2-5") # Pages 2 through 5
rotate("doc.pdf", pages="1,3-5,8") # Mixed
rotate("doc.pdf", pages="all") # All pages (default)
Input Flexibility
Every function accepts bytes, Path, or str (file path):
from pathlib import Path
# File path as string
result = info("document.pdf")
# pathlib.Path
result = info(Path("document.pdf"))
# Raw bytes (e.g., from an HTTP response)
pdf_bytes = response.content
result = info(pdf_bytes)
Command-Line Interface
pip install "peasy-pdf[cli]"
peasy-pdf merge file1.pdf file2.pdf -o merged.pdf
peasy-pdf split doc.pdf --every 5 -o split_
peasy-pdf rotate doc.pdf --angle 90 -o rotated.pdf
peasy-pdf compress doc.pdf -o compressed.pdf
peasy-pdf info doc.pdf
peasy-pdf text doc.pdf --pages 1-3
peasy-pdf encrypt doc.pdf --password secret -o encrypted.pdf
peasy-pdf decrypt encrypted.pdf --password secret -o decrypted.pdf
peasy-pdf metadata doc.pdf --title "New Title" --author "Author" -o updated.pdf
MCP Server (Claude, Cursor, Windsurf)
pip install "peasy-pdf[mcp]"
Configure in Claude Desktop:
{
"mcpServers": {
"peasy-pdf": {
"command": "uvx",
"args": ["--from", "peasy-pdf[mcp]", "python", "-m", "peasy_pdf.mcp_server"]
}
}
}
REST API Client
from peasy_pdf.api import PeasyPdfAPI
api = PeasyPdfAPI()
tools = api.list_tools()
glossary = api.search("compress")
Learn More About PDF
- Tools: Merge PDF · Split PDF · Compress PDF
- Guides: PDF Glossary · PDF Guides
- API: Developer Docs · OpenAPI Spec
Peasy Developer Tools
| Package | PyPI | Description |
|---|---|---|
| peasy-pdf | PyPI | PDF merge, split, compress, 21 operations — peasypdf.com |
| peasytext | PyPI | Text case, slug, word count, 15 operations — peasytext.com |
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file peasy_pdf-0.1.0.tar.gz.
File metadata
- Download URL: peasy_pdf-0.1.0.tar.gz
- Upload date:
- Size: 78.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f3b5463244cd0a51ab7217a2b075e2a8b1f8102f2b2260a8f8a1f375555a8fa
|
|
| MD5 |
3815ccfac0e2c6dd76ac278f92bab336
|
|
| BLAKE2b-256 |
76711bb1c8167a6a2f8fa5ddee2e04d22d6b0fe15c0c7981eed48381f157d9e4
|
File details
Details for the file peasy_pdf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: peasy_pdf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8990719d9895cb31ed0fa1decc2f941ef775b28dc72f67c58b9f88fd452c549
|
|
| MD5 |
9a89171c0f227fc5d9ca4bf4605de391
|
|
| BLAKE2b-256 |
ff9f40c4edd61b672b56efa601751e99bbbf7056987af07d2afecac35aad1758
|