Search code examples
phplibreofficexilinx

After installing Libreoffice service on Linux server with ROOT user, normal user cannot call Libreoffice API


System: Centos 7.
Installed Libreoffice service with root user, and when switching to normal user abc to call the API, it prompts.

javaldx failed!
Warning: failed to read path from javaldx

Call command: /usr/bin/libreoffice7.0 --headless --convert-to pdf a.xlsx --outdir a.pdf

originally intended to use php exec to execute the Libreoffice API to convert PDF documents command. So what is the solution, you can use ordinary users (including www) to call the Libreoffice API?


Solution

  • The correct answer:

    /usr/bin/libreoffice7 -env:UserInstallation=file:///$HOME/.libreoffice-headless/ --convert-to pdf '.$infile_path.' --outdir '.$outfile_path

    The point is -env:UserInstallation=file:///$HOME/.libreoffice-headless/