Metadata-Version: 2.4
Name: deckle
Version: 1.0.0
Summary: Deckle - PDF generation API for developers. HTML in, pixel-perfect PDF out.
Project-URL: Homepage, https://getdeckle.dev
Project-URL: Documentation, https://getdeckle.dev/docs
Project-URL: Repository, https://github.com/Yoshyaes/deckle
Author: Deckle
License-Expression: MIT
Keywords: api,html-to-pdf,pdf,pdf-generation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Requires-Dist: pydantic>=2.0
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Requires-Dist: respx>=0.20; extra == 'test'
Description-Content-Type: text/markdown

# Deckle Python SDK

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

## Installation

```bash
pip install deckle
```

## Quick Start

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

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

## PDF Options

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

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

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

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