如何用Prawn将图像添加到表中?

时间:2011-08-29 08:31:03

标签: ruby-on-rails ruby-on-rails-3 prawn

所以我有以下代码:

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$ ')
]

这会产生错误:

Content type not recognized: #<Prawn::Images::JPG:0x00000101703b98 @bits=8, @height=300, @width=300, @channels=3, @scaled_width=300, @scaled_height=300>

提取的来源(第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: 

1 个答案:

答案 0 :(得分:0)

刚刚找到一张带有图片的模拟桌子,对我帮助很大。感谢jfeust与我们分享它。 - https://gist.github.com/973267