Class: Idml::Render::Renderers::TableRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/idml/render/renderers/table_renderer.rb

Overview

Renders an IDML Table. Draws the cell grid via rectangle ops, then renders inline text in each cell via canvas.text_rich. Cells with no text render as empty rectangles.

Two table layouts are supported:

1. **Schema-faithful** (real IDML): `Table` has `cell`
 and `row` sibling collections. Cell `Name` encodes
 column and row as `"col:row"`. Row order determines
 vertical position; cell Name determines horizontal.
2. **Legacy** (synthetic test fixture): `Table` has a
 `table_row` collection, each `TableRow` has a
 `table_cell` collection. Nested structure.

The renderer auto-detects which layout is present.

Constant Summary collapse

DEFAULT_SIZE =
10.0
INSET =
4.0

Class Method Summary collapse

Class Method Details

.render(canvas, context) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/idml/render/renderers/table_renderer.rb', line 26

def self.render(canvas, context)
  table = context.item
  return if table.visible == false

  box = Placement.box(table, context.page_height)
  return unless box

  canvas.save_graphics_state do
    if schema_faithful?(table)
      render_schema_faithful(canvas, table, box, context)
    else
      render_legacy(canvas, table, box, context)
    end
  end
end