bsdpower.com

Getting unoconv to work on Debian Squeeze

Today I looked into options for converting msoffice documents to something more usable. There are several programs for this sort of conversion nowadays, with unoconv being advertised as a relatively lighter choice.

To get it running on Debian Squeeze I had to do some research. The biggest issue to figure out was the necessity to install Writer component of LibreOffice separately, as Debian splits programs into multiple packages.

OpenOffice or LibreOffice?

Squeeze ships with OpenOffice. Newer versions of Debian have LibreOffice, and LibreOffice is also available in squeeze-backports repository. While trying to troubleshoot the installation I switched to LibreOffice from backports, therefore that is what I will use in the following instructions.

Install LibreOffice

Since I am going with LibreOffice, I will install it in its own step.

apt-get install -t squeeze-backports libreoffice-core libreoffice-writer

For excel file conversion, you will need libreoffice-calc.

The core package is a dependency of unoconv. The important part is also including one of the actual LibreOffice programs, like libreoffice-writer above. Those are not required by unoconv but not having any programs installed will produce the following error when attempting a conversion:

% unoconv -f pdf example1.odt 
unoconv: UnoException during conversion: Unsupported URL <file:///home/sandbox/example1.odt>: ""
The provided document cannot be converted to the desired format.

Install LibreOffice Python bindings

These must be installed from the same source that LibreOffice was installed from, in my case squeeze-backports:

apt-get install -t squeeze-backports python-uno

Install Java

unoconv requires libreoffice-java-common package and a JRE. Despite libreoffice-java-common bringing in some gij packages, they do not count for a JRE.

I chose to go with openjdk-6-jre.

apt-get install openjdk-6-jre
apt-get install -t squeeze-backports libreoffice-java-common

LibreOffice listener

unoconv requires a LibreOffice listener to be running. unoconv can launch it on demand, or you can launch it yourself.

To launch manually run:

unoconv --listener

Important thing to remember if manually launching the listener: the running listener is not affected by package installations and deinstallations. For example, if you launched the listener when libreoffice-writer was not installed, then you instaled libreoffice-writer, and subsequently you are trying to run unoconv, unoconv will use the runnning listener which has no knowledge of Writer and conversion will fail. Make sure to kill/restart listeners after installing or deinstalling LibreOffice components.

Done

With all of the above done unoconv should work:

unoconv -f pdf example1.odt

Other options