Skip to main content

rustpdf (Python binding)

Idiomatic Python over the rust-pdf C ABI (libpdf_ffi). It mirrors the full product surface: vector graphics, embedded/subsetted fonts and text, wrapping paragraphs, images, PDF/A (levels 1b–3a), tagged/accessible output, embedded file attachments, AcroForm fields, manipulation (merge/split/rotate/optimize/incremental update), text extraction, page rendering (page to PNG image), encryption (RC4 / AES-128 / AES-256) and digital signatures (PKCS#7 / PAdES).

Two layers, per the project's porting strategy:

  • a raw ctypes surface bound 1:1 against include/pdf.h;
  • Document / EditableDoc wrappers that hide opaque handles, raise PdfError on non-zero status codes, and act as context managers.

Install

pip install rustpdf

Platform wheels (macOS arm64, manylinux_2_28 x86_64/aarch64, Windows x64) bundle the native libpdf_ffi library — no Rust toolchain needed to install. Basic PDF generation is free; corporate features (PDF/A, accessibility, encryption, signatures, page rendering) unlock with a license token via the RUSTPDF_LICENSE env var. Page rendering is a Pro feature. See https://rustpdf.dev.

Loading the native library

The wrapper finds libpdf_ffi in this order:

  1. $RUSTPDF_LIB (explicit path);
  2. bundled next to rustpdf/__init__.py (installed wheel);
  3. the build tree (target/debug then target/release).

Build it from the repo root with cargo build -p pdf-ffi.

Quick start

import rustpdf

# Author an accessible PDF/A-2a document.
with rustpdf.Document() as doc:
    doc.pdfa(rustpdf.PdfaLevel.A2A).set_info(title="Report", author="me")
    f = doc.add_font_file("assets/fonts/Roboto-Regular.ttf")
    doc.add_page()
    doc.show_text(f, 20, 72, 760, "Title", heading_level=1)
    doc.paragraph(f, 12, 72, 720, 450, "A wrapping, justified body…",
                  rustpdf.Align.JUSTIFY)
    data = doc.to_bytes()

print(rustpdf.extract_text(data))

# Render a page to a PNG image (Pro feature).
print(f"{rustpdf.page_count(data)} page(s)")
png = rustpdf.render_page_to_png(data, page=0, dpi=150.0)
open("page1.png", "wb").write(png)

# Manipulate an existing file (non-destructive incremental update).
with rustpdf.EditableDoc.load(data) as ed:
    ed.set_info("Subject", "Edited")
    updated = ed.to_bytes_incremental(data)

# Encrypt (AES-256).
with rustpdf.EditableDoc.load(data) as ed:
    ed.encrypt(owner="owner", method=rustpdf.Encryption.AES256)
    ed.save("secured.pdf")

# Sign (PKCS#7 detached / PAdES).
signed = rustpdf.sign(data, key_der, cert_der, reason="Approved", pades=True)

Testing

cargo build -p pdf-ffi
python3 bindings/python/test_binding.py    # dogfood + full-surface exercise
# or: make python-test

Metadata

Release files for rustpdf 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for rustpdf 0.4.0
File
rustpdf-0.4.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
rustpdf-0.4.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
rustpdf-0.4.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details
rustpdf-0.4.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 10.6 MB

Release files / rustpdf-0.4.0-py3-none-win_amd64.whl

Download URL rustpdf-0.4.0-py3-none-win_amd64.whl
Size 2.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
8a7dc1c736f729f0e912c70486294c92b6b90a2619f84efdeaa99c4bb99b1505
BLAKE2b-256 checksum
How to use checksums
28b707c57806cf3ee51e6ff65128118e0df5cb18846436fc64f8f3e9913e398a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.

Transparency log

Release files / rustpdf-0.4.0-py3-none-manylinux_2_28_x86_64.whl

Download URL rustpdf-0.4.0-py3-none-manylinux_2_28_x86_64.whl
Size 2.8 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
020c3aec287dd6e40977605dbcc84d6829e2f54db6894c6e8e91f7a6d0113d80
BLAKE2b-256 checksum
How to use checksums
4afb90f4dd7f103ccca6bc323e5f7d36fee725ba8ab90d4d8b1061eec0ebd989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.

Transparency log

Release files / rustpdf-0.4.0-py3-none-manylinux_2_28_aarch64.whl

Download URL rustpdf-0.4.0-py3-none-manylinux_2_28_aarch64.whl
Size 2.7 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2400d2c0e31651f392839b9dd45d1984b8819060cb3970877e6aedb8ec70ac9d
BLAKE2b-256 checksum
How to use checksums
9697e8aedd377e7c2ba54d5fda1c72fb4b198c59b129ba378a906faba5ded38a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.

Transparency log

Release files / rustpdf-0.4.0-py3-none-macosx_11_0_arm64.whl

Download URL rustpdf-0.4.0-py3-none-macosx_11_0_arm64.whl
Size 2.5 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
48e70d4b069dee2a85ad5aa7dad0eec0b9b34626e9e79e2ff71c77195ff02152
BLAKE2b-256 checksum
How to use checksums
75ea6520421ea8e3ad703e81ab50e1811bdaa6b8f4d01f221ea0a870f1512914
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

4 release files

0.4.8

4 release files

0.4.6

4 release files

0.4.5

4 release files

0.4.4

4 release files

0.4.3

4 release files

0.4.2

4 release files

0.4.1

4 release files

This release

0.4.0 This release

4 release files

0.2.0

4 release files

0.1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page