I have a web server set up on my laptop. I am building a web application which I am accessing through the local network. I have a php file which contains the following lines:
$command = "/usr/bin/oowriter --invisible --convert-to pdf /var/www/hackathon/document/gaurav.doc -outdir /var/www/hackathon/pdf/"
exec($command, $output, $return_var);
print_r($output);
So, the problem is that when I run the above code in the terminal php runs perfectly. But when accessed via a web browser, output is just empty and no conversion is done as intended.
Apache error log shows the following lines:
[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!
Warning: failed to read path from javaldx
I have tried solutions from https://wiki.archlinux.org/index.php/Libreoffice#Fixing_Java_Framework_Error. But it didn't work.
I am using OpenJDK 7.
Does anybody have any idea on how to make this work?
Can't vote, can't comment (yet)... So...
What Tim-Erwin said is true.
The error actually states that Error in function createSettingsDocument which is a hint that some function named createSettingsDocument (note: create Settings Document) is failing....
Here's how you (or atleast I) get it to work:
On my server the needed directory was actually /var/www/libreoffice, while in my desktop machine,the directory would of been /var/www/.config/libreoffice so you need to make sure.
Fraber's answer solved the problem for me!
Used:
$cmd = 'HOME='.getCWD().' && export HOME && libreoffice --headless ....';
exec($cmd);
libreoffice then created '.config' and 'libreoffice' directories in the php script directory. Obviously it must be writeable by the webserver process.
OpenOffice needs a user directory. Since you are trying to invoke OpenOffice with the web server, you have to grant the respective user write access to is. On Debian, for instance, that would mean to allow www-data to write to /var/www/.openoffice.org/:
mkdir /var/www/.openoffice.org
chown www-data /var/www/.openoffice.org
I got the same error message running "ooffice --headless --convert-to pptx filename" from a Web server (actually "NaviServer" 4.99). The solutions above did not solve my issue, but they got me on the right track. It turned out that NaviServer changes the "HOME" environment variable to it's installation directory /usr/local/ns, so that LibreOffice tried to access and create a .config folder in this directory. I found out by executing the BASH "set" command from the Web server and checking the environment variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With