7

我如何通过 php 执行这两个命令行:

wkhtmltopdf www.google.com gg.pdf

&

oofice -headless -nologo -pt cup-pdf my.doc

他们都返回一个pdf文件并下载到我的主目录中。

我想知道如何通过 php 从我的 html 页面执行这些命令。

谢谢。

4

2 回答 2

15

You should take a look at the System program execution section of the manual : PHP provides several functions that can be used to launch external commands / programs, including :

  • exec() -- which can store the output of the command in an array
  • shell_exec() -- which returns, as a string, the output of the command
  • system() -- which echoes the output of the command
于 2011-07-22T22:10:50.540 回答
2

要从 php(在 linux 中)创建 pdf,您必须使用包装器。

$cmd = '/usr/bin/xvfb-run --server-args="-screen 0, 1920x1080x24" /usr/bin/wkhtmltopdf http://google.com /tmp/google.pdf';

exec($cmd);
于 2013-10-01T20:34:36.033 回答