class HexaPDF::Document::Layout::ChildrenCollector

Parent

This class is used when a box can contain child boxes and the creation of such boxes should be seemlessly doable when creating the parent node. It is yieled, for example, by Layout#box to collect the children for the created box.

A box can be added to the list of collected children in the following ways:

<<

This appends the given box to the list.

text_box, formatted_text_box, image_box, …

Any method accepted by the Layout class.

text, formatted_text, image, …

Any method accepted by the Layout class without the _box suffix.

list, column, …

Any name registered with the configuration option layout.boxes.map.

The special method multiple allows adding multiple boxes as a single array to the collected children.

Example:

document.layout.box(:list) do |list|  # list is a ChildrenCollector
  list.text_box("Some text here")     # layout method
  list.image(image_path)              # layout method without _box suffix
  list.column(columns: 3) do |column| # registered box name
    column.text("Text in column")
    column << document.layout.lorem_ipsum_box   # adding a Box instance
  end
end

Attributes

children[R]

The collected children

Public Class Methods

collect(layout) { |collector| ... }

Creates a children collector, yields it and then returns the collected children.

new(layout)

Create a new ChildrenCollector for the given layout (a HexaPDF::Document::Layout) instance.