使用rails app中的wicked_pdf gem压缩pdf的内容

时间:2015-08-19 18:00:22

标签: ruby-on-rails twitter-bootstrap wicked-pdf

使用/show.pdf?debug=1时,它会显示具有正确css和数据的确切html内容。但是当试图下载原始pdf时,它在pdf中显示压缩内容。使用twitter-bootstrap作为css。

这是布局

 <!doctype html>
 <html>
   <head>
    <meta charset='utf-8' />
    <%= wicked_pdf_stylesheet_link_tag "application",media: 'all', 'data-turbolinks-track' => true %>
    <%= wicked_pdf_javascript_include_tag "number_pages" %>
    <%= wicked_pdf_javascript_include_tag "application", 'data-turbolinks-track' => true %>
  </head>
  <body onload='number_pages'>
    <div id="header">
      <%= wicked_pdf_image_tag 'entity-10.png' %>
    </div>

    <%= yield %>

  </body>
</html>

这是控制器代码

def show
 @user = Payment.new('splace')



respond_to do |format|
  format.html
  format.pdf do
    render pdf: "invoice", layout: 'pdf.html',
           no_pdf_compression:true,
           disposition:  "inline",
           dpi: 300,
           encoding: "UTF-8",
           show_as_html: params[:debug].present?,
           :margin => {:top => 0,
                       :bottom => 0,
                       :left => 0,
                       :right => 0}

  end
end

0 个答案:

没有答案