![](/img/trans.png)
[英]Ruby on Rails: Prawn Gem Generates PDF, but PDF Cannot Display
[英]using prawn gem how to display paperclip image on pdf format in 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
在我的应用程序中使用以下代码显示图像
pdf.image Rails.root.join('app','assets','images','rails.png')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.