邪恶的pdf样式未显示

时间:2018-07-07 02:54:11

标签: ruby-on-rails wicked-pdf

我无法使邪恶的pdf样式正常工作。我尝试了几种方法,如堆栈溢出问题和网络上所见,没有运气。这是我的代码-

控制器-

 format.pdf do
     html = render_to_string(template: 'orders/showPDF.html.erb', layout: 'order_pdf')
     document_data = WickedPdf.new.pdf_from_string(html)
     send_data(document_data, filename: 'filename', type:  application/pdf')
 end

布局-order_pdf.pdf.erb

<!DOCTYPE html>
    <html>
        <head>
           <%= csrf_meta_tags %>
           <%= wicked_pdf_stylesheet_link_tag("application"), media: "all" %>
           <%= wicked_pdf_stylesheet_link_tag("app/orders/showPDF"), media: "all"  %>
           <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
           <%= wicked_pdf_javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
           <%= javascript_pack_tag 'application' -%>
      </head>
      <body>
        <div class="orderContent">
            <%= yield %>
        </div>
      </body>
</html>

我也已将Rails.application.config.assets.precompile += %w( application.js application.scss app/orders/showPDF.scss)添加到a​​sset.rb

ShowPDF.scss具有我想要包含的所有样式。如果将布局的扩展名设置为“ order_pdf.html.erb”,则会看到错误“ undefined mixin grid-container”。因此,我将其重命名为“ order_pdf.pdf.erb”,但看不到应用任何样式。任何帮助将不胜感激。

0 个答案:

没有答案
相关问题