Skip to main content

RustPdf for Python

Generate, edit, sign and process PDFs from Python: vector graphics, embedded fonts and Unicode text, wrapping paragraphs, images, PDF/A (1b-4f), tagged/accessible output, attachments, AcroForm fields, page manipulation (merge/split/stamp), watermarks, true redaction, AES-256 encryption, digital signatures (PAdES) with HSM/deferred signing, timestamps/LTV, text extraction and search, and page rendering to PNG. Pure Python package, no compiler needed.

Documentation

The public API is Document (create PDFs) and EditableDoc (load and edit existing PDFs), both usable as context managers; errors raise PdfError.

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)

# Deferred / HSM signing: the private key never enters the library.
# The library builds the CMS signed attributes and asks your signer for the
# raw RSA signature. `sign_hash` can call any HSM, cloud KMS, smartcard or
# PKI token (national PKI / eIDAS / AATL).
def sign_hash(to_be_signed: bytes) -> bytes:
    return my_hsm.sign(to_be_signed)   # raw RSA PKCS#1 v1.5 over SHA-256

signed = rustpdf.sign_with(data, cert_der, sign_hash, chain=[intermediate_der])

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.8

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.8
File
rustpdf-0.4.8-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
rustpdf-0.4.8-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
rustpdf-0.4.8-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details
rustpdf-0.4.8-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 11.2 MB

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

Download URL rustpdf-0.4.8-py3-none-win_amd64.whl
Size 2.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
485b261d787f9e66936475c629ee0d97d9f1e07bc8ddeff266b06a88512bf836
BLAKE2b-256 checksum
How to use checksums
89abc09360acd65651bf48a2193086bba8ebac9296e529c5561e9e282ce333ce
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 Jul 2, 2026.

Transparency log

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

Download URL rustpdf-0.4.8-py3-none-manylinux_2_28_x86_64.whl
Size 3.0 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
8c0025b05d53ac92d5242b416e067b41fa7fb3850e0782bd8ffc6f33c5f902e2
BLAKE2b-256 checksum
How to use checksums
6c6dbb67b18359278f4e650a935787072b4184a70ecfe91cb0a05375631189ca
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 Jul 2, 2026.

Transparency log

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

Download URL rustpdf-0.4.8-py3-none-manylinux_2_28_aarch64.whl
Size 2.8 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b50fbc56bcbe848962044b96bbcd674ffa1d30ca5370c9dca49ae6272b12f6fd
BLAKE2b-256 checksum
How to use checksums
0e275b02496050a834e7f09f9a2339004c06812ab394250db10594cd793c1d82
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 Jul 2, 2026.

Transparency log

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

Download URL rustpdf-0.4.8-py3-none-macosx_11_0_arm64.whl
Size 2.7 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8114c55d91ce6d6e1ef1de09fa9c27bdf75c63dcc4f86a7f181b256a66d6e057
BLAKE2b-256 checksum
How to use checksums
2cd0f6e4593c397fe92d34f401972376515a8623e98ef93925cc41e455fd6aed
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 Jul 2, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

4 release files

This release

0.4.8 This release

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

0.4.0

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