Rendro (Rendro v1.0.0) (stable)

Copy Markdown View Source

Pure-Elixir, Phoenix-first PDF/document generation with deterministic layout and pagination.

Summary

Functions

Creates a fixed-position document from a list of pages.

Creates a flow document from a list of content blocks.

Wraps exactly one authored block with a curated external URI or internal page target.

Returns {header_height, row_heights} (in points) for rows laid out as a Rendro.table/2 of total width, using document's font metrics.

Sets the default logical font for a document.

Registers a document-level embedded file on a document.

Registers an explicit embedded font source on a document.

Registers a four-variant embedded font family on a document.

Registers a logical font name on a document.

Renders the document to an artifact and then applies the configured protection adapter.

Renders the document to an artifact and then applies the configured signing adapter.

Renders the document and returns a Rendro.Artifact which contains the PDF binary, a deterministic hash, diagnostics, and metadata.

Renders the document and returns the binary along with the fully populated document struct. Useful for inspecting layout or reading populated diagnostics.

Types

render_option()

@type render_option() ::
  {:output, Path.t()} | {:deterministic, boolean()} | {:shaper, module()}

render_options()

@type render_options() :: [render_option()]

Functions

block(content, attrs \\ [])

@spec block(
  Rendro.Text.t() | term(),
  keyword()
) :: Rendro.Block.t()

document(attrs \\ [])

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

fixed(pages, opts \\ [])

@spec fixed(
  [Rendro.Page.t()],
  keyword()
) :: Rendro.Document.t()

Creates a fixed-position document from a list of pages.

flow(content, opts \\ [])

@spec flow(
  [Rendro.Block.t()],
  keyword()
) :: Rendro.Document.t()

Creates a flow document from a list of content blocks.

form_field(name, value \\ "", attrs \\ [])

@spec form_field(String.t(), String.t(), keyword()) :: Rendro.Block.t()

link(block, opts)

@spec link(
  Rendro.Block.t(),
  keyword()
) :: Rendro.Block.t()

Wraps exactly one authored block with a curated external URI or internal page target.

measure_rows(rows, width, document, table_opts \\ [])

@spec measure_rows([Rendro.Table.row()], number(), Rendro.Document.t(), keyword()) ::
  {number(), [number()]}

Returns {header_height, row_heights} (in points) for rows laid out as a Rendro.table/2 of total width, using document's font metrics.

This is a read-only projection of the engine's OWN table measurement: it builds an ephemeral table, measures it through the same private measurement logic the paginator uses, and returns the geometry. It does not paginate, render, cache, or mutate any engine state, so PAGE-04 single-pass behavior is unchanged.

It exists so recipes can chunk transaction rows by the engine's actual row heights — rather than a recipe-local estimate that would drift into :content_overflow — and therefore place page breaks and carried/brought-forward rows on the correct pages.

table_opts are forwarded to Rendro.table/2 (e.g. :header, :columns). Raises ArgumentError if the table cannot be measured (e.g. unsupported glyph).

metadata(attrs \\ [])

@spec metadata(keyword()) :: Rendro.Metadata.t()

page(attrs \\ [])

@spec page(keyword()) :: Rendro.Page.t()

page_number(opts \\ [])

@spec page_number(keyword()) :: Rendro.Block.t()

page_template(attrs \\ [])

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

path(ops, attrs \\ [])

@spec path(
  [term()],
  keyword()
) :: Rendro.Block.t()

put_default_font(doc, logical_name)

Sets the default logical font for a document.

region(attrs \\ [])

@spec region(keyword()) :: Rendro.Region.t()

register_embedded_file(doc, logical_name, source, metadata)

@spec register_embedded_file(
  Rendro.Document.t(),
  atom(),
  {:path, Path.t()} | {:binary, binary()},
  keyword()
) :: Rendro.Document.t()

Registers a document-level embedded file on a document.

register_embedded_font(doc, logical_name, source)

@spec register_embedded_font(
  Rendro.Document.t(),
  Rendro.FontRegistry.logical_name(),
  {:path, Path.t()} | {:binary, binary()}
) :: Rendro.Document.t()

Registers an explicit embedded font source on a document.

register_embedded_font_family(doc, family_name, variants)

@spec register_embedded_font_family(
  Rendro.Document.t(),
  Rendro.FontRegistry.logical_name(),
  %{
    required(Rendro.FontRegistry.embedded_variant()) =>
      {:path, Path.t()} | {:binary, binary()}
  }
) :: Rendro.Document.t()

Registers a four-variant embedded font family on a document.

register_font(doc, logical_name, opts)

Registers a logical font name on a document.

render(doc, opts \\ [])

@spec render(Rendro.Document.t(), render_options()) ::
  {:ok, binary()} | {:error, Rendro.Error.t()}

render_protected(doc, render_opts \\ [], protect_opts)

@spec render_protected(Rendro.Document.t(), render_options(), keyword()) ::
  {:ok, Rendro.Artifact.t()} | {:error, Rendro.Error.t()}

Renders the document to an artifact and then applies the configured protection adapter.

render_signed(doc, render_opts \\ [], sign_opts)

@spec render_signed(Rendro.Document.t(), render_options(), keyword()) ::
  {:ok, Rendro.Artifact.t()} | {:error, Rendro.Error.t()}

Renders the document to an artifact and then applies the configured signing adapter.

render_to_artifact(doc, opts \\ [])

@spec render_to_artifact(Rendro.Document.t(), render_options()) ::
  {:ok, Rendro.Artifact.t()} | {:error, Rendro.Error.t()}

Renders the document and returns a Rendro.Artifact which contains the PDF binary, a deterministic hash, diagnostics, and metadata.

render_with_diagnostics(doc, opts \\ [])

@spec render_with_diagnostics(Rendro.Document.t(), render_options()) ::
  {:ok, binary(), Rendro.Document.t()} | {:error, Rendro.Error.t()}

Renders the document and returns the binary along with the fully populated document struct. Useful for inspecting layout or reading populated diagnostics.

final_doc.diagnostics is a list of user-inspectable structured maps. Stable common keys such as :level and :type are present on every entry, while event-specific optional keys may include :message, :page_index, :reason, and :keep_rule. This is the developer-facing layout-debug surface; telemetry remains the operational span surface.

section(attrs \\ [])

@spec section(keyword()) :: Rendro.Section.t()

signature_field(name, attrs \\ [])

@spec signature_field(
  String.t(),
  keyword()
) :: Rendro.Block.t()

table(rows, attrs \\ [])

@spec table(
  [Rendro.Table.row()],
  keyword()
) :: Rendro.Table.t()

text(content, attrs \\ [])

@spec text(
  String.t(),
  keyword()
) :: Rendro.Text.t()