使用prawn gem如何在rails中以pdf格式显示回形针图像

时间:2014-04-30 12:26:58

标签: ruby-on-rails

这是我的控制者。它在pdf文件上显示文本数据,但我希望图像也显示在pdf文件

def index
@line_items = Line_item.all
respond_to do |format|
format.html
format.pdf do
pdftable = Prawn::Document.new
pdftable.table([["price"]],
:column_widths =>{0=>80,}, :row_colors =>['dfdfdf])
@line_items.each do |line_item|
pdftable.table([["#{line_item.price}"]],
:column_widths =>{0=>80,}, :row_colors =>['dfdfdf])
end
send_data pdftable.render, type: "application/pdf", dispostion:"inline"
end
end
end

1 个答案:

答案 0 :(得分:0)

在我的应用程序中使用以下代码显示图像

  
    

pdf.image Rails.root.join('app','assets','images','rails.png')