在Windows PHP exec()上运行(生成PDF)办公LibreOffice不起作用 [英] Running (Generate PDF) soffice LibreOffice on Windows PHP exec() doesn't work

查看:115
本文介绍了在Windows PHP exec()上运行(生成PDF)办公LibreOffice不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用soffice从docx生成pdf,所以我在apache linux及其工作上尝试使用pdf,但是我在Windows Server 2012和IIS 6.2中尝试使用.

如果我在CMD上运行此命令,则其工作原理:

  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 

所以在PHP中,我尝试这样做:

  $ 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); 

它给我"NULL"

当我尝试在PHP中使用soffice --version时,也会发生同样的情况.

我在C:\ Program Files \ Libreoffice中对IUSR授予完全许可,并且存储/应用也具有许可.在IIS中,启用了匿名身份验证.

我在php中运行,并且返回" string(26)" iis apppool \ defaultapppool""

  $ var = exec('whoami');var_dump($ var); 

我不知道该如何解决.

解决方案

我解决了这个问题,在Windows中创建了一个新用户,该用户具有较低的权限来运行类似该用户的命令.一世nstall SysinternalsSuite 以运行psexec命令,该zip文件在C:\

因此,我更改的行是:

  $ 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-到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'; 

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.

解决方案

I solved it, creating a new user in Windows with low permission to run a command like that user. I nstall SysinternalsSuite to run psexec command, the zip is descompressed in C:\

So, the line that i change was:

$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';

to:

$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';

这篇关于在Windows PHP exec()上运行(生成PDF)办公LibreOffice不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆