Skip to main content

CLI tool to compress and merge PDFs (Rust backend via PyO3)

Project description

PDF Manipulator (pdfman)

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/pdfman-*.whl

CLI Usage

rustypdf --help

pdfman compress --input input.pdf --output out.pdf --scale 7
rustypdf compress --input input.pdf --output out.pdf --scale 7

pdfman merge --inputs a.pdf b.pdf c.pdf --output merged.pdf
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 compress will 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rustypdf-0.1.0-cp312-none-win_amd64.whl (585.3 kB view details)

Uploaded CPython 3.12Windows x86-64

rustypdf-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (808.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

rustypdf-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (606.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file rustypdf-0.1.0-cp312-none-win_amd64.whl.

File metadata

  • Download URL: rustypdf-0.1.0-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

Hashes for rustypdf-0.1.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 f78a09f85d1e6e56175e552b49a282d87c41e3353621a938205e1640c4be1d07
MD5 edf8ec0df01684d33aebda62b9899d49
BLAKE2b-256 50c8f5c0df7c4de27fe82c41bd938277e566a15d945b20a8b14451c485f5a478

See more details on using hashes here.

File details

Details for the file rustypdf-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rustypdf-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e489edd889cf0ad61105758bbacaafb74cae4bfb4ed29ff187b4bc9008f8152d
MD5 42584520ab1f01a7285211164e7e7c25
BLAKE2b-256 418df9e15c6ded2024a1c0008e09c534f35b759cf11a2fe0c29cd7a7c94ffd90

See more details on using hashes here.

File details

Details for the file rustypdf-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustypdf-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 828cbf0e4a138a86afb296654c19cabe9d68307d23b4a18b138921a182c5682c
MD5 581da9c2ff7d25f80dc69ef2d5696f3d
BLAKE2b-256 7ae6abdf3a731c9575c8721a64685f09673d07a84fb00b59386f1105dbff4e2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page