WKHTML + Windows + PHP

发布于 2025-01-01 09:43:02 字数 684 浏览 4 评论 0原文

我从这里安装了 wkhtml http://code.google.com/p/wkhtmltopdf/downloads/列表(特别是 Windows 的 wkhtmltox-0.11.0_rc1-installer.exe)。我从命令行调用 ir 并且它工作得很好,但是当我尝试使用 PHP exec 或 shell_exec 函数调用它时,只有当 wkh​​tmltopdf.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼眸印温柔 2025-01-08 09:43:02

由于空格,您必须将路径放在引号中。

exec('"C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe" c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf');

或者,您可以将 wkhtmltopdf 目录添加到您的 PATH 变量中。

You have to put the path in quotes beacause of the space.

exec('"C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe" c:/wamp/www/test/pdf.html c:/wamp/www/test/pdf.pdf');

Alternatively you could just add the wkhtmltopdf directory to your PATH variable.

め可乐爱微笑 2025-01-08 09:43:02

使用 Snappy ,将使使用 wkhtmltpdf 生成 pdf 的生活更轻松

Use Snappy , will make life easier for generating pdf using wkhtmltpdf

如痴如狂 2025-01-08 09:43:02

像这样改变你的执行编码。它对我有用。:)

exec("C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe" c:/wamp/www/test/pdf.html "c:/wamp/www/test/pdf.pdf");

快乐编码...:) :)

change your exec coding like this.it works for me.:)

exec("C:/Program Files/wkhtmltopdf/wkhtmltopdf.exe" c:/wamp/www/test/pdf.html "c:/wamp/www/test/pdf.pdf");

Happy coding...:) :)

奶茶白久 2025-01-08 09:43:02

这对我有用:

exec('"C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe" "c:/wamp/www/catalogo_2.html" "c:/wamp/www/pdf.pdf"');

This worked for me:

exec('"C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe" "c:/wamp/www/catalogo_2.html" "c:/wamp/www/pdf.pdf"');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文