Metadata-Version: 2.5
Name: brevier
Version: 0.1.7
Summary: PDF generation from HTML, CSS and JSON: the Brevier engine and command line
Project-URL: Homepage, https://www.brevier.dev
Project-URL: Documentation, https://www.brevier.dev/docs
Project-URL: Pricing, https://www.brevier.dev/pricing
Author: Liviu Ionesi
License-Expression: BUSL-1.1
License-File: LICENSE
Keywords: din-5008,german,html-to-pdf,invoice,pdf,pdf-generation,pdf-library
Requires-Python: >=3.10
Requires-Dist: mistune>=3.0.0
Requires-Dist: pyphen==0.18.1
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: typer>=0.12.0
Requires-Dist: weasyprint==70.0
Provides-Extra: dev
Requires-Dist: attrs>=26.1.0; extra == 'dev'
Requires-Dist: django>=5.2.18; extra == 'dev'
Requires-Dist: interrogate==1.7.0; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pydantic>=2.14.0; extra == 'dev'
Requires-Dist: pydoclint==0.11.0; extra == 'dev'
Requires-Dist: pylint; extra == 'dev'
Requires-Dist: pypdf; extra == 'dev'
Requires-Dist: pyrefly==1.3.2; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: sqlalchemy>=2.0.54; extra == 'dev'
Description-Content-Type: text/markdown

# Brevier

[Website](https://www.brevier.dev) · [Docs](https://www.brevier.dev/docs) · [Pricing](https://www.brevier.dev/pricing)

> **Point Brevier at a template, or at a PDF you already have. Get a document that is already correct.**

Brevier is a modern, high-fidelity PDF generation library designed for developers who need perfect business documents, invoices, contracts, and reports without fighting legacy PDF APIs or proprietary design tools.

---

## Overview

Generating PDFs in enterprise systems is notoriously painful:
- **Hard to style & maintain**: iText, List & Label, or JasperReports force you into clunky GUI designers or walls of imperative drawing code.
- **Blind binding**: String-based field binding fails silently at runtime or on printed paper.
- **Ugly breaks & layout leaks**: Long compound words break wrong, headers fail to repeat, isolated headings sit alone at page bottoms, and developers put `\n` or `<br/>` into Java strings to force layout.
- **German typography challenges**: Strict compound word hyphenation rules, DIN 5008 standards, and missing font glyphs (`ß`, `€`, `„`).

**Brevier solves all of this.** It uses HTML and CSS as the single visible contract, compiles Markdown as a friendly front-end, handles German hyphenation natively, and verifies every page with a built-in visual linter.

---

## Key Features

- 📄 **HTML & Markdown Templates**: Edit clean HTML or Markdown (`.md`). Need multi-row headers or complex layouts? Write the template in HTML, which has no such ceiling.
- 🔄 **Bidirectional Codegen & Schema Hub**: Infer schemas from existing templates, then generate sample JSON, usage code, and Java/Python classes from them.
- 🇩🇪 **Ranked Hyphenation**: Compound-word boundary splitting (Duden rules) for German and English (`Ur-instinkt` instead of `Urin-stinkt`). Never more than 3 hyphenated lines in a row.
- 📊 **Table Mechanics & Übertrag**: Fixed column width ratios, repeating `<thead>` on every page, non-splitting rows, and automatic running totals (`Übertrag`) at page breaks.
- 📜 **Contracts & Fine Print**:
  - **Clause Numbering**: Automatic CSS counter numbering (`§ 1`, `§ 2`, `1.1`, `1.2`).
  - **Table of Contents**: Page numbers automatically calculated using `target-counter(attr(href), page)`.
  - **Small-Print Blocks**: Pre-configured `.small-print` class meeting legal legibility standards (7pt minimum font size).
- 🏷️ **Page Geometry & Counters**: Header/footer configuration in front-matter with dynamic page counters (`Seite 3 von 12`) and section title headers.
- 🧾 **Compliance & E-Invoicing**: Every document is PDF/A-3b compliant. Built-in support for ZUGFeRD / Factur-X e-invoices (EN 16931).
- 🔍 **The Visible Middle & Visual Linter**: Inspect exact HTML/CSS given to the engine (`--debug`). Automated linter detects text overflows, missing font glyphs, orphan headings, and hyphenation runs in CI.

---

## Installation

Brevier provides three simple installation channels across Linux, macOS, and Windows:

### 1. PyPI (pip)
```bash
pip install brevier
```

### 2. Docker
```bash
docker pull brevier/brevier:latest
docker run -p 5151:5151 brevier/brevier
```

### 3. One-Line Script Installer
```bash
# Linux / macOS
curl -fsSL https://get.brevier.dev | sh

# Windows (PowerShell)
iwr -useb https://get.brevier.dev/ps1 | iex
```

---

## Quickstart

### 1. Live Preview (planned)
```bash
brevier preview rechnung.md
```
Starts a local server at `http://localhost:5151` that re-renders automatically on save.

### 2. Render PDF
```bash
brevier pdf rechnung.md --data sample.json -o rechnung.pdf
```

---

## Usage Examples

### Java Client

```java
import dev.brevier.client.Brevier;
import dev.brevier.client.BrevierDocument;

public class InvoiceService {
    private final Brevier brevier = Brevier.connect("http://localhost:5151");

    public byte[] generateInvoice(Invoice invoice, Customer customer) {
        return brevier.template("rechnung")
                      .render(invoice, customer);
    }
}
```

### Python Client

```python
from brevier import BrevierEngine, render_pdf

engine = WeasyPrintEngine()
pdf_bytes = render_pdf(
    engine=engine, html_content=html_string, css_content=css_string, data={"rechnung": invoice_dict}
)
```

---

## Architecture Hub

```
   ┌── template HTML/MD ─────┐                     ┌──► HTML / Markdown Template (+ CSS)
   │                         │                     │
   ├── JSON sample ──────────┤                     ├──► Java / Python / TS Classes
   │                         ├──►  SCHEMA HUB  ────┤
   └── existing PDF (v2) ────┘     (JSON Schema)   ├──► Sample JSON Data
                                                   │
                                                   └──► 10-line Usage Example
```

### Rendering Pipeline

```
  template.md ──compile──►┐
                          ├──► HTML ──► bind {{ }} ──► Preparer (Hyphenation/nbsp) ──► Engine ──► PDF/A-3b
  template.html ─────────►┘                                   │
                                                              └──► Debug HTML written out (--debug)
```

---

## Business Model & Licensing

> **Testing is free. Production is not.**

- **Development & CI**: 100% Free. Test on developer laptops, CI build servers, and staging environments with synthetic data without restrictions or watermark.
- **Production Use**: Paid per production server with simple, published pricing on `brevier.dev`.
- **Air-Gap Friendly**: No phone-home checks, no license server, no AGPL supply chain risks.

---

## Contributing & Development

We follow Scrum discipline as defined in [`AGENTS.md`](https://github.com/liviuionesi/brevier/blob/main/AGENTS.md) and [`docs/process/METHODOLOGY.md`](https://github.com/liviuionesi/brevier/blob/main/docs/process/METHODOLOGY.md).

Please follow the [Code of Conduct](https://github.com/liviuionesi/brevier/blob/main/CODE_OF_CONDUCT.md). Report security problems as described in [SECURITY](https://github.com/liviuionesi/brevier/blob/main/SECURITY.md).

### Pre-commit & Pre-push Setup

```bash
git config core.hooksPath .githooks
```

### Running Tests & Quality Gates

```bash
# Run pytest suite
uv run pytest --ignore=tests/packaging

# Run Golden Render Gate
uv run python tests/golden_render_gate.py

# Run Linters and Type Checks
uv run ruff check
uv run ruff format --check
uv run mypy brevier tests
```

---

## License

Brevier is licensed under the [Business Source License (BSL 1.1)](https://github.com/liviuionesi/brevier/blob/main/LICENSE). See [PRD Section 12](https://github.com/liviuionesi/brevier/blob/main/docs/PRD.md#12-business-model) for details.
