Class: Prawn::Markup::Builders::TableBuilder

Inherits:
NestableBuilder show all
Defined in:
lib/prawn/markup/builders/table_builder.rb

Constant Summary collapse

FAILOVER_STRATEGIES =
%i[equal_widths subtable_placeholders].freeze
DEFAULT_CELL_PADDING =
5
MIN_COL_WIDTH =
1.cm

Constants inherited from NestableBuilder

NestableBuilder::TEXT_STYLE_OPTIONS

Instance Method Summary collapse

Constructor Details

#initialize(pdf, cells, total_width, options = {}) ⇒ TableBuilder

Returns a new instance of TableBuilder.



13
14
15
16
17
# File 'lib/prawn/markup/builders/table_builder.rb', line 13

def initialize(pdf, cells, total_width, options = {})
  super(pdf, total_width, options)
  @cells = cells
  @column_widths = []
end

Instance Method Details

#drawObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/prawn/markup/builders/table_builder.rb', line 24

def draw
  # fix https://github.com/prawnpdf/prawn-table/issues/120
  pdf.font_size(table_options[:cell][:size] || pdf.font_size) do
    make.draw
  end
rescue Prawn::Errors::CannotFit => e
  if failover_on_error
    draw
  else
    raise e
  end
end

#makeObject



19
20
21
22
# File 'lib/prawn/markup/builders/table_builder.rb', line 19

def make
  compute_column_widths
  pdf.make_table(convert_cells, prawn_table_options)
end