prawnto displaying tables that don't break when new page

后端 未结 4 822
面向向阳花
面向向阳花 2021-02-10 09:46

I have a variable number of tables with variable number of rows and I want to have them displaying one after the other but if a table doesn\'t fit on the current page put it on

4条回答
  •  你的背包
    2021-02-10 10:23

    @current_page = pdf.page_count

    @roll = pdf.transaction do 
      pdf.move_down 20
    
      pdf.table @data,
        :font_size  => 12, 
        :border_style => :grid,
        :horizontal_padding => 10,
        :vertical_padding   => 3,
        :border_width       => 2,
        :position           => :left,
        :row_colors => ["FFFFFF","DDDDDD"]
    
      pdf.rollback if pdf.page_count > @current_page
    
    end 
    
    if @roll == false
    
      pdf.start_new_page
    
      pdf.table @data,
        :font_size  => 12, 
        :border_style => :grid,
        :horizontal_padding => 10,
        :vertical_padding   => 3,
        :border_width       => 2,
        :position           => :left,
        :row_colors => ["FFFFFF","DDDDDD"]
    end
    

    I hope this works for you as for me :-)

提交回复
热议问题