Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use UTF-8 in PDFKit in Rails?

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?

like image 962
tybro0103 Avatar asked Sep 09 '11 20:09

tybro0103


2 Answers

Fixed by adding this to in the html head:

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
like image 138
tybro0103 Avatar answered Oct 15 '22 17:10

tybro0103


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
like image 28
Govind shaw Avatar answered Oct 15 '22 17:10

Govind shaw