PaperForge.Graphics.TextBox (PaperForge v0.2.0)

Copy Markdown View Source

Builds multiline text commands constrained to a rectangular area.

This module handles:

  • automatic word wrapping;
  • line height;
  • horizontal alignment;
  • optional height limits;
  • overflow detection.

It does not draw a visible rectangle. It only generates the text commands required for the box.

Summary

Functions

Generates PDF text commands for a multiline text box.

Types

result()

@type result() :: %{
  commands: iodata(),
  lines: [binary()],
  overflow?: boolean(),
  consumed_height: number()
}

Functions

commands(text, options)

@spec commands(
  binary(),
  keyword()
) :: result()

Generates PDF text commands for a multiline text box.

Required options:

  • :x
  • :y
  • :width
  • :resource_name
  • :font

Optional options:

  • :height
  • :size
  • :line_height
  • :align
  • :color

Example

PaperForge.Graphics.TextBox.commands(
  "A long paragraph that should wrap automatically.",
  x: 72,
  y: 700,
  width: 400,
  height: 120,
  font: :helvetica,
  resource_name: "F1",
  size: 12,
  line_height: 16,
  align: :left
)