Generate, manipulate, sign and validate PDFs — Python binding for the rust-pdf core
Project description
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,
encryption (RC4 / AES-128 / AES-256) and digital signatures (PKCS#7 /
PAdES).
Two layers, per the project's porting strategy:
- a raw
ctypessurface bound 1:1 againstinclude/pdf.h; Document/EditableDocwrappers that hide opaque handles, raisePdfErroron 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) unlock with a license token via the RUSTPDF_LICENSE
env var. See https://rustpdf.dev.
Loading the native library
The wrapper finds libpdf_ffi in this order:
$RUSTPDF_LIB(explicit path);- bundled next to
rustpdf/__init__.py(installed wheel); - the build tree (
target/debugthentarget/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))
# 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
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 rustpdf-0.1.0-py3-none-win_amd64.whl.
File metadata
- Download URL: rustpdf-0.1.0-py3-none-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8228ccf8c1c099d4551b3a216b15b5b4ee28493d9355dc46158b68306ecd54c8
|
|
| MD5 |
4b22c12756f5b307dd48f15a8df9a678
|
|
| BLAKE2b-256 |
0599be4e5b78156d3efb9fde1c280e140eefd545ab4557ae0bcad7c095114e08
|
Provenance
The following attestation bundles were made for rustpdf-0.1.0-py3-none-win_amd64.whl:
Publisher:
release-python.yml on rustpdf/rustpdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpdf-0.1.0-py3-none-win_amd64.whl -
Subject digest:
8228ccf8c1c099d4551b3a216b15b5b4ee28493d9355dc46158b68306ecd54c8 - Sigstore transparency entry: 1980331562
- Sigstore integration time:
-
Permalink:
rustpdf/rustpdf@173706534c5eb5252748847c06801bd4cd03dd03 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/rustpdf
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@173706534c5eb5252748847c06801bd4cd03dd03 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustpdf-0.1.0-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rustpdf-0.1.0-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed93a8c4a167cb465d27ad86d19fa67c2dd7bed159a2acbf51f5ebadea05d0bf
|
|
| MD5 |
2eee87f1079fd632fddb302a0cf1c8c3
|
|
| BLAKE2b-256 |
131f275ed3c980056cb742693ca5eb6dc0ee8ba0a5efc7a13a635c536a017859
|
Provenance
The following attestation bundles were made for rustpdf-0.1.0-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
release-python.yml on rustpdf/rustpdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpdf-0.1.0-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
ed93a8c4a167cb465d27ad86d19fa67c2dd7bed159a2acbf51f5ebadea05d0bf - Sigstore transparency entry: 1980331389
- Sigstore integration time:
-
Permalink:
rustpdf/rustpdf@173706534c5eb5252748847c06801bd4cd03dd03 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/rustpdf
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@173706534c5eb5252748847c06801bd4cd03dd03 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustpdf-0.1.0-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: rustpdf-0.1.0-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f5e669dc9d90359d9e632c84e30cb7609efa91b08a3a71b0d56f5907fc20cb8
|
|
| MD5 |
1139471900b64f2f01aaae6bb6bd9e90
|
|
| BLAKE2b-256 |
afdfdb45650ec30d316734a30c6a1b4c7220ac5c642a57d372fa822a937c58eb
|
Provenance
The following attestation bundles were made for rustpdf-0.1.0-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
release-python.yml on rustpdf/rustpdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpdf-0.1.0-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
5f5e669dc9d90359d9e632c84e30cb7609efa91b08a3a71b0d56f5907fc20cb8 - Sigstore transparency entry: 1980331735
- Sigstore integration time:
-
Permalink:
rustpdf/rustpdf@173706534c5eb5252748847c06801bd4cd03dd03 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/rustpdf
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@173706534c5eb5252748847c06801bd4cd03dd03 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustpdf-0.1.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustpdf-0.1.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a3ee5589f794d80b6a3bdd7c8a3064a2422a49f0ab215c3b8182c3b1a94c440
|
|
| MD5 |
584b416c30248e06cf03d8b9dc339beb
|
|
| BLAKE2b-256 |
11f82983d7e1f7b91cacbfb6cfdeb408211a17623e6b9b73dc1cf8f49a1bf7cd
|
Provenance
The following attestation bundles were made for rustpdf-0.1.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
release-python.yml on rustpdf/rustpdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustpdf-0.1.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
0a3ee5589f794d80b6a3bdd7c8a3064a2422a49f0ab215c3b8182c3b1a94c440 - Sigstore transparency entry: 1980331227
- Sigstore integration time:
-
Permalink:
rustpdf/rustpdf@173706534c5eb5252748847c06801bd4cd03dd03 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/rustpdf
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@173706534c5eb5252748847c06801bd4cd03dd03 -
Trigger Event:
push
-
Statement type: