Universal Office Converter (unoconv): Difference between revisions

From MoodleDocs
m (clean up, typos fixed: Github → GitHub (2), apache → Apache (4), Ubuntu based → Ubuntu-based, , → , , eg. → e.g.)
 
Line 1: Line 1:
{{Document converters}}
{{Document converters}}
==What is unoconv?==
==What is unoconv?==
"unoconv" is a command line program that is used to convert between different office document file formats. It uses an instance of [http://libreoffice.org LibreOffice] to do the conversion and is used by the [[Assignment activity]] to convert documents to pdf so that they can be annotated. If unoconv is not installed - the only impact is that the assignment activities will only allow annotations when students upload a pdf document.  
"unoconv" is a command line program that is used to convert between different office document file formats. It uses an instance of [http://libreoffice.org LibreOffice] to do the conversion and is used by the [[Assignment activity]] to convert documents to pdf so that they can be annotated. If unoconv is not installed - the only impact is that the assignment activities will only allow annotations when students upload a pdf document.  


The steps required to install unoconv are different depending on the operating system that you have installed Moodle on.  
The steps required to install unoconv are different depending on the operating system that you have installed Moodle on.  
== Installing unoconv on Linux ==
== Installing unoconv on Linux ==
The required version of unoconv is at least 0.7. Depending on your flavour of linux, this may be available in your package manager and you can install it directly with:
The required version of unoconv is at least 0.7. Depending on your flavour of linux, this may be available in your package manager and you can install it directly with:
=== Ubuntu 22.04 LTS ===
You will need to install Python 3, and note that the unoconv will only support Python up to 3.11.
sudo apt install python3
To download the latest version of unoconv (0.8.2):
cd /opt
sudo git clone <nowiki>https://github.com/unoconv/unoconv.git</nowiki>
sudo nano /opt/unoconv/unoconv
Change the first line of code by adding the number 3 to the Python version, as per the example below:
#!/usr/bin/env python3
Permissions and run link:
sudo chmod ugo+x /opt/unoconv/unoconv
sudo ln -s /opt/unoconv/unoconv /usr/bin/
Now we need LibreOffice installed:
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt install libreoffice -y
Production servers should consider running unoconv in listener mode, see [[Installing unoconv#Run a unoconv listener]] or follow directions below:
sudo nano /etc/systemd/system/unoconv.service
And then copy and paste the following configuration into it:
[Unit]
Description=Unoconv listener for document conversions
Documentation=<nowiki>https://github.com/dagwieers/unoconv</nowiki>
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/bin/unoconv --listener
[Install]
WantedBy=multi-user.target
And then enable and start the above service:
sudo systemctl enable unoconv.service
sudo systemctl start unoconv.service


===Ubuntu 18.04 LTS===
===Ubuntu 18.04 LTS===
Line 15: Line 46:
chown www-data:www-data /var/www/.config
chown www-data:www-data /var/www/.config
</pre>
</pre>
===Ubuntu 16.04 LTS===
===Ubuntu 16.04 LTS===
<pre>
<pre>
apt-get install unoconv
apt-get install unoconv
</pre>
</pre>
If your package manager contains an older version of the package, you will have to find a newer version and install it manually ([https://packages.debian.org/stretch/unoconv Debian Testing]). Unoconv itself is just a python script, so it has few dependencies.
If your package manager contains an older version of the package, you will have to find a newer version and install it manually ([https://packages.debian.org/stretch/unoconv Debian Testing]). Unoconv itself is just a python script, so it has few dependencies.


Line 31: Line 60:
deb http://ftp.debian.org/debian jessie-backports main
deb http://ftp.debian.org/debian jessie-backports main
</pre>
</pre>
Then, update and install unoconv from jessie-backports:
Then, update and install unoconv from jessie-backports:
<pre>
<pre>
Line 37: Line 65:
apt-get install -t jessie-backports unoconv
apt-get install -t jessie-backports unoconv
</pre>
</pre>
The package will bring all necessary dependencies for you.
The package will bring all necessary dependencies for you.
===Ubuntu 14.04 LTS===
===Ubuntu 14.04 LTS===
1) Navigate to opt directory
1) Navigate to opt directory
<pre>
<pre>
cd /opt
cd /opt
</pre>
</pre>
2) Download unoconv
2) Download unoconv
<pre>
<pre>
sudo wget https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv
sudo wget https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv
</pre>
</pre>
3) Modify the Python unoconv file by changing 'python' in the first line to 'python3'
3) Modify the Python unoconv file by changing 'python' in the first line to 'python3'
<pre>
<pre>
Line 58: Line 80:
</pre><br>
</pre><br>
e.g. <pre>#!/usr/bin/env python3</pre>
e.g. <pre>#!/usr/bin/env python3</pre>
4) Make unoconv executable
4) Make unoconv executable
<pre>
<pre>
sudo chmod ugo+x /opt/unoconv
sudo chmod ugo+x /opt/unoconv
</pre>
</pre>
5) Add LibreOffice PPA to your system and install the latest version
5) Add LibreOffice PPA to your system and install the latest version
<pre>
<pre>
Line 70: Line 90:
sudo apt-get install libreoffice
sudo apt-get install libreoffice
</pre>
</pre>
6) Change permissions so apache can write to its home directory
6) Change permissions so apache can write to its home directory
<pre>
<pre>
sudo chown www-data /var/www
sudo chown www-data /var/www
</pre>
</pre>
7) From your browser navigate to
7) From your browser navigate to
''Site administration > Server > System paths'' and add the path to unoconv<br>
''Site administration > Server > System paths'' and add the path to unoconv<br>
Line 83: Line 101:
sudo ln -s /opt/unoconv /usr/bin/
sudo ln -s /opt/unoconv /usr/bin/
</pre>
</pre>
 
8) Navigate to
8) Navigate to  
''Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF > Test unoconv path'' <br>
''Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF > Test unoconv path'' <br>
You should see: <br>
You should see: <br>
"The unoconv path appears to be properly configured."
"The unoconv path appears to be properly configured."
*Download the converted pdf test file. (if the PDF fails to load ensure that www-data can write to its home directory: /var/www)
*Download the converted pdf test file. (if the PDF fails to load ensure that www-data can write to its home directory: /var/www)
===CentOS / RedHat===
===CentOS / RedHat===
Just before you start, you might like to consider installing the latest [http://www.tecmint.com/install-libreoffice-on-rhel-centos-fedora-debian-ubuntu-linux-mint/ LibreOffice 6.3.2] directly from RPM packages, that are not part of the distribution you are using.
Just before you start, you might like to consider installing the latest [http://www.tecmint.com/install-libreoffice-on-rhel-centos-fedora-debian-ubuntu-linux-mint/ LibreOffice 6.3.2] directly from RPM packages, that are not part of the distribution you are using.
Line 106: Line 122:
</pre>
</pre>
  Note: depends on what version you are installing, openoffice or libreoffice, make sure you installed the *-pyuno package. (the headless package is already compiled into the core)
  Note: depends on what version you are installing, openoffice or libreoffice, make sure you installed the *-pyuno package. (the headless package is already compiled into the core)
Make sure it is properly configured:
Make sure it is properly configured:
http://your-moodle/admin/search.php?query=unoconv
http://your-moodle/admin/search.php?query=unoconv
Line 138: Line 153:
#setsebool -P httpd_execmem on
#setsebool -P httpd_execmem on
</pre>
</pre>
== Installing unoconv on OS X ==
== Installing unoconv on OS X ==
Download and install LibreOffice for Mac. Unfortunately - newer versions of LibreOffice are not currently compatible with unoconv for mac and you will have to install LibreOffice 4.2 (Direct download link - https://downloadarchive.documentfoundation.org/libreoffice/old/4.2.5.2/mac/x86_64/LibreOffice_4.2.5.2_MacOS_x86-64.dmg).
Download and install LibreOffice for Mac. Unfortunately - newer versions of LibreOffice are not currently compatible with unoconv for mac and you will have to install LibreOffice 4.2 (Direct download link - https://downloadarchive.documentfoundation.org/libreoffice/old/4.2.5.2/mac/x86_64/LibreOffice_4.2.5.2_MacOS_x86-64.dmg).
Line 146: Line 160:
brew install unoconv
brew install unoconv
</pre>
</pre>
If you haven't done it already - install ghostscript. One way to install ghostscript is also with http://brew.sh/ brew
If you haven't done it already - install ghostscript. One way to install ghostscript is also with http://brew.sh/ brew
<pre>
<pre>
brew install ghostscript
brew install ghostscript
</pre>
</pre>
Set the paths to unoconv and ghostscript in Moodle (''Site administration > Server > System paths''). If you used brew, they will both be installed to /usr/local/bin.
Set the paths to unoconv and ghostscript in Moodle (''Site administration > Server > System paths''). If you used brew, they will both be installed to /usr/local/bin.


Line 164: Line 176:
os.environ['HOME'] = '/tmp/'                                                                                                         
os.environ['HOME'] = '/tmp/'                                                                                                         
</pre>
</pre>
This needs to be inserted at line 36 immediately after the line "exitcode = 0"
This needs to be inserted at line 36 immediately after the line "exitcode = 0"
== Installing unoconv on Windows ==
== Installing unoconv on Windows ==
Download and install LibreOffice for Windows. Open Office will work just as well, but the documentation for unonconv is set to Libre Office.  
Download and install LibreOffice for Windows. Open Office will work just as well, but the documentation for unonconv is set to Libre Office.  
Line 177: Line 187:


Create a batch file in the same folder as '''unoconv.py''' name it something like '''unoconv.bat''', it must be a batch file, with these contents:
Create a batch file in the same folder as '''unoconv.py''' name it something like '''unoconv.bat''', it must be a batch file, with these contents:
  @"C:\Program Files\LibreOffice\program\python.exe" c:\unoconv\unoconv.py %*
  @"C:\Program Files\LibreOffice\program\python.exe" c:\unoconv\unoconv.py %*
or:
or:
  @"C:\Program Files\OpenOffice\program\python.exe" c:\unoconv\unoconv.py %*
  @"C:\Program Files\OpenOffice\program\python.exe" c:\unoconv\unoconv.py %*
 
Next, you have to '''Set paths in Moodle.'''
Next, you have to '''Set paths in Moodle.'''  


Login as admin and go to ''Site administration > Server > System paths''
Login as admin and go to ''Site administration > Server > System paths''


Set:
Set:
''Path to Ghostscript (pathtogs)'' to <code>C:\Program Files\gs\gsversion\bin\gswin64c.exe</code>.
''Path to Ghostscript (pathtogs)'' to <code>C:\Program Files\gs\gsversion\bin\gswin64c.exe</code>.
Do not use gswin32.exe or gswin64.exe, these are not command line programs - use gswin32c.exe or gswin64c.exe.  
Do not use gswin32.exe or gswin64.exe, these are not command line programs - use gswin32c.exe or gswin64c.exe.  


Set:
Set:
''Path to Python (pathtopython)'' to <code>C:\Program Files (x86)\OpenOffice\program\python.exe</code> or <code>C:\Program Files (x86)\LibreOffice\program\python.exe</code>.
''Path to Python (pathtopython)'' to <code>C:\Program Files (x86)\OpenOffice\program\python.exe</code> or <code>C:\Program Files (x86)\LibreOffice\program\python.exe</code>.
Identify in the path whichever program you use and include the full exe name for both Ghostscript and Python.
Identify in the path whichever program you use and include the full exe name for both Ghostscript and Python.
 
Save the pathto statements and a green tick should appear if Moodle is communicating with the required files.  
Save the pathto statements and a green tick should appear if Moodle is communicating with the required files.  


Go to ''Site administration > Plugins > Document converters'' and enable '''Unoconv''' then select ''Settings''
Go to ''Site administration > Plugins > Document converters'' and enable '''Unoconv''' then select ''Settings''


Enter the path statement to  
Enter the path statement to
''Path to unoconv document converter'': <code>C:\Program Files (x86)\unoconv\unoconv.bat</code>.
''Path to unoconv document converter'': <code>C:\Program Files (x86)\unoconv\unoconv.bat</code>.
Include the full name of the .bat file.  
Include the full name of the .bat file.  


Test ghostscript and unoconv are working correctly in the admin test pages ''Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF''.
Test ghostscript and unoconv are working correctly in the admin test pages ''Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF''.
== Run a unoconv listener ==
== Run a unoconv listener ==
Unoconv utilises a client/server process when converting documents. By default, when there is no running server process - each time unoconv runs it will start a server process, send its request and shut down the server process when the request is complete. The drawback of this mode is that if 2 requests are submitted simultaneously - this can cause the first request to shutdown the server process when the second request is still in progress - and the second conversion request fails. A more robust way to configure unoconv is to start a server process at boot time, and/or run a script to monitor it and restart it if it crashes.
Unoconv utilises a client/server process when converting documents. By default, when there is no running server process - each time unoconv runs it will start a server process, send its request and shut down the server process when the request is complete. The drawback of this mode is that if 2 requests are submitted simultaneously - this can cause the first request to shutdown the server process when the second request is still in progress - and the second conversion request fails. A more robust way to configure unoconv is to start a server process at boot time, and/or run a script to monitor it and restart it if it crashes.
Line 220: Line 225:


[[mod/assign/feedback/editpdf/testunoconv/systemd | SystemD service script for CentOS/RedHat 7.x]]
[[mod/assign/feedback/editpdf/testunoconv/systemd | SystemD service script for CentOS/RedHat 7.x]]
== Offload processing to a different server ==
== Offload processing to a different server ==
Processing office documents can put increased load on your webserver, which may impact on the responsiveness of your site. If you are installing unoconv on a large site you may want to consider running unoconv on a server that is not also serving web requests.
Processing office documents can put increased load on your webserver, which may impact on the responsiveness of your site. If you are installing unoconv on a large site you may want to consider running unoconv on a server that is not also serving web requests.
Line 234: Line 238:
unoconv --listener --server 0.0.0.0 --port 2002
unoconv --listener --server 0.0.0.0 --port 2002
</pre>
</pre>
Open the firewall port 2002 between the moodle webservers and the machine running unoconv.
Open the firewall port 2002 between the moodle webservers and the machine running unoconv.


Line 246: Line 249:
/usr/bin/unoconv --server=<ip of remote server> "$@"
/usr/bin/unoconv --server=<ip of remote server> "$@"
</pre>
</pre>
Configure the path to unoconv in the Moodle admin settings to point to this wrapper script.
Configure the path to unoconv in the Moodle admin settings to point to this wrapper script.
==Additional resources==
==Additional resources==
[https://github.com/dagwieers/unoconv GitHub dagwieers/unoconv] has additional information on installation of unoconv and troubleshooting tips.
[https://github.com/dagwieers/unoconv GitHub dagwieers/unoconv] has additional information on installation of unoconv and troubleshooting tips.
==Troubleshooting==
==Troubleshooting==
* [http://webnetkit.com/soffice-bin-using-100-cpu-moodle/ soffice.bin using 100% of CPU MOODLE]
* [http://webnetkit.com/soffice-bin-using-100-cpu-moodle/ soffice.bin using 100% of CPU MOODLE]
==See also==
==See also==
* [https://moodle.org/mod/forum/discuss.php?d=335310 Is the unoconv installation a security risk?] forum discussion
* [https://moodle.org/mod/forum/discuss.php?d=335310 Is the unoconv installation a security risk?] forum discussion
[[Category:Site administration]]
[[Category:Site administration]]
[[Category:Assignment]]
[[Category:Assignment]]
[[es:Universal Office Converter (unoconv)]]
[[es:Universal Office Converter (unoconv)]]
[[de:Universal Office Konverter]]
[[de:Universal Office Konverter]]
[[fr:Universal Office Converter]]
[[fr:Universal Office Converter]]

Latest revision as of 20:02, 18 April 2023

What is unoconv?

"unoconv" is a command line program that is used to convert between different office document file formats. It uses an instance of LibreOffice to do the conversion and is used by the Assignment activity to convert documents to pdf so that they can be annotated. If unoconv is not installed - the only impact is that the assignment activities will only allow annotations when students upload a pdf document.

The steps required to install unoconv are different depending on the operating system that you have installed Moodle on.

Installing unoconv on Linux

The required version of unoconv is at least 0.7. Depending on your flavour of linux, this may be available in your package manager and you can install it directly with:

Ubuntu 22.04 LTS

You will need to install Python 3, and note that the unoconv will only support Python up to 3.11.

sudo apt install python3

To download the latest version of unoconv (0.8.2):

cd /opt
sudo git clone https://github.com/unoconv/unoconv.git
sudo nano /opt/unoconv/unoconv

Change the first line of code by adding the number 3 to the Python version, as per the example below:

#!/usr/bin/env python3

Permissions and run link:

sudo chmod ugo+x /opt/unoconv/unoconv
sudo ln -s /opt/unoconv/unoconv /usr/bin/

Now we need LibreOffice installed:

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt install libreoffice -y

Production servers should consider running unoconv in listener mode, see Installing unoconv#Run a unoconv listener or follow directions below:

sudo nano /etc/systemd/system/unoconv.service

And then copy and paste the following configuration into it:

[Unit]
Description=Unoconv listener for document conversions
Documentation=https://github.com/dagwieers/unoconv
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
ExecStart=/usr/bin/unoconv --listener

[Install]
WantedBy=multi-user.target

And then enable and start the above service:

sudo systemctl enable unoconv.service
sudo systemctl start unoconv.service

Ubuntu 18.04 LTS

apt-get install unoconv
mkdir /var/www/.config
chown www-data:www-data /var/www/.config

Ubuntu 16.04 LTS

apt-get install unoconv

If your package manager contains an older version of the package, you will have to find a newer version and install it manually (Debian Testing). Unoconv itself is just a python script, so it has few dependencies.

Potential problems:

  • On some systems the apache user home directory is set to a non existent folder. This can cause unoconv to fail. There are 2 solutions to this - one is to make a (writable) home directory for the apache user (like /home/www-data). The other is to run a unoconv listener (described below) as another user other than the apache user (someone with a valid, writable home directory).
  • If you are still running 14.04LTS then unoconv won't work as shipped. This might not be the most efficient route but it worked by first installing unoconv (version 0.6) from the package manager as above. You will then need to grab unoconv 0.7 from Github (https://github.com/dagwieers/unoconv), then upgrade to the latest libreoffice using the PPA (https://launchpad.net/~libreoffice/+archive/ubuntu/ppa). Point moodle at the Github version of unoconv. You need to modify the Python unoconv file by changing 'python' in the first line to 'python3'. You also need to change the permissions on the directory /var/www so that the user www-data can write to it (www-data needs to write to its home directory which it cannot do by default).

On Debian Stable, the cleanest method to install unoconv is using Jessie-backports. First, enable backports repo line in /etc/apt/sources.list:

#### Jessie-backports  ####
deb http://ftp.debian.org/debian jessie-backports main

Then, update and install unoconv from jessie-backports:

apt-get update
apt-get install -t jessie-backports unoconv

The package will bring all necessary dependencies for you.

Ubuntu 14.04 LTS

1) Navigate to opt directory

cd /opt

2) Download unoconv

sudo wget https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv

3) Modify the Python unoconv file by changing 'python' in the first line to 'python3'

sudo nano /opt/unoconv


e.g.

#!/usr/bin/env python3

4) Make unoconv executable

sudo chmod ugo+x /opt/unoconv

5) Add LibreOffice PPA to your system and install the latest version

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice

6) Change permissions so apache can write to its home directory

sudo chown www-data /var/www

7) From your browser navigate to Site administration > Server > System paths and add the path to unoconv
/opt/unoconv

  • Note: if you would like to preserve the default path add a symbolic link to /usr/bin:
sudo ln -s /opt/unoconv /usr/bin/

8) Navigate to Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF > Test unoconv path
You should see:
"The unoconv path appears to be properly configured."

  • Download the converted pdf test file. (if the PDF fails to load ensure that www-data can write to its home directory: /var/www)

CentOS / RedHat

Just before you start, you might like to consider installing the latest LibreOffice 6.3.2 directly from RPM packages, that are not part of the distribution you are using. As of nov-2016, CentOS and RedHat 7.2 comes with OpenOffice 4.3 . so if you are not interested in using this version and would like to install latest 6.3 independent LibreOffice 6.3, please remove any openoffice packages you might have on your OS by issuing:

yum remove openoffice* libreoffice*

It is recommended to chose your localized libreoffice version for better document conversions.

yum install libreoffice libreoffice-pyuno
git clone https://github.com/dagwieers/unoconv.git
# copy 
cp unoconv/unoconv /usr/bin
# or link unoconv to /usr/bin
ln -s unoconv/unoconv /usr/bin/unoconv
Note: depends on what version you are installing, openoffice or libreoffice, make sure you installed the *-pyuno package. (the headless package is already compiled into the core)

Make sure it is properly configured: http://your-moodle/admin/search.php?query=unoconv

Production servers should consider running unoconv in listener mode, see Installing unoconv#Run a unoconv listener or follow directions bellow

vi /etc/systemd/system/unoconv.service

And then copy and paste the following configuration into it:

[Unit]
Description=Unoconv listener for document conversions
Documentation=https://github.com/dagwieers/unoconv
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
Environment="UNO_PATH=/usr/lib64/libreoffice/program"
ExecStart=/usr/bin/unoconv --listener

[Install]
WantedBy=multi-user.target

And then enable and start the above service

systemctl enable unoconv.service
systemctl start unoconv.service

If your selinux is enable yous should set

#setsebool -P httpd_execmem on

Installing unoconv on OS X

Download and install LibreOffice for Mac. Unfortunately - newer versions of LibreOffice are not currently compatible with unoconv for mac and you will have to install LibreOffice 4.2 (Direct download link - https://downloadarchive.documentfoundation.org/libreoffice/old/4.2.5.2/mac/x86_64/LibreOffice_4.2.5.2_MacOS_x86-64.dmg).

Get the latest version of the unoconv python script. One way to do this is with http://brew.sh/ brew.

brew install unoconv

If you haven't done it already - install ghostscript. One way to install ghostscript is also with http://brew.sh/ brew

brew install ghostscript

Set the paths to unoconv and ghostscript in Moodle (Site administration > Server > System paths). If you used brew, they will both be installed to /usr/local/bin.

LibreOffice needs write access to the current users home directory to create some temporary files. When unoconv is run as the webserver user (_www) it does not normally have this permission.

There are some ways to get around this - one way is just to give the "_www" user write access to /Library/WebServer.

Another solution is to convince LibreOffice that this users home directory is somewhere else. This can be done by inserting this code into the top of the unoconv python script. Code to insert:

# Set home to a writable folder. 
os.environ['HOME'] = '/tmp/'                                                                                                        

This needs to be inserted at line 36 immediately after the line "exitcode = 0"

Installing unoconv on Windows

Download and install LibreOffice for Windows. Open Office will work just as well, but the documentation for unonconv is set to Libre Office.

Download the latest version of the unoconv script from https://github.com/dagwieers/unoconv/releases (download the zip version).

From the downloaded zip file - extract the one file unoconv-0.7\unoconv (no file extension). This is the unoconv script - none of the other files in the package are required.

Rename the downloaded script to unoconv.py and copy it to a folder in either C:\Program Files or C:\Program Files (x86).

Create a batch file in the same folder as unoconv.py name it something like unoconv.bat, it must be a batch file, with these contents:

@"C:\Program Files\LibreOffice\program\python.exe" c:\unoconv\unoconv.py %*

or:

@"C:\Program Files\OpenOffice\program\python.exe" c:\unoconv\unoconv.py %*

Next, you have to Set paths in Moodle.

Login as admin and go to Site administration > Server > System paths

Set: Path to Ghostscript (pathtogs) to C:\Program Files\gs\gsversion\bin\gswin64c.exe. Do not use gswin32.exe or gswin64.exe, these are not command line programs - use gswin32c.exe or gswin64c.exe.

Set: Path to Python (pathtopython) to C:\Program Files (x86)\OpenOffice\program\python.exe or C:\Program Files (x86)\LibreOffice\program\python.exe. Identify in the path whichever program you use and include the full exe name for both Ghostscript and Python.

Save the pathto statements and a green tick should appear if Moodle is communicating with the required files.

Go to Site administration > Plugins > Document converters and enable Unoconv then select Settings

Enter the path statement to Path to unoconv document converter: C:\Program Files (x86)\unoconv\unoconv.bat. Include the full name of the .bat file.

Test ghostscript and unoconv are working correctly in the admin test pages Site administration > Plugins > Activity modules > Assignment > Feedback plugins > Annotate PDF.

Run a unoconv listener

Unoconv utilises a client/server process when converting documents. By default, when there is no running server process - each time unoconv runs it will start a server process, send its request and shut down the server process when the request is complete. The drawback of this mode is that if 2 requests are submitted simultaneously - this can cause the first request to shutdown the server process when the second request is still in progress - and the second conversion request fails. A more robust way to configure unoconv is to start a server process at boot time, and/or run a script to monitor it and restart it if it crashes.

To start a unoconv listener at boot time - you need a start up script. Different operating systems and Linux distributions use different startup scripts - but here are some examples of startup scripts for different systems.

Upstart script for Ubuntu based systems

Launchd script for OS X

Init script for Debian

Init script for CentOS/RedHat 6.x

SystemD service script for CentOS/RedHat 7.x

Offload processing to a different server

Processing office documents can put increased load on your webserver, which may impact on the responsiveness of your site. If you are installing unoconv on a large site you may want to consider running unoconv on a server that is not also serving web requests.

How to do this:

Install unoconv on each webservers and the remote server following the installation instructions above.

Make sure unoconv is started at boot time on the remote server with the "--listener" argument and is monitored and restarted if it exits (see Debian init script for an example of how to do this). By default, unoconv will only listen on localhost (127.0.0.1): if you want to connect to the listener process from another server, you need to start the unoconv listener process with the "--server" argument too!

An example command for starting a listener on a remote server (0.0.0.0 listens on all interfaces):

unoconv --listener --server 0.0.0.0 --port 2002

Open the firewall port 2002 between the moodle webservers and the machine running unoconv.

Share the moodle data root between the webservers and the machine running unoconv. This folder must be mounted at the same path on all servers.

Install a wrapper for unoconv on the webservers that forwards the requests to the remote server. Example:

#!/bin/bash
# Wrapper script for unoconv to forward processing.
# Install to /usr/bin/unoconv-remote with 755 permissions
/usr/bin/unoconv --server=<ip of remote server> "$@"

Configure the path to unoconv in the Moodle admin settings to point to this wrapper script.

Additional resources

GitHub dagwieers/unoconv has additional information on installation of unoconv and troubleshooting tips.

Troubleshooting

See also