1

I have the following issue I am using Ubuntu and I am using a simple libreOffice conversion command

$command_conversion = 'libreoffice --headless --convert-to pdf:writer_pdf_Export --outdir /home/stilian/Desktop /home/stilian/Desktop/sample.doc';

exec($command_conversion. $output);

The command is working fine in the terminal but not when I open the webpage to execute the command. I also double checked for errors in the command there are none. also the variable $output is an empty array. Any suggestions would be appriciated.

12
  • What happens when you execute the command through webpage? Does it give any errors? Also, can you check the returned value of exec command using the last optional parameter? Commented Jun 29, 2017 at 8:25
  • is libreoffice in the PATH of the webserver user (www-data usually) Commented Jun 29, 2017 at 8:26
  • The variable is empty and it gives no errors whatsoever. @apokryfos What do you mean I am new to Ubuntu if you can be more specific. Commented Jun 29, 2017 at 8:27
  • Check $_SERVER["PATH"] and make sure the path to libreoffice binary is in the path variable e.g. do which libreoffice and if e.g. the result is /usr/local/bin/libreoffice you need to check if /usr/local/bin is in $_SERVER["PATH"] Commented Jun 29, 2017 at 8:29
  • The path to the libreoffice is "usr/lib/libreoffice/program" and it is not in the variable. Should I add it somehow ? Commented Jun 29, 2017 at 8:49

1 Answer 1

1

Change dot by comma

$command_conversion = 'libreoffice --headless --convert-to pdf:writer_pdf_Export --outdir /home/stilian/Desktop /home/stilian/Desktop/sample.doc';

exec($command_conversion, $output);
Sign up to request clarification or add additional context in comments.

1 Comment

It was changed when I was writing it I made the mistake, sorry about that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.