Tincture.Layout.Table (Tincture v0.1.0)

Copy Markdown View Source

Tabular layout with headers, borders and automatic column widths.

Pass :auto for the column spec to size columns from their content, or a list of explicit widths in points.

rows = [
  ["Item", "Qty", "Total"],
  ["Widget", "2", "$40.00"],
  ["Gadget", "1", "$15.00"]
]

{pdf, result} =
  Table.render(pdf, 50, 700, :auto, rows,
    header_rows: 1,
    header_font: "Helvetica-Bold",
    table_width: 500
  )

Cell text is escaped, so values containing parentheses or backslashes cannot break the content stream. Cells wrap within their column, and :valign controls vertical alignment when a row's cells differ in height.

Summary

Types

option()

@type option() ::
  {:font, String.t()}
  | {:header_font, String.t()}
  | {:font_size, number()}
  | {:padding, number()}
  | {:valign, :top | :middle | :bottom}
  | {:border, boolean()}
  | {:header_rows, non_neg_integer()}
  | {:row_height, number()}
  | {:table_width, number()}
  | {:min_col_width, number()}

row()

@type row() :: [term()]

Functions

render(pdf, x, y, column_spec, rows, opts \\ [])

@spec render(Tincture.PDF.t(), number(), number(), [number()] | :auto, [row()], [
  option()
]) ::
  {Tincture.PDF.t(), Tincture.Layout.Table.RenderResult.t()}