class HexaPDF::Layout::PageStyle

A PageStyle defines the initial look of a page and the placement of one or more frames.

def create_frame(page, margin = 36)

*Note*: This is a helper method for use inside the #template callable.

The +margin+ can be any value allowed by HexaPDF::Layout::Style::Quad#set.

Creates a frame based on the given page's box and margin.
def create_frame(page, margin = 36)
  box = page.box
  margin = Layout::Style::Quad.new(margin)
  Layout::Frame.new(box.left + margin.left,
                    box.bottom + margin.bottom,
                    box.width - margin.left - margin.right,
                    box.height - margin.bottom - margin.top,
                    context: page)
end

def create_page(document)

covering the whole page except a margin of 36 is created.
If #frame has not been set beforehand or during execution of the #template, a default frame

Creates a new page in the given document with this page style and returns it.
def create_page(document)
  page = document.pages.create(media_box: page_size, orientation: orientation)
  template&.call(page.canvas, self)
  self.frame ||= create_frame(page, 36)
  page
end

def initialize(page_size: :A4, orientation: :portrait, next_style: nil, &block)

end
canvas.fill_color("fd0") { canvas.circle(100, 100, 50).fill }
style.next_style = :other
style.frame = style.create_frame(canvas.context, 72)
PageStyle.new(page_size: :Letter) do |canvas, style|

Example:

values. If a block is given, it is used as template for defining the initial content.
Creates a new page style instance for the given page size, orientation and next style
def initialize(page_size: :A4, orientation: :portrait, next_style: nil, &block)
  @page_size = page_size
  @orientation = orientation
  @template = block
  @frame = nil
  @next_style = next_style
end