在php中从网页生成pdf

发布于 2024-12-13 05:29:25 字数 291 浏览 5 评论 0原文

如何从服务器即 执行命令 wkhtmltopdf http://google.com /tmp/test.pdf http://localhost/test.php,当我从命令行执行它时,它可以工作。我尝试了 system() 和 exec() 函数,但没有成功。当我使用 system('touch /tmp/test') 文件时被创建。是什么阻止了 wkhtmltopdf?是php、apache吗?

how can I execute command wkhtmltopdf http://google.com /tmp/test.pdf from server ie http://localhost/test.php, when I do it from command line it works. I tried system() and exec() functions but did not work. When I use system('touch /tmp/test') file is created. What stops wkhtmltopdf? Is it php, apache?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

还给你自由 2024-12-20 05:29:25

确保运行脚本的用户知道 wkhtmltopdf bin 的位置。

您可以使用which命令找出它在哪里。

which wkhtmltopdf 

您还可以通过设置等于命令的变量来获取命令的返回状态
例如

$last_line = system('ls');
echo $last_line

Make sure that the user the script is running as knows where wkhtmltopdf bin is.

You can find out where it is with the which command.

which wkhtmltopdf 

Also you can get the return status of a command by setting a variable equal to it
e.g.

$last_line = system('ls');
echo $last_line
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文