【问题标题】:Wicked PDF on RAILS 5 ignores bootstrap 4 grid systemRAILS 5 上的邪恶 PDF 忽略 bootstrap 4 网格系统
【发布时间】:2019-03-16 04:03:37
【问题描述】:

我在 RAILS 5 系统中使用 Wicked PDF,它可以工作 - 我在浏览器中获得一个 PDF 页面 - 但它似乎忽略了 bootstrap 4 网格系统,并且字体比预期的要小得多。

控制器代码

respond_to do |format|
  format.html
  format.pdf do
    render(pdf: "carrier_out_file",
           viewport_size: '1280x1024',
           template: 'carriers/order_now_as_pdf')
  end

查看代码

    <!doctype html>
    <html>
     <head>
     <meta charset='utf-8'/>
     <%= wicked_pdf_stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" %>
     <%= wicked_pdf_javascript_include_tag "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" %>
     <!--    <!-- Latest compiled and minified CSS -->
     <%=  wicked_pdf_javascript_include_tag "number_pages" %>

     </head>
      <body onload='number_pages'>

       <div id="content">
       ....

【问题讨论】:

标签: bootstrap-4 ruby-on-rails-5 wicked-pdf


【解决方案1】:

已知问题是 wkpdftohtml 对基于 flexbox 的网格系统的支持有限,因为它使用的是旧版本的 Qt WebKit。一种选择是尝试将您的 wkpdftohtml 版本切换到最新的边缘版本 gem 'wkhtmltopdf-binary-edge'。另一种选择是重写部分 html 以使用基于表格的系统,甚至恢复为基于浮点的网格系统。

欲了解更多信息,请参阅:https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1522

至于字体问题,您可以考虑设置 wicked_pdf.rb 配置以包含 disable_smart_shrinking: true 我希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2015-02-22
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    • 2018-03-03
    • 2018-12-30
    • 1970-01-01
    相关资源
    最近更新 更多