class HexaPDF:: Content:: CanvasComposer
| Parent | Object |
|---|
The CanvasComposer class allows using the document layout functionality for a single canvas. It works in a similar manner as the HexaPDF::Composer class.
Attributes
The associated canvas.
The associated HexaPDF::Document instance.
The HexaPDF::Layout::Frame instance into which the boxes are laid out.
Public Class Methods
Creates a new CanvasComposer instance for the given canvas.
The margin can be any value allowed by HexaPDF::Layout::Style::Quad#set and defines the margin that should not be used during composition. For the remaining area of the canvas a frame object will be created.
Public Instance Methods
Draws the given HexaPDF::Layout::Box and returns the last drawn box.
The box is drawn into the frame. If it doesn’t fit, the box is split. If it still doesn’t fit, a new region of the frame is determined and then the process starts again.
If none or only some parts of the box fit into the frame, an exception is thrown.
Draws any box that can be created using HexaPDF::Document::Layout.
This includes all named boxes defined in the ‘layout.boxes.map’ configuration option.
Examples:
canvas.composer(margin: 10) do |composer|
composer.text("Some text", position: :float)
composer.image(machu_picchu, height: 30, align: :right)
composer.lorem_ipsum(sentences: 1, margin: [0, 0, 5])
composer.list(item_spacing: 2) do |list|
composer.document.config['layout.boxes.map'].each do |name, klass|
list.formatted_text([{text: name.to_s, fill_color: "hp-blue-dark"},
{text: "\n#{klass}"}], font_size: 6)
end
end
endSee: HexaPDF::Document::Layout#box
Invokes HexaPDF::Document::Layout#style with the given arguments to create/update and return a style object.
