class HexaPDF::Layout::BoxFitter


A BoxFitter instance contains an array of Frame objects and allows placing boxes one after the other in them. Such functionality is useful, for example, for boxes that provide multiple frames for content.


  • First one needs to add the frame objects via << or provide them on initialization.

  • Then use the fit method to fit boxes one after the other. No drawing is done.

  • Once all boxes have been fitted, the fit_results, remaining_boxes and success? methods can be used to get the result:

    • If there are no remaining boxes, all boxes were successfully fitted into the frames.

    • If there are remaining boxes but no fit results, the first box could not be fitted.

    • If there are remaining boxes and fit results, some boxes were able to fit.



The Frame::FitResult objects for the successfully fitted objects in the order the boxes were fitted.


The array of frames inside of which the boxes should be laid out.

Use << to add additional frames.


The boxes that could not be fitted into the frames.

Public Class Methods

new(frames = [])

Creates a new BoxFitter object for the given frames.

Public Instance Methods


Add the given frame to the list of frames.


Returns an array with the heights of the content of each frame.


Fits the given box at the current location.


Returns true if all boxes were successfully fitted.