38

wkhtmltopdf --encoding utf-8 is not working for --footer-html.

I am using the following command. Both HTML files are also in utf8 format.

wkhtmltopdf  --dpi 120 -O Portrait --encoding 'utf-8' --footer-html /tmp/testFooter.html  /tmp/testMain.html  /tmp/testPDF.pdf

Both files have french characters. But in pdf footer have bad characters.

<html>
     <head>
        <title></title>
     </head>
    <body>
    <div style="width:95%;font-size:9pt;font-family:Arial;">
    <div style="border-top: 1px solid black;width: 100%;text-align: center;">
    test - Guérin 691BANNE - FRANCE - SA au capital 0 Euros -737 729 - Téléphone :  86 03</div></div>
    </body>
</html>

Following image is output enter image description here

Vineet Jain
  • 1,515
  • 4
  • 21
  • 31
  • Can you give us a small example of a HTML file that does not work? I don't even define --encoding and everything still works for me. – Joel Peltonen Jan 31 '14 at 11:34
  • I have only now found your post. I posted about the same problem here: http://stackoverflow.com/questions/23387826/print-utf-chars-in-page-header-footer-with-wkhtmltopdf, but I am not giving the html with --footer-html option. Instead I was specifying it with --footer-left. Actually --header-left, but not important. I was going to try with --footer-html next, but obviously that doesn't work too. – userfuser Apr 30 '14 at 12:18
  • Possible duplicate of [wkhtmltopdf - encoding issue](http://stackoverflow.com/questions/11859872/wkhtmltopdf-encoding-issue) – Nakilon Sep 25 '16 at 07:17

2 Answers2

105

Try adding the following line in the HTML head element of the footer:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
martin
  • 1,219
  • 1
  • 9
  • 12
1

Make sure you have specific font installed there. I need Hindi (Indian Language) on my PDF files. putting meta tag had not solved my problem. So i installed hindi fonts on my debian box by

sudo apt-get install fonts-indic
Terry
  • 307
  • 1
  • 12
  • 1
    The image clearly shows it's a simple encoding problem, as explained in the most-upvoted answer. – Jongware Mar 03 '18 at 17:46
  • For me, i had similar problem. I tried suggested solutions but it did not work for me. That's how i came to know i need to install new font. now without suggested metatag, i can print foreign language which i was interested in. – Terry Mar 05 '18 at 19:33
  • You may have had a *similar* problem, but it's not so similar that this answer would solve the issue that is being asked here. – Jongware Mar 05 '18 at 20:59
  • For HINDI (Indic) font I have to install Mangal font. – makwana.a Apr 23 '22 at 10:05