# `Accrue.PDF`
[🔗](https://github.com/szTheory/accrue/blob/accrue-v0.3.0/lib/accrue/pdf.ex#L1)

Behaviour + facade for PDF rendering (PDF-01, D-32).

Callers pass pre-rendered HTML + opts; the adapter returns a binary
PDF body. Two adapters ship with Phase 1:

- `Accrue.PDF.ChromicPDF` — production default. Delegates to the host
  application's ChromicPDF instance. **Accrue does NOT start ChromicPDF**
  (D-33, Pitfall #4) — the host app starts it in its own supervision tree.
- `Accrue.PDF.Test` — Chrome-free test adapter. Sends
  `{:pdf_rendered, html, opts}` to `self()` and returns `{:ok, "%PDF-TEST"}`
  (D-34). Use in tests to avoid Chrome binary dependency.

## Telemetry (T-PDF-01)

`[:accrue, :pdf, :render, :start | :stop | :exception]` is emitted with
metadata `%{size, archival, adapter}`. The HTML body is NEVER placed in
metadata — it may contain PII.

# `html`

```elixir
@type html() :: binary()
```

# `opts`

```elixir
@type opts() :: keyword()
```

# `render`

```elixir
@callback render(html(), opts()) :: {:ok, binary()} | {:error, term()}
```

# `render`

```elixir
@spec render(html(), opts()) :: {:ok, binary()} | {:error, term()}
```

Renders `html` to a PDF binary via the configured adapter.

## Options

- `:size` — paper size (atom or tuple, adapter-specific). Default `:a4`.
- `:archival` — when `true`, produces PDF/A (long-term archival format).
  ChromicPDF uses `print_to_pdfa/1` in this case.
- `:header_html`, `:footer_html` — optional header/footer HTML. The
  ChromicPDF adapter translates these to the `:header`/`:footer` keys
  that `ChromicPDF.Template.source_and_options/1` expects (RESEARCH
  Summary point 5).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
