Pdf.Layout.ContainingBlock (ex_pdf_components v1.0.4)

Copy Markdown View Source

CSS-like containing block — resolves relative sizes against a parent area.

Use inside boxes, rows, and columns so children can declare width: :full or "50%" and inherit the parent's available space (similar to HTML width: 100%).

Summary

Functions

Resolve a height value against the parent area height.

Resolve {w, h} against a parent area.

Apply width/height resolution to a style map using the parent area. Resolves :width, :height, and :wrap_width when present.

Resolve a width value against the parent area width.

Text wrap width for a child at horizontal offset x inside the area. Like CSS: width: calc(100% - x).

Types

area()

@type area() :: %{
  :width => number(),
  optional(:height) => number(),
  optional(:x) => number(),
  optional(:y) => number()
}

Functions

resolve_height(parent, parent_height)

@spec resolve_height(any(), area() | number()) :: number()

Resolve a height value against the parent area height.

resolve_size(size, area)

@spec resolve_size(
  {any(), any()},
  area()
) :: {number(), number()}

Resolve {w, h} against a parent area.

resolve_style(style, area)

@spec resolve_style(map(), area()) :: map()

Apply width/height resolution to a style map using the parent area. Resolves :width, :height, and :wrap_width when present.

resolve_width(parent, parent_width)

@spec resolve_width(any(), area() | number()) :: number()

Resolve a width value against the parent area width.

text_width(map, x_offset)

@spec text_width(area(), number()) :: number()

Text wrap width for a child at horizontal offset x inside the area. Like CSS: width: calc(100% - x).