I'm trying to produce a PDF report with Prawn, I can get it to do a report on a show action easily enough by passing the single ID but I want to produce one with every record in it. Like a standard rails scaffold index page. Using rails it would look like this:
<% @customer.each do |customer| %>
<%= customer.id %>
<%= customer.name %>
<%end%>
Easy!
But I'm not sure how to do this with Prawn..
Something like:
def index
@customer = Customer.all
respond_to do |format|
format.html
Prawn::Document.generate("customer_list.pdf") do |pdf|
pdf.text "#{@customer.id} "
pdf.text "#{@customer.name} "
end
end
end
Which clearly isn't right.
Any ideas? Thank you.
wkhtmltopdf
app. There is a wrapper gem calledPDFKit
that makes working with it easy. wkhtmltopdf: code.google.com/p/wkhtmltopdf and pdfkit: github.com/pdfkit/PDFKit for generating complex reports i find it much easier to generate them in HTML instead of working with PDF/Prawn directly. – Clayborn