class HexaPDF::Document::Layout::ChildrenCollector


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 for the configuration option

Example: do |list|
  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



The collected children

Public Class Methods

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

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


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