WKHTML + Windows + PHP
我从这里安装了 wkhtml http://code.google.com/p/wkhtmltopdf/downloads/列表(特别是 Windows 的 wkhtmltox-0.11.0_rc1-installer.exe)。我从命令行调用 ir 并且它工作得很好,但是当我尝试使用 PHP exec 或 shell_exec 函数调用它时,只有当 wkhtmltopdf.exe 位于我的 php 所在的同一目录中时它才有效。
所以,如果我这样做:
exec("wkhtmltopdf c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf");
并且 wkhtmltopdf 文件位于 c:/wamp/www/test 目录中,它工作得很好,但如果我这样做:
exec("C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf");
它根本不起作用。
你能帮助我吗?我想让它工作,即使它位于另一个目录中。
谢谢。
I installed wkhtml from here http://code.google.com/p/wkhtmltopdf/downloads/list (specically the wkhtmltox-0.11.0_rc1-installer.exe for Windows). I called ir from the command line and it worked perfect, but when I try to call it using the PHP exec or shell_exec function, it only works if the wkhtmltopdf.exe is located in the same directory my php is.
So, if I do this:
exec("wkhtmltopdf c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf");
and the wkhtmltopdf file is in the c:/wamp/www/test directory it works perfect, but if I do this:
exec("C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf");
it doesn't work at all.
Can you help me? I'd like to make it work even when it's in another directory.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于空格,您必须将路径放在引号中。
或者,您可以将 wkhtmltopdf 目录添加到您的
PATH
变量中。You have to put the path in quotes beacause of the space.
Alternatively you could just add the wkhtmltopdf directory to your
PATH
variable.使用 Snappy ,将使使用 wkhtmltpdf 生成 pdf 的生活更轻松
Use Snappy , will make life easier for generating pdf using wkhtmltpdf
像这样改变你的执行编码。它对我有用。:)
快乐编码...:) :)
change your exec coding like this.it works for me.:)
Happy coding...:) :)
这对我有用:
This worked for me: