PHP-Unoconv
PHP-Unoconv copied to clipboard
How to get php-unoconv / unoconv working for Ubuntu 14.04?
Most times, any issue with using php-unoconv actually lies in the interaction between unoconv, the libreoffice/openoffice, and the operating system's python modules.
I think to increase more adoption for this php-unoconv, it is good to add more documentation around the area of installing unoconv, libreoffice/openoffice, and the operation system.
I can contribute to the use of this in Ubuntu 14.04 64-bit Server edition using Python 2.7
- git clone directly from the unoconv repo. Forget about ever using the packages standard unoconv. It is usually broken.
- copy the unoconv file into the /usr/bin/unoconv
- Uninstall all versions of open office and libreoffice and follow this https://gist.github.com/luw2007/d5ce9b5e5a27be77054a. Stop at step 4.
- Use this test script to make sure that unoconv itself is okay.
testunoconv.php
putenv('HOME=/var/www/');
$command = 'echo $HOME & unoconv -vvvv --format %s --output %s %s 2>full_path_to_output.txt';
$command = sprintf($command, 'pdf', 'full_path_to_output.pdf', 'full_path_to_input.docx');
exec($command, $output, $result_var);
- Look for the output.txt and you should expect to see something like this:
Verbosity set to level 4
DEBUG: Connection type: socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext
DEBUG: Existing listener not found.
DEBUG: Launching our own listener using /opt/openoffice4/program/soffice.bin.
Input file: full_path_to_input.docx
DEBUG: Terminating OpenOffice instance.
DEBUG: Waiting for OpenOffice instance to exit.
- Even if you don't see this, there will be some useful error messages that you can use to google your way out of this. I highly recommend that php-unoconv include this as a function somewhere for testing purposes. I couldn't have solved the issue without this logger. The logger example given did not set verbosity to vvvv
- Once you can get unoconv to work, it is matter of using
php-unoconv
I honestly think that php-unoconv should replicate the step for high verbosity logging of the unoconv