Rails, spooky-drawing gem and é à ö characters displaying incorrectly

When I create a PDF file with text containing characters such as é è à, etc., I get funny characters instead.

I know this should be due to the encoding.

I tried force_encoding ("UTF-8") on a string with these characters without success.

joel

+5
source share
4 answers

Add <meta charset="UTF-8">at the top of your HTML view or at the top of your layout.

+7
source

You can go as an option:

encoding: 'utf8'
+5
source

wickedpdf

 WickedPdf.new.pdf_from_string(
    render :pdf => "Paper",
    :template => "paper/paper.html",
    :page_size => 'A4',
     formats: :html, encoding: 'utf8',
    :margin => {:top => 40}
  )
+1

, :

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

You can refer to this link - https://github.com/mileszs/wicked_pdf/issues/35 for more details.

0
source

All Articles