Wicked-PDF not showing images, 'wicked_pdf_image_tag' undefined

▼魔方 西西 提交于 2019-12-03 12:07:58

First thing create a pdf template to render and use your wicked_pdf tags in that template.. for example-

app/views/layout/application.pdf.erb-

<!doctype html>
<html>
  <head>
    <meta charset='utf-8' />
  </head>
  <body onload='number_pages'>
    <div id="content">
      <%= yield %>
    </div>
  </body>
</html>

app/views/pdf/pdf_view.pdf.erb-

<div>
  <%= wicked_pdf_image_tag 'logo.jpg' %>
</div>

use this template instead

def save
  pdf = WickedPdf.new.pdf_from_string(
                        render_to_string(
                          template: 'example/pdf_view.pdf.erb',
                          layout: 'layouts/application.pdf.erb'))
  send_data(pdf,
            filename: 'file_name.pdf',
            type: 'application/pdf',
            disposition: 'attachment') 
end

This might help you..

I converted image url that 'http' from 'https'. Than worked.

Heroku-18
Rails 4.2
wicked_pdf (1.1.0)
wkhtmltopdf-binary (0.12.4)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!