【问题标题】:wicked_pdf without yield contentwicked_pdf 没有收益内容
【发布时间】:2014-09-16 07:52:09
【问题描述】:
<%= wicked_pdf_stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= wicked_pdf_javascript_include_tag "application", "data-turbolinks-track" => true%>


def show
  @invoice_items = @invoice.accounts_receivables_items

  respond_to do |format|
    format.html { render :template => "invoices/show"}
    format.pdf  {render :pdf => "invoices/show",
                        :template => 'layouts/application.html', formats: :html, encoding: 'utf8', :show_as_html => params[:debug].present?}
  end
end

我明白了。这是我的网页(layout/application.html),但没有 &lt;%= yield %&gt; 内容

编辑

【问题讨论】:

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


    【解决方案1】:

    因为您指定:template 为您的布局文件,所以它会在没有视图的情况下呈现您的布局。

    更像这样的东西怎么样(注意模板和布局键):

    render pdf: "invoice",
           layout: 'layouts/application.html',
           template: 'invoices/show',
           formats: :html,
           encoding: 'utf8',
           show_as_html: params[:debug].present?
    

    【讨论】:

    • @sparkle 您是否使用了某种非标准字体或字体库可以做到这一点?
    • 是的,已修复。我已经用我的css中的asset_url()替换了每个asset_path(),它们引用了字体,并且我在我的环境中设置了config.action_controller.asset_host = "website.com"
    猜你喜欢
    • 2014-10-21
    • 2021-02-11
    • 2011-01-28
    • 2019-09-19
    • 2012-11-26
    • 1970-01-01
    • 1970-01-01
    • 2011-08-08
    • 2016-11-07
    相关资源
    最近更新 更多