Metadata-Version: 2.4
Name: rustpdf
Version: 0.2.0
Summary: Generate, manipulate, sign and validate PDFs — Python binding for the rust-pdf core
Author-email: rust-pdf <edivanteixeira@gmail.com>
License: rust-pdf — Proprietary Software License
        =======================================
        
        Copyright (c) 2026 rust-pdf. All rights reserved.
        
        This software and its source code (the "Software") are proprietary and
        confidential. Basic PDF generation is available free of charge; corporate
        features (PDF/A, accessibility/tagged output, encryption and digital
        signatures) require a valid, paid license token activated at runtime.
        
        Subject to the terms of a separate commercial agreement, you are granted a
        non-exclusive, non-transferable right to use the Software. You may NOT, without
        prior written permission:
        
          * redistribute, sublicense, sell or lease the Software;
          * reverse engineer, decompile or disassemble the native components, except to
            the extent such restriction is prohibited by applicable law;
          * remove or alter any proprietary notices.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
        FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
        COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
        IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
        CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
        For licensing inquiries, contact: edivanteixeira@gmail.com
        
Project-URL: Homepage, https://rustpdf.dev
Project-URL: Documentation, https://rustpdf.dev/docs/python
Project-URL: Repository, https://github.com/rustpdf/rustpdf
Project-URL: Issues, https://github.com/rustpdf/rustpdf/issues
Keywords: pdf,pdf/a,pdf/ua,accessibility,signature,acroform
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Office/Business
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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 `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

```sh
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:

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

```python
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

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