class HexaPDF::Layout::ColumnBox


A ColumnBox arranges boxes in one or more columns.

The number and width of the columns as well as the size of the gap between the columns can be modified. Additionally, the contents can either fill the columns one after the other or the columns can be made equally high.

If the column box has padding and/or borders specified, they are handled like with any other box. This means they are around all columns and their contents and are not used separately for each column.

The following style properties are used (additionally to those used by the parent class):


If this is set to :flow, the frames created for the columns will take the shape of the frame into account. This also means that the available_width and available_height arguments are ignored.



The child boxes of this ColumnBox. They need to be finalized before fit is called.


The columns definition.

If the value is an array, it needs to contain the widths of the columns. The size of the array determines the number of columns. Otherwise, if the value is an integer, the value defines the number of equally sized columns, i.e. a value of N is equal to [-1]*N.

If a negative integer is used for the width, the column is auto-sized. Such columns split the remaining width (after substracting the widths of the fixed columns) proportionally among them. For example, if the definition is [-1, -2, -2], the first column is a fifth of the width and the other columns are each two fifth of the width.

Examples:, columns: 2, gaps: 10,
             children: [composer.document.layout.lorem_ipsum_box]), columns: [50, -2, -1], gaps: [10, 5],
             children: [composer.document.layout.lorem_ipsum_box])


Determines whether the columns should all be equally high or not.

Examples:, children: [composer.document.layout.lorem_ipsum_box]), equal_height: false,
             children: [composer.document.layout.lorem_ipsum_box])


The size of the gaps between the columns.

This is an array containing the width of the gaps. If there are more gaps than numbers in the array, the array is cycled.

Examples: see columns

Public Class Methods

new(children: [], columns: 2, gaps: 36, equal_height: true, **kwargs)

Creates a new ColumnBox object for the given child boxes in children.


Can either simply integer specify the number of columns or be a full column definition (see columns for details).


Can either be a simply integer specifying the width between two columns or a full gap definition (see gap for details).


If true, the fit method tries to balance the columns in terms of their height. Otherwise the columns are filled from the left.

Calls superclass method HexaPDF::Layout::Box::new

Public Instance Methods


Returns true if no box was fitted into the columns.

Calls superclass method HexaPDF::Layout::Box#empty?
fit(available_width, available_height, frame)

Fits the column box into the current region of the frame.

If the style property ‘position’ is set to :flow, the columns might not be rectangles but arbitrary (sets of) polygons since the +frame+s shape is taken into account.


Returns true as the ‘position’ style property value :flow is supported.