Pdf.Component.KeyValue (ex_pdf_components v1.0.0)

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

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

Render key-value pairs at {x, y}.

Functions

measure_height(style \\ %{}, pairs)

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)

Render key-value pairs at {x, y}.

Style options

  • :width — total width (default 300)
  • :font — font name (default "Helvetica")
  • :font_size — text size (default 10)
  • :label_color — label text color
  • :value_color — value text color
  • :line_height — row spacing (default 18)
  • :label_width — fraction of width for labels (default 0.35)
  • :divider — show divider between rows (default false)
  • :divider_color — divider line color
  • :striped — alternate row backgrounds (default false)
  • :stripe_color — background for even rows
  • :value_align:left (default) or :right to right-align values
  • :label_bold — bold labels (default true)
  • :value_bold — bold values (default false)