-->

wkhtmltopdf footer-html encoding utf-8

2019-03-17 11:42发布

问题:

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

回答1:

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

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


回答2:

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