I'm trying to generate a pdf from docx using soffice so i try it on apache linux and its works, but im trying in windows server 2012 and IIS 6.2.
If i run this command on CMD its works:
soffice --headless --convert-to pdf:writer_pdf_Export --outdir ../../storage/app/ACTIVO/2019-03/3404/docx/ ../../storage/app/ACTIVO/2019-03/3404/docx/documento_word.docx
So in PHP I try this:
$comando = 'soffice --headless --convert-to pdf:writer_pdf_Export --outdir ../../storage/app/ACTIVO/2019-03/3404/docx/ ../../storage/app/ACTIVO/2019-03/3404/docx/documento_word.docx';
$var = exec($comando);
var_dump($var);
And its give me "NULL"
The same happen when i try to use soffice --version in PHP.
I give full permission to IUSR in C:\Program Files\Libreoffice and storage/app have permission too. In IIS the Anonymous Authentication is enabled.
I run in php and its return " string(26) "iis apppool\defaultapppool" "
$var = exec('whoami');
var_dump($var);
I don't know how can i do to fix it.
答案 0 :(得分:0)
我解决了这个问题,在Windows中创建了一个新用户,该用户具有较低的权限来运行类似该用户的命令。 一世 nstall SysinternalsSuite运行psexec命令,在C:\
中将zip解压缩。因此,我更改的行是:
$comando = 'soffice --headless --convert-to pdf:writer_pdf_Export --outdir ../../storage/app/ACTIVO/2019-03/3404/docx/ ../../storage/app/ACTIVO/2019-03/3404/docx/documento_word.docx';
收件人:
$comando = '"C:\SysinternalsSuite\psexec.exe" -u DOMAIN\USER -p PASSWORD "C:\Program Files\LibreOffice\program\soffice.exe" --headless --convert-to pdf:writer_pdf_Export --outdir C:\inetpub\wwwroot\storage\app\ACTIVO\2019-03\3404\docx\ C:\inetpub\wwwroot\storage\app\ACTIVO\2019-03\3404\docx\documento_word.docx';