Wicked_pdf和utf8符号

spa*_*kle 6 ruby-on-rails utf-8 wicked-pdf ruby-on-rails-4

在我生成的pdf中,我得到了这个

0,00 €
Run Code Online (Sandbox Code Playgroud)

代替

0,00 €
Run Code Online (Sandbox Code Playgroud)

Application.html.erb

  <meta charset="utf-8">
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
Run Code Online (Sandbox Code Playgroud)

show.html.erb

<%=number_to_currency item.total%>
Run Code Online (Sandbox Code Playgroud)

spa*_*kle 13

respond_to do |format|
      format.html { render :template => "invoices/show"}
      format.pdf  {render :pdf => "invoices/show",
                :template => 'invoices/show', formats: :html, encoding: 'utf8'}
    end
Run Code Online (Sandbox Code Playgroud)

  • 您也可以将相同的设置`encoding:'utf8'`放入initializers\wicked_pdf配置文件中 (5认同)