wkhtmltopdf - encoding issue

烈酒焚心 提交于 2019-12-01 02:26:06

For future reference:

I had the same problem with german umlauts.

As soon as I added

<meta charset="UTF-8" />

to the html page the problem was solved.

That of course presupposes your page is served as utf-8.

I solved the issue! The catch was in constant WKHTML_LIB, which I defined on the beginning of the page:

define('WKHTML_LIB', "../wkhtmltopdf/wkhtmltopdf-amd64");

I just wrote the path directly to the exec(); command and now it works even with the flags. Sorry for bothering you with such a triviality... Now the $commandString line looks like this:

$commandString = '"../wkhtmltopdf/wkhtmltopdf-amd64" --print-media-type --page-size A4 -R     50 --encoding windows-1250 --header-html header.html --margin-top 10mm --margin-bottom 10mm --margin-left 10mm --margin-right 10mm http://www.estiroad.com/export.php sestava.pdf';

I had a similar problem with wkhtmltopdf before where the Chinese characters were not rendered properly. I have solved the problem by installing the appropriate Chinese fonts.

By any chance do you have to install any Czech related fonts for the characters to render properly? As I am not familiar with Czech characters / fonts, I am not sure whether this applies. Hope this helps.

Just now I made a test with those characters you provided and they work fine for me. Win7, wkhtmltopdf 0.11.0 rc2. Works on cover, toc, bookmarks, content and headers. Also tested with korean and chinese characters and even they work.

PDF Generated using (file locations removed) --print-media-type --page-size A5 --header-html header.html --footer-html footer.html --margin-bottom 10mm --margin-top 10mm --margin-left 10mm --margin-right 10mm cover cover.html toc --xsl-style-sheet tocfile.xsl temp.html temp.pdf

temp.html is Extremely invalid XHTML, first line says <?xml version="1.0" encoding="iso-8859-1"?>. The temp.html file was written to disk with C# using UTF-8 and it works. I really suggest using UTF-8 wherever possible.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!