Wicked_pdf和utf8符号

时间:2014-04-22 21:58:31

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

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

0,00 €

而不是

0,00 €

Application.html.erb

  <meta charset="utf-8">
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />

show.html.erb

<%=number_to_currency item.total%>

2 个答案:

答案 0 :(得分:12)

respond_to do |format|
      format.html { render :template => "invoices/show"}
      format.pdf  {render :pdf => "invoices/show",
                :template => 'invoices/show', formats: :html, encoding: 'utf8'}
    end

答案 1 :(得分:0)

我仍然可以看到 PDF 中的特殊字符。下面是我的代码

pdf = WickedPdf.new.pdf_from_string(page_html,:page_size => "A3") 

  send_data(pdf, 
    :filename => "my_pdf_name.pdf", 
    :formats => 'HTML', 
    :encoding => 'utf8',
    :disposition => 'attachment') 
  end