【发布时间】:2017-01-29 11:25:05
【问题描述】:
我在大虾中搜索了大虾的页面布局,它显示了这个
pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
pdf.text 不打印任何东西
但是当我尝试这个时,我得到了未定义的方法
page_layout :landscape
在 super() 之后添加
这是我的全部代码
class ProductPdfGenerate < Prawn::Document
require 'open-uri'
def initialize(order_items)
super()
@document = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
@order_items = order_items
@order_items.each_with_index do |oi, i|
if oi.case.present? && Model.where(magento_model_id: oi.case.model_id).first.present?
style_image = oi.case.image_preview.url(:custom_image)
model = Model.where(magento_model_id: oi.case.model_id).first
# image open(style_image), width: "200".to_f, height: "400".to_f
image open(style_image), width: "#{model.aspect_ratio_width.to_f/2.54*72}".to_f, height: "#{model.aspect_ratio_height.to_f/2.54*72}".to_f
text "\n \n \n"
text "Model: #{model.name}"
text "Model Category: #{model.category_type}"
text "Style: #{oi.case.style.try(:name)} "
text "Order Id: #{oi.order_id}"
else
image open("https://s3.ap-south-1.amazonaws.com/take-my-order/default/missing.png")
end
end
end
end
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 prawn