CLI tool to compress and merge PDFs (Rust backend via PyO3)
Project description
RustyPDF (rustypdf)
CLI tool to compress and merge PDF files using a Rust backend exposed to Python via PyO3/maturin.
Features
compress: Reduce embedded image dimensions (PNG) with a scale factor (1-10). Placeholder JPEG handling.merge: Concatenate multiple PDFs preserving page order.
Installation (local build)
pip install maturin
maturin develop # or: maturin build --release && pip install target/wheels/rustypdf-*.whl
CLI Usage
rustypdf --help
rustypdf compress --input input.pdf --output out.pdf --scale 7
rustypdf merge --inputs a.pdf b.pdf c.pdf --output merged.pdf
Scale meaning: 1 = minimal compression, 10 = maximum (down to ~25% linear dimension for PNG images). JPEG currently left unchanged (placeholder logic).
Python API
from rustypdf import compress_pdf, merge_pdfs
merge_pdfs(["a.pdf", "b.pdf"], "merged.pdf")
compress_pdf("in.pdf", "out.pdf", 5)
Notes / Limitations
- Compression is basic and may not always reduce file size, especially for PDFs with already-compressed JPEGs or complex content.
rustypdf compresswill automatically detect Ghostscript and, if missing, will best-effort install it using the platform package manager:- Linux: apt/dnf/yum/zypper/pacman (requires appropriate privileges)
- macOS: Homebrew (
brew) or MacPorts (port) - Windows: winget/chocolatey/scoop If installation fails or permissions are insufficient, the command falls back to Rust-only compression and prints a note.
- Not all PDFs may be supported; complex structures or encrypted PDFs are out of scope for this minimal example.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 rustypdf-0.1.1-cp312-none-win_amd64.whl.
File metadata
- Download URL: rustypdf-0.1.1-cp312-none-win_amd64.whl
- Upload date:
- Size: 585.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f07f487f1962f226d1ccede51781b4e90a2fa3929af58f9329d414b89c04d89c
|
|
| MD5 |
833d7ff508360261b1bb9390f5a89ff6
|
|
| BLAKE2b-256 |
02585a901785cca534bad5077eb6769f926ab0d5b76dfb14c8231a0c9129c2f0
|
File details
Details for the file rustypdf-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: rustypdf-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 808.4 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7455b2dc00885b8b3bffc4902d81b7faa8800d44e5c547456257ad45c671d68e
|
|
| MD5 |
830b8065be07f38127b2cc0b40a441a6
|
|
| BLAKE2b-256 |
4c7f829d896f43a50cf3f7fae44e053d5bd2071ae862ee5fd4cb6f8ac04c43ee
|
File details
Details for the file rustypdf-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustypdf-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 606.1 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f397bf0fcbcd6d6d95cb071ece878d3a007946d0617ac752f87523fd13ba9d0a
|
|
| MD5 |
49d1ecdbfdbf9a995fd19f6394a830b3
|
|
| BLAKE2b-256 |
3a5353f87261ca16438369f8778300ff12c1b9ea6d9f4ebc6a182ef03c94e16f
|