Online Text Assignment doesn't covert to pdf.

Re: Online Text Assignment doesn't covert to pdf.

by Derick Turner -
Number of replies: 1
Picture of Core developers

I'm experiencing the same issue on on Ubuntu 16.04.1 server with unoconv etc installed from the repositories.  Followed the installation instructions and assignments were still blank.  A little bit of digging on Uniconv later and it appears that it could be something to do with the security settings on the site for the www-data user.  I changed the shell for the account to be /bin/false and followed the instructions here - https://github.com/dagwieers/unoconv/issues/87 on the 12th July 2016.  Specifically added the line 

os.environ['HOME'] = '/tmp'

after line 1206 in the unoconv script.

You can test if it works by taking a .docx file and running the following to try and convert it

sudo -u www-data unoconv -vvvv -f pdf /var/www/test.docx

If it fails you get the following output:

Verbosity set to level 4
Using office base path: /usr/lib/libreoffice
Using office binary path: /usr/lib/libreoffice/program
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 /usr/lib/libreoffice/program/soffice.bin.
LibreOffice listener successfully started. (pid=27637)
Failed to connect to /usr/lib/libreoffice/program/soffice.bin (pid=27637) in 6 seconds.
Connector : couldn't connect to socket (Success)
Error: Unable to connect or start own listener. Aborting.

After the change to the script (/usr/bin/unoconv in my case) I got the following output:

Verbosity set to level 4
Using office base path: /usr/lib/libreoffice
Using office binary path: /usr/lib/libreoffice/program
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 /usr/lib/libreoffice/program/soffice.bin.
LibreOffice listener successfully started. (pid=27841)
DEBUG: Caught exit code 81 (new installation). Restarting listener.
DEBUG: Existing listener not found.
DEBUG: Launching our own listener using /usr/lib/libreoffice/program/soffice.bin.
LibreOffice listener successfully started. (pid=27848)
Input file: /var/www/test.docx
Selected output format: Portable Document Format [.pdf]
Selected office filter: writer_pdf_Export
Used doctype: document
Output file: file:///var/www/test.pdf
DEBUG: Terminating LibreOffice instance.
DEBUG: Waiting for LibreOffice instance to exit.

Which is obviously a much better result.  Unfortunately I don't have any assignments which haven't been opened and it's a live client site.  I will check with them tomorrow and report back.

In reply to Derick Turner

Re: Online Text Assignment doesn't covert to pdf.

by Marianne Michel -

Hello.

We solved the problem (Debian 8, Moodle 3.3.1+) creating a .config file in /var/www (home directory of the user www-data) and made a chown www-data:www-data on the file.

After that, you will need to convert twice a first file.

Marianne.