wkhtml库不接受url中的第二个参数?

时间:2012-08-09 08:44:02

标签: wkhtmltopdf

我使用wkhtml库进行html到pdf生成,但是它不接受url中的第二个参数?

exec('C://"Program Files"//wkhtmltopdf.exe ' . 'http://localhost/test.php?a=351&b=2' . ' ' . $file_name . '');

有什么想法吗?

2 个答案:

答案 0 :(得分:5)

尝试将命令设置为变量,回显它并直接在可执行文件上尝试,而不是从PHP。这可能会给你一个可读的错误。

另外,尝试将url放在引号中,我只是尝试了以下命令,它运行良好

wkhtmltopdf.exe "https://www.google.com/search?hl=fi&safe=off&biw=1195&bih=732&site=imghp&tbm=isch&sa=1&q=test&oq=test" test.pdf

答案 1 :(得分:1)

我建议使用escapeshellarg()(转义&这会导致问题成为shell命令的保留字符)

$print_url = escapeshellarg("http"//site.com/print_page.php?arg1=$arg1&arg2=$arg2");

然后:

$print = exec("/usr/bin/wkhtmltopdf -T 0 -B 0 -L 0 -R 0  $print_url  $path/$file 2>&1");