开发者

How to add an image to a table with Prawn?

开发者 https://www.devze.com 2023-04-01 13:23 出处:网络
So I have the following code: items = [ [\"Photo\",\"Name\", \"Qty\", \"Unit Price\", \"Amount\"] ] items += @quotation.quotation_items.map do |oitem|

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号