I am using the prawn gem with Rails 4
I have the following gems:
gem 'prawn'
gem 'prawn-table'
gem 'prawn-qrcode'
I get the following error:
Prawn::Errors::UnrecognizedTableContent
When I do this:
require 'prawn/qrcode'
class ReportPdf < Prawn::Document
def initialize(organizations)
super()
@organizations = organizations
table_content
end
def table_content
table organization_rows do
row(0).font_style = :bold
self.header = true
self.row_colors = ['DDDDDD', 'FFFFFF']
self.column_widths = [40, 300, 200]
end
end
def organization_rows
[['#', 'Name', 'id']] +
@organizations.map do |organization|
[render_qr_code(RQRCode::QRCode.new(organization.id.to_s)), organization.name, organization.id]
end
end
end
Can anyone help by providing an example of adding a QR code to each row in a table?
UPDATE:
I changed my table code to the following (I added .to_s
to the qr code:
def organization_rows
[['#', 'Name', 'id']] +
@organizations.map do |organization|
[render_qr_code(RQRCode::QRCode.new(organization.id.to_s)).to_s,
organization.name,
organization.id]
end
end
Now, I get the following pdf. See screenshot. How can I get those QR codes inside of a table cell?