简体   繁体   English

使用LibreOffice使用PHP的EXEC将DOCX转换为PDF的问题

[英]Issue Using LibreOffice to Convert DOCX to PDF using PHP's EXEC

I am having an issue with running the exec command on a Windows-based PHP server. 我在基于Windows的PHP服务器上运行exec命令时遇到问题。

I am attempting to convert .docx files to .pdf files using LibreOffice Portable. 我正在尝试使用LibreOffice Portable将.docx文件转换为.pdf文件。 The revelant section of code is below: 代码的相关内容如下:

exec('LibreOfficePortable/App/libreoffice/program/soffice.exe'
    . ' --headless --convert-to pdf'
    . ' C:\inetpub\wwwroot\eCaseDev\Webapp\pdfmaker\output.20.docx'
    . ' --outdir C:\inetpub\wwwroot\eCaseDev\Webapp\pdfmaker');

The issue is that that the command does not complete, leaving the browser waiting indefinitely until it times out. 问题在于该命令未完成,使浏览器无限期等待直到超时。 The same command works when run directly in the Windows command prompt. 直接在Windows命令提示符下运行时,该命令也有效。

I believe the issue may be related to the permissions of the user the PHP process is run under, though I have given full permissions to all users for the executable being called (unless I have done this incorrectly). 我相信问题可能与运行PHP进程的用户的权限有关,尽管我已将所有可执行文件的权限授予所有用户(除非我不正确地执行了此操作)。

Try with shell_exec(); 尝试使用shell_exec();

It checks if the permissions are set well in: 它检查权限设置是否正确:

  • C:/windows/temp C:/窗口/温度
  • C:/ program files (x86)/Java C:/程序文件(x86)/ Java
  • folder pdfmaker 文件夹pdfmaker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM