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
答案 0 :(得分:0)
在我的应用程序中使用以下代码显示图像
pdf.image Rails.root.join('app','assets','images','rails.png')