I'm having issues with the Annotate PDF feature that is new on Moodle 3.1. I can get it to work with PDF files, but the other files come across as just a blank white page. When I run the test script for unoconv that is included as part of Moodle, it says that it is not able
I am running Moodle 3.1+ on CentOS 7.2 (x86_64), Apache 2.4.6, PHP 5.4.16, and MariaDB (MySQL drop-in replacement) 5.5.47.
I installed LibreOffice 5.1.4 from RPM and cloned unoconv from the Github repository, so I am running the latest version of it. I followed the advice in the readme file to change the script's shebang line to reference the Python that is included as part of LibreOffice. After doing that, the script worked fine from command line using:
unoconv -f pdf filename.doc
or the like, when I was the root user or the regular user under which I log in. However, it got a permissions error exit 77 when trying to spawn the LibreOffice listener instance when I tried running it as the user under which the web server runs (apache).
I was able to resolve this error on the command line as the apache user by running:
export HOME=/tmp
before running unoconv. See http://superuser.com/questions/627266/convert-file-to-pdf-using-libreoffice-under-user-apache-i-e-when-using-php.
However, I think that the home directory may not be getting set when I try to create a file for unoconv in Moodle itself. I tried modifying file_storage.php to have the following:
shell_exec('export HOME=' . $tmp); $cmd = escapeshellcmd(trim($CFG->pathtounoconv)) . ' ' . escapeshellarg('-f') . ' ' . escapeshellarg($format) . ' ' . escapeshellarg('-o') . ' ' . escapeshellarg($newtmpfile) . ' ' . escapeshellarg($filename);
However, that did not make a difference. The test pdf file that unoconv is supposed to create is still 0 bytes in size.