开发者

How to use UTF-8 in PDFKit in Rails?

开发者 https://www.devze.com 2023-04-03 17:09 出处:网络
I\'m using PDFKit in my Rails app to generate PDF\'s. Problem is some of my content in contains non-ascii characters. How do 开发者_StackOverflow中文版I force it to use UTF-8?Fixed by adding this to i

I'm using PDFKit in my Rails app to generate PDF's. Problem is some of my content in contains non-ascii characters. How do 开发者_StackOverflow中文版I force it to use UTF-8?


Fixed by adding this to in the html head:

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


You can write in PDFKIT configration.

 PDFKit.configure do |config|
        config.wkhtmltopdf = '/opt/wkhtmltopdf'
        config.default_options = {
          :encoding      => 'UTF-8'
          :page_size     => 'Letter',
          :margin_top    => '0.3in',          
          :margin_bottom => '0.1in',          
          :print_media_type => true                       
        }
 end
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号