Skip to main content

Deckle Python SDK

PDF generation API for developers. HTML in, pixel-perfect PDF out.

Installation

pip install deckle

Quick Start

from deckle import Deckle

df = Deckle("dk_live_...")

# Generate a PDF from HTML
pdf = df.generate(
    html="<h1>Invoice #1234</h1><p>Amount: $500</p>",
    options={"format": "A4", "margin": "1in"}
)

print(pdf.url)    # https://cdn.getdeckle.dev/gen_abc123.pdf
print(pdf.pages)  # 2

Generate from Template

pdf = df.from_template(
    template="tmpl_invoice_v2",
    data={
        "company": "Acme Corp",
        "items": [
            {"description": "Consulting", "qty": 10, "rate": 150}
        ],
        "total": 1500
    }
)

PDF Options

from deckle import PDFOptions

pdf = df.generate(
    html=invoice_html,
    options=PDFOptions(
        format="A4",
        margin="1in",
        orientation="portrait",
        header="<div>Acme Corp</div>",
        footer="<div>Page {{pageNumber}} of {{totalPages}}</div>",
        print_background=True
    )
)

Templates

# Create
template = df.templates.create(
    name="Invoice",
    html_content="<h1>Invoice for {{company}}</h1>",
    schema={"company": "string", "total": "number"}
)

# List
templates = df.templates.list()

# Update
df.templates.update("tmpl_abc123", html_content="<h1>Updated</h1>")

# Delete
df.templates.delete("tmpl_abc123")

Error Handling

from deckle import Deckle, DeckleError, RateLimitError

try:
    pdf = df.generate(html="<h1>Hello</h1>")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except DeckleError as e:
    print(f"Error {e.code}: {e.message}")

Development

pip install -e ".[test]"
pytest                   # run the test suite (httpx requests are stubbed via respx)
make test                # same, via the project's Makefile

License

MIT

Metadata

Release files for deckle 1.0.0

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

Source distribution (sdist)

Source distribution for deckle 1.0.0
File Size Uploaded Provenance Actions
deckle-1.0.0.tar.gz 10.6 kB Without provenance Details for deckle-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for deckle 1.0.0
File Interpreter ABI Platform Actions
deckle-1.0.0-py3-none-any.whl Python 3 none any Details for deckle-1.0.0-py3-none-any.whl

Total release size: 19.9 kB

Release files / deckle-1.0.0.tar.gz

Download URL deckle-1.0.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7526f325d0bdcb9397c647f0c9b8011891a8e9c8d4e0219313bb6a959c14602c
BLAKE2b-256 checksum
How to use checksums
567ab3a3f02e64d26ab3cc673752145cb3829da079dfd103765b7a19a9d798b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / deckle-1.0.0-py3-none-any.whl

Download URL deckle-1.0.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8c139b0b23cf35db2cece1e96a4ba4b6075d3d50539a94c8d163cd6ac1fe622
BLAKE2b-256 checksum
How to use checksums
93fa38921fe37bdb8cd91eeca835869653b1b46aa751f345434642d29ef5f3ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for deckle 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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