When I generate a PDF with text containing characters such as é è à and so on I do get funny characters instead.
I know this must be related to encoding.
I did try force_encoding("UTF-8") on the string with those characters with no success.
joel
When I generate a PDF with text containing characters such as é è à and so on I do get funny characters instead.
I know this must be related to encoding.
I did try force_encoding("UTF-8") on the string with those characters with no success.
joel
Add <meta charset="UTF-8">
to the top of your HTML view or in the head of your layout.
You can also add it as an option in the wickedpdf
WickedPdf.new.pdf_from_string(
render :pdf => "Paper",
:template => "paper/paper.html",
:page_size => 'A4',
formats: :html, encoding: 'utf8',
:margin => {:top => 40}
)
To solve this, add the following line at the beginning of your view:
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
You can refer this link - https://github.com/mileszs/wicked_pdf/issues/35 for more details.
© 2022 - 2024 — McMap. All rights reserved.
pdf_from_string
doesn't really hint that you can pass options like this (sans controller/view). Eg this worked for me:pdf = WickedPdf.new.pdf_from_string(html, encoding: 'utf8')
– Geode