How to create a multipage PDF in Rails representing one table of data (including column headers on each new page)? I've looked at many examples with wicked-pdf, pdfkit, and prawn but haven't seen anything that specifically addresses the overflow into subsequent pages and the need to repeat the headers with each new page. Thanks for the help.
I use Prawn to generate my pdfs, and can get the effect you desire like this:
def render_photo_table(pdf)
ps = self.photos.map do |photo|
[photo.filename, photo.image_height, photo.image_width]
end
ps.insert(0, ['Filename', 'Height', 'Width'])
pdf.table(ps) do |table|
table.header = true
end
end
This yields a header (set in array position 0) at the top of each page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With