wkhtmltopdf - 编码问题 [英] wkhtmltopdf - encoding issue

查看:245
本文介绍了wkhtmltopdf - 编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用wkhtmltopdf将HTML页面导出到pdf,但是它似乎与捷克语字符有问题...我将整个html加载到变量中,然后更改编码并运行wkhtmltopdf,如下所示:

I'm using wkhtmltopdf to export html pages to pdf, but it seems it has a problem with Czech characters... I load whole html into variable, then I change encoding and run wkhtmltopdf like this:

$html = ob_get_clean();
$html = iconv("UTF-8","Windows-1250", $html);
file_put_contents('../export.php', $html);

$commandString = WKHTML_LIB.'http://www.estiroad.com/export.php sestava.pdf';
exec($commandString);

.html文件具有正确的编码,但即使我设置--encoding windows-1250参数命令字符串,它只是不工作...感谢任何想法...

The .html file has the right encoding, but even when I set --encoding windows-1250 parameter to command string, its just not working... Thanks for any ideas...

编辑:
我解决了问题!这个捕获是不断的WKHTML_LIB,我在页面的开头定义:

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");

我只是将路径直接写入exec();命令,现在它甚至与标志一起工作。对不起,困扰你这样一个琐碎的...
现在$ commandString行看起来像这样:

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';


推荐答案

我解决了这个问题!这个捕获是不断的WKHTML_LIB,我在页面的开头定义:

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");

我只是将路径直接写入exec();命令,现在它甚至与标志一起工作。对不起,这样一个琐碎的烦恼...现在$ commandString行看起来像这样:

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';

这篇关于wkhtmltopdf - 编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆