无法使用php中的libreoffice5将doc转换为pdf

时间:2015-09-22 10:51:05

标签: php mysql libreoffice unoconv

我在php中使用libreoffice5将doc转换为pdf时遇到了问题。

我编写了一个Linux shell来将office doc文档转换为pdf(t.sh):

#!/bin/sh
libreoffice5.0 --headless --invisible --convert-to pdf --outdir $1 $2

然后我在apache htdocs dir中创建了一个php文件,如下所示(mytest.php):

<?php 
$cmd = './t.sh ./ ./55ffbc34c3808.docx';
var_dump($cmd);

$rtn = exec($cmd, $rtnResult, $rtnVal);
var_dump($rtnResult);

但是当我运行http://localhost/mytest.php时,页面永远不会停止并且没有打印结果(没有生成pdf)。 当我运行ps -ef | grep libre时,我看到了以下内容:

maijin   10403 10402  0 03:11 ?        00:00:00 /opt/libreoffice5.0/program/oosplash --headless --invisible --convert-to pdf --outdir ./ ./55ffbc34c3808.docx
maijin   10420 10403  1 03:11 ?        00:00:00 /opt/libreoffice5.0/program/soffice.bin --headless --invisible --convert-to pdf --outdir ./ ./55ffbc34c3808.docx
maijin   10427  8755  0 03:11 pts/1    00:00:00 grep libre

这些过程永远不会停止。 我检查了libreoffice并且它是正确的:

>ls -l  /usr/local/bin/libreoffice5.0
lrwxrwxrwx 1 root root 35 Aug 22 02:54 /usr/local/bin/libreoffice5.0 -> /opt/libreoffice5.0/program/soffice

如果我在linux控制台中运行t.sh shell,则可以生成pdf文件。 为什么我不能在php中将doc转换为pdf?

0 个答案:

没有答案
相关问题