How to use UTF-8 in PDFKit in Rails?

前端 未结 2 765
梦谈多话
梦谈多话 2020-12-19 08: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?

相关标签:
2条回答
  • 2020-12-19 08:54
    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 讨论(0)
  • 2020-12-19 08:55

    Fixed by adding this to in the html head:

    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    
    0 讨论(0)
提交回复
热议问题