Search code examples
ruby-on-railsfooterprawn

The Page Footer contains table in Prawn PDF


I've been combating this footer problem in Prawn PDF since last year. My page footer contains a table. Normally, table rows will flow on to the next page. My problem is how can I prevent the footer from appearing from previous page? I want it to appear only in the last page and intact.

Can someone share how did you find a solution about this?

below is the screenshot. The footer part is Total accounted value up to On hand count figure. enter image description here


Solution

  • Since I don't have your code I will post an example I've used:

        footer_table = pdf.make_table(data) do
          cells.borders = []
        end
        pdf.start_new_page if (pdf.cursor - footer_table.height).negative?
        footer_table.draw
    

    So in the last line you will check the whole table fits on the the current page, if not it will create a new page.