I am trying to create a document using Prawn gem for Rails
What I'm trying to do is set the height of the variable for my pdf, so depending on some queries in the database, the height of the PDF will change. I do this because I need a document in one PDF page.
Currently, my code looks like this:
pdf = Prawn::Document.new(page_size: [297.64, 419.53], margin: 0) .... data = [ ["Header1", "Header2", "Header3", "Header4", "Header5", "Header6"] ] // here is the variable data cart.cart_products.each do |cp| arr = [ cp.product_code, cp.product_description, cp.amount, cp.product_metric, cp.product_unit_value, cp.total_value ] data.push(arr) end // populating the table with data pdf.table(data, :cell_style => {:border_width => 0}, :column_widths => [45, 80, 30, 42.36, 50, 50]) do |table| table.row(0).border_width = 0.1.mm table.row(0).font_style = :bold table.row(0).borders = [:bottom] end .... pdf.render_file("path/to/dir/document.pdf")
Can anyone help me with this? Thanks.
source share