Rendro.Recipes.Certificate (Rendro v1.0.0) (adapter)

Copy Markdown View Source

Data-driven certificate recipe for completion, compliance, and award certificates.

All region coordinates are derived from template geometry — zero hardcoded A4 numerics. The default orientation is landscape (classic diploma/award look). Portrait is reachable by passing orientation: :portrait.

Branding is optional: an unbranded certificate renders fine with default fonts and no logo. When data.brand is present, the font and image are registered via Rendro.Document.register_embedded_font/3 and Rendro.Document.register_image/3, mirroring BrandedInvoice.

Required data keys

  • :title — certificate title, e.g. "Certificate of Completion"
  • :recipient — recipient name, e.g. "Jane Smith"
  • :date — issue date (Date.t())

Optional data keys

  • :body — body statement text (default "")
  • :seal_line — signature / seal line (default "")
  • :brand%{font_name: atom(), logo_name: atom()} for branded output

Border frame option

The border: option adds a decorative keyline frame to the certificate. All frame geometry is derived from page dimensions and margins — zero hardcoded numerics.

  • border: false (default) — no frame; output is byte-identical to prior output
  • border: true — single near-ink keyline ({34, 34, 34}), geometry-derived
  • border: %{...} — map with any subset of override keys:
    • :color{r, g, b} integer tuple (0–255), default {34, 34, 34}
    • :style:single (default) or :double
    • :inset — float in pt, default 0.5 * min(margins)
    • :weight — line width in pt, default max(1.0, short / 400)
    • :gap — gap between rules for :double style, default 0

Examples

iex> template = Rendro.Recipes.Certificate.page_template()
iex> template.width > template.height   # landscape default
true

iex> data = %{title: "Certificate of Completion", recipient: "Jane Smith", date: ~D[2026-05-29]}
iex> doc = Rendro.Recipes.Certificate.document(data)
iex> doc.page_template
:certificate

Summary

Functions

Assembles and returns a fully composed %Rendro.Document{} ready for Rendro.render/2.

Returns a %Rendro.PageTemplate{} with geometry derived from the page size and orientation options. Default is A4 landscape.

Returns a list of %Rendro.Section{} structs for the certificate body.

Functions

document(data, opts \\ [])

@spec document(
  map(),
  keyword()
) :: Rendro.Document.t()

Assembles and returns a fully composed %Rendro.Document{} ready for Rendro.render/2.

Options

All options from page_template/1 are supported. Additionally:

  • :page_number_opts — options forwarded to Rendro.page_number/1 (unused for single-page certificates; included for API consistency)
  • :borderfalse (default), true, or a border options map (see module docs)

Examples

iex> data = %{title: "Certificate of Completion", recipient: "Jane Smith", date: ~D[2026-05-29]}
iex> doc = Rendro.Recipes.Certificate.document(data)
iex> doc.page_template
:certificate

page_template(opts \\ [])

@spec page_template(keyword()) :: Rendro.PageTemplate.t()

Returns a %Rendro.PageTemplate{} with geometry derived from the page size and orientation options. Default is A4 landscape.

Options

  • :page_size:a4 (default) or :us_letter, or {width, height} tuple
  • :orientation:landscape (default) or :portrait
  • :margin_top / :margin_right / :margin_bottom / :margin_left — margin in pt (default 72)
  • :name — template name atom (default :certificate)
  • :borderfalse (default), true, or a border options map

Examples

iex> t = Rendro.Recipes.Certificate.page_template()
iex> t.width > t.height
true

iex> t = Rendro.Recipes.Certificate.page_template(orientation: :portrait)
iex> t.height > t.width
true

sections(data, opts \\ [])

@spec sections(
  map(),
  keyword()
) :: [Rendro.Section.t()]

Returns a list of %Rendro.Section{} structs for the certificate body.

Examples

iex> data = %{title: "Certificate of Completion", recipient: "Jane Smith", date: ~D[2026-05-29]}
iex> sections = Rendro.Recipes.Certificate.sections(data)
iex> length(sections) > 0
true