Rendro (Rendro v0.2.0)

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.

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 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()}

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.

metadata(attrs \\ [])

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

page(attrs \\ [])

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

page_template(attrs \\ [])

@spec page_template(keyword()) :: Rendro.PageTemplate.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_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()

table(rows, attrs \\ [])

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

text(content, attrs \\ [])

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