Pdf.Component.KeyValue (ex_pdf_components v1.0.4)

Copy Markdown View Source

Key-value pair component for PDF documents.

Renders aligned label-value rows, like invoice details or profile info.

Examples

doc |> Pdf.Component.KeyValue.render({50, 700}, %{width: 300}, [
  {"Name:", "John Doe"},
  {"Email:", "john@example.com"},
  {"Role:", "Admin"}
])

Summary

Functions

Resolve the content width for a key-value block inside a containing block.

Calculate the total height this key-value list will occupy, accounting for word-wrap on long values.

Functions

content_width(style, container_width, x_offset \\ 0)

@spec content_width(map(), number() | nil, number()) :: number()

Resolve the content width for a key-value block inside a containing block.

container_width is the inner width of the parent. x_offset is the component's horizontal inset from that edge (same semantics as width: :full on text inside a box).

measure_height(style \\ %{}, pairs, container_width \\ nil, opts \\ [])

Calculate the total height this key-value list will occupy, accounting for word-wrap on long values.

Takes the same style map as render/4 plus the pairs list. Returns the height in points.

render(doc, arg, style \\ %{}, pairs, container_width \\ nil)