这种方法有什么问题?我完全被难住了。我一直在线收到此错误img.write(res)
:
ArgumentImage no images in this image list
这是控制器方法:
def convert_to_image
@document = Document.find(params[:document_id])
img = Magick::ImageList.new
pdf = Prawn::Document.generate("tmp.pdf", :margin => 0, :page_size => [398, 398]) do |p|
res = @document.post_pdf(p)
img.write(res)
send_data img
end
end
上面提到的post_pdf
方法如下所示:
def post_pdf(p)
size = 398
p.image self.user.logo.path, :width => size
p.bounding_box([30, 490], :width => size) do
p.fill_color self.user.colour1
p.pad_bottom(10) { p.text self.title, :size => 28, :style => :bold }
p.fill_color '#444444'
end
self.components.each do |component|
p.image component.image_newsletter.path, :width => size
p.fill_color self.user.colour1
p.fill_rectangle([0, 20], size, 20)
end
end