wkhtmltopdf footer-html encoding utf-8
Asked Answered
S

2

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

Sheer answered 30/1, 2014 at 11:52 Comment(3)
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.Insensate
I have only now found your post. I posted about the same problem here: #23388326, 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.Florie
Possible duplicate of wkhtmltopdf - encoding issueStafford
H
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">
Hamster answered 7/4, 2014 at 13:36 Comment(2)
I had the same issue and this fixed itNostrum
here is output example gist.github.com/equivalent/27d4abbb78ea991778316526f87fff94Mohsen
I
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
Inharmonious answered 3/3, 2018 at 16:11 Comment(4)
The image clearly shows it's a simple encoding problem, as explained in the most-upvoted answer.Sprightly
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.Inharmonious
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.Sprightly
For HINDI (Indic) font I have to install Mangal font.Bukharin

© 2022 - 2024 — McMap. All rights reserved.