5

When I generate a PDF with text containing characters such as é è à and so on I do get funny characters instead.

I know this must be related to encoding.

I did try force_encoding("UTF-8") on the string with those characters with no success.

joel

4

4 回答 4

8

添加<meta charset="UTF-8">到 HTML 视图的顶部或布局的头部。

于 2012-03-09T01:35:14.623 回答
7

您可以作为选项传递:

encoding: 'utf8'
于 2012-09-20T06:15:25.247 回答
4

您也可以将其添加为 wickedpdf 中的选项

 WickedPdf.new.pdf_from_string(
    render :pdf => "Paper",
    :template => "paper/paper.html",
    :page_size => 'A4',
     formats: :html, encoding: 'utf8',
    :margin => {:top => 40}
  )
于 2014-07-15T12:14:54.107 回答
0

要解决此问题,请在视图开头添加以下行:

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

您可以参考此链接 - https://github.com/mileszs/wicked_pdf/issues/35了解更多详情。

于 2014-04-21T07:53:08.103 回答