How to use UTF-8 in PDFKit in Rails?

点点圈 提交于 2019-12-19 07:52:47

问题


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 I force it to use UTF-8?


回答1:


Fixed by adding this to in the html head:

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



回答2:


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


来源:https://stackoverflow.com/questions/7367187/how-to-use-utf-8-in-pdfkit-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!