module Prawn::Markup::Processor::Tables
Attributes
table_stack[R]
Public Class Methods
prepended(base)
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 6 def self.prepended(base) base.known_elements.push('table', 'tr', 'td', 'th') end
Public Instance Methods
end_table()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 19 def end_table data = table_stack.pop return if data.empty? || data.all?(&:empty?) if table_stack.empty? add_table(data) else current_cell.nodes << data end end
end_td()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 48 def end_td if current_table add_cell_text_node(current_cell) else add_current_text end end
Also aliased as: end_th
start_img()
click to toggle source
Calls superclass method
# File lib/prawn/markup/processor/tables.rb, line 57 def start_img if current_table add_cell_image(current_cell) else super end end
start_table()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 10 def start_table if current_table add_cell_text_node(current_cell) else add_current_text end table_stack.push([]) end
start_td()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 36 def start_td return unless current_table current_table.last << Elements::Cell.new(width: style_properties['width']) end
start_th()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 42 def start_th return unless current_table current_table.last << Elements::Cell.new(width: style_properties['width'], header: true) end
start_tr()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 30 def start_tr return unless current_table current_table << [] end
Private Instance Methods
add_cell_image(cell)
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 92 def add_cell_image(cell) add_cell_text_node(cell) img = image_properties(current_attrs['src']) cell.nodes << img || invalid_image_placeholder end
add_cell_text_node(cell, options = {})
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 86 def add_cell_text_node(cell, options = {}) return unless buffered_text? cell.nodes << options.merge(content: dump_text.strip) end
add_table(cells)
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 98 def add_table(cells) draw_table(cells) put_bottom_margin(text_margin_bottom + additional_cell_padding_top + text_leading) rescue Prawn::Errors::CannotFit => e append_text(table_too_large_placeholder(e)) end
additional_cell_padding_top()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 113 def additional_cell_padding_top # as used in Prawn::Table::Cell::Text#draw_content move_down (text_line_gap + text_descender) / 2 end
current_cell()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 78 def current_cell current_table.last.last end
current_table()
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 74 def current_table table_stack.last end
draw_table(cells)
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 105 def draw_table(cells) Builders::TableBuilder.new(pdf, cells, pdf.bounds.width, options).draw end
inside_container?()
click to toggle source
Calls superclass method
# File lib/prawn/markup/processor/tables.rb, line 82 def inside_container? super || current_table end
reset()
click to toggle source
Calls superclass method
# File lib/prawn/markup/processor/tables.rb, line 69 def reset @table_stack = [] super end
table_too_large_placeholder(error)
click to toggle source
# File lib/prawn/markup/processor/tables.rb, line 109 def table_too_large_placeholder(error) placeholder_value(%i[table placeholder too_large], error) || '[table content too large]' end