How to add an image to a table with Prawn?
So I have the following code:
items = [ ["Photo","Name", "Qty", "Unit Price", "Amount"] ]
items += @quotation.quotation_items.map do |oitem|
[
pdf.image(oitem.item.photo),
oitem.item.title,
oitem.quantity.to_s,
number_to_currency(oitem.item.price,:unit => 'HK$ '),
number_to_currency(oitem.full_price,:unit => 'HK$ ')
]
This generates the error:
Content type not recognized: #<Prawn::Images::JPG:0x00000101703b98 @bits=8, @height=300, @wid开发者_Python百科th=300, @channels=3, @scaled_width=300, @scaled_height=300>
Extracted source (around line #54):
51:
52: end
53:
54: pdf.table items, :header => true,
55: :column_widths => [300,200,100,150,150],
56: :row_colors => ["FFFFFF","DDDDDD"]
57:
Just found a Mock table with Images that helped me a lot. Thanks to jfeust for sharing it wih us. - https://gist.github.com/973267
精彩评论