我如何通过 php 执行这两个命令行:
wkhtmltopdf www.google.com gg.pdf
&
oofice -headless -nologo -pt cup-pdf my.doc
他们都返回一个pdf文件并下载到我的主目录中。
我想知道如何通过 php 从我的 html 页面执行这些命令。
谢谢。
我如何通过 php 执行这两个命令行:
wkhtmltopdf www.google.com gg.pdf
&
oofice -headless -nologo -pt cup-pdf my.doc
他们都返回一个pdf文件并下载到我的主目录中。
我想知道如何通过 php 从我的 html 页面执行这些命令。
谢谢。
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 arrayshell_exec()
-- which returns, as a string, the output of the commandsystem()
-- which echoes the output of the command要从 php(在 linux 中)创建 pdf,您必须使用包装器。
$cmd = '/usr/bin/xvfb-run --server-args="-screen 0, 1920x1080x24" /usr/bin/wkhtmltopdf http://google.com /tmp/google.pdf';
exec($cmd);