0

PDFkit 根本不获取<div>元素,IMGkit 呈现空白图像(以下方法):

def png
  file = Tempfile.new(Digest::MD5.hexdigest(rand(12).to_s), :encoding => 'ascii-8bit')
  file.write(IMGKit.new(request.referer).to_png)
  send_data file, :filename => "test.png"
end

是否有可靠的方法可以获取应用程序中任何给定页面的副本?格式并不重要,但 PDF 会是理想的。

4

1 回答 1

1

尝试

kit = IMGKit.new(request.referer, height: 900, transparent:true, quality:10) /*YOUR SETTING*/

file = kit.to_file(Rails.root + "public/pngs/" + "screenshot.png") /*YOUR IMAGE NAME*/
send_file("#{Rails.root}/public/pngs/screenshot.png", :filename => "screenshot.png", :type => "image/png",:disposition => 'attachment',:streaming=> 'true') /*YOUR ADDRESS WHERE U WANT TO STORE PNG FILE*/
于 2013-07-26T06:33:52.940 回答