@@ -66,7 +66,13 @@ def on_text_node(content)
6666 def render
6767 return if buffer . empty?
6868
69- output_content ( buffer . dup , context . block_styles )
69+ content = prepare_content ( buffer . dup , context . block_styles )
70+ if context . current_table
71+ td_content = content . dig ( :buffer , 0 , :text )
72+ context . current_table . update_content ( td_content )
73+ else
74+ pdf . puts ( content [ :buffer ] , content [ :options ] , left_indent : content [ :left_indent ] , bounding_box : content [ :bounds ] )
75+ end
7076 buffer . clear
7177 @last_margin = 0
7278 end
@@ -95,6 +101,7 @@ def render_if_needed(element)
95101
96102 def apply_tag_close_styles ( element )
97103 tag_styles = element . tag_closing ( context : context )
104+ pdf . table ( element . table_data ) if element . is_a? ( Tags ::Table )
98105 @last_margin = tag_styles [ :margin_bottom ] . to_f
99106 pdf . advance_cursor ( last_margin + tag_styles [ :padding_bottom ] . to_f )
100107 pdf . start_new_page if tag_styles [ :break_after ]
@@ -118,12 +125,12 @@ def prepare_text(content)
118125 @last_text = text
119126 end
120127
121- def output_content ( buffer , block_styles )
128+ def prepare_content ( buffer , block_styles )
122129 apply_callbacks ( buffer )
123130 left_indent = block_styles [ :margin_left ] . to_f + block_styles [ :padding_left ] . to_f
124131 options = block_styles . slice ( :align , :indent_paragraphs , :leading , :mode , :padding_left )
125132 options [ :leading ] = adjust_leading ( buffer , options [ :leading ] )
126- pdf . puts ( buffer , options , bounding_box : bounds ( buffer , options , block_styles ) , left_indent : left_indent )
133+ { buffer : buffer , options : options , left_indent : left_indent , bounds : bounds ( buffer , options , block_styles ) }
127134 end
128135
129136 def apply_callbacks ( buffer )
0 commit comments