table is breaking to late and begins to early on following page

Im using prawn to generate a report basing on a set of data which is displayed in a table. This works perfectly as long as I dont have too much data. When I have more than 20 datasets the table reaches into my page footer and on the following page it begins in the page header.

The best would be to define a kind of area for each page in which the table is displayed. I didnt find any solution by searching the manual. Is there a workaround or sth. like that?

Answers


One possible solution (without knowing too much detail of your use-case):

If the rows are a fixed height, you could just group the data into as many rows as will fit on a page. then insert a page break and draw a new table. refer to http://rails.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Array/Grouping.html#M000833

eg: (in haml)

- @people.in_groups_of(5,false) do |people|
  %ul
    - people.each do |person|
      %li= person.name
  %hr

that would create multiple <ul>'s with up to 5 <li> tags in each, separated by a <hr />

Hope that applies to your use case somehow.


The solition was using a bounding_box for the whole document content so it doesnt get involved in the footer or header even not after a page break.


Need Your Help

How to sense Email in PHP or Java

java php email

I have a database where I have to store data from a file. But the problem is every night the file is sent to a particular email address.I want to write a program using PHP or Java that will read the