【问题标题】:I need an accurate PDF or image of an app's page我需要应用页面的准确 PDF 或图像
【发布时间】:2013-07-26 06:24:22
【问题描述】:

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 是理想的。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 wkhtmltopdf pdfkit imgkit


    【解决方案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*/
    

    【讨论】:

    • 效果很好!非常感谢。变得非常沮丧。
    猜你喜欢
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多