Turning OpenOffice.org into a document conversion tool

One of the less well-known features of OpenOffice.org is its ability to run as a service. You can put that ability to some clever use. For example, you can turn OpenOffice.og into a conversion engine and use it to convert documents from one format to another via a web-based interface or a command-line tool. JODConverter can help you to unleash OpenOffice.org’s file conversion capabilities.

To be able to use OpenOffice.org as a conversion engine, you have to start it as a service. This means launching it without its GUI and making it listen for incoming connections on a particular port. To do this, launch OpenOffice.org using the following command on Linux:

soffice -headless -accept="socket,port=8100;urp;"

On Windows, use this command:

"C:\Program Files\OpenOffice.org 2.2\program\soffice" -accept="socket,port=8100;urp;"

Since JODConverter is Java-based, you have to make sure that the Java runtime environment version 1.4 or higher is installed on your machine. Download the latest version of the jodconverter-tomcat-x.x.x.zip package and extract it into your home directory. You can then launch the JODConverter using the start.sh script (start.bat on Windows) in the bin directory:

sh jodconverter-tomcat-2.1.1/bin/startup.sh

On Ubuntu, you may get an error message telling you that the JAVA_HOME variable is not set. To fix this problem, locate your Java Runtime Environment using the locate /rt.jar command, and then set the variable as follows (using the directory the locate command reports):

export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.11

To avoid doing this manually every time you run JODConverter, add the above command to your /home/user/.bashrc file, or to the /etc/bash.bashrc file, if you want to add it for all users.

Now, point your browser to http://localhost:8080/converter and you should see a simple web interface. Pick the file you want to convert, select the target format, and press the Convert! button.

The above description assumes that you are running OpenOffice.org and JODConverter on the same machine. However, it’s possible to configure JODConverter to connect to OpenOffice.org running as a service on another machine. The Art of Solving website provides a description of how to go about it.

Converting documents from the command line is equally easy. Download the latest jodconverter-x.x.x.zip package and extract it into your home directory. Make sure that OpenOffice.org is running as a service, and use the java -jar lib/jodconverter-2.1.1.jar command to convert documents. For example:

java -jar jodconverter-2.1.1/lib/jodconverter-2.1.1.jar loremipsum.odt loremipsum.pdf

That’s all there is to it. The created document conversion tool is ideal for converting files that come from any computer without OpenOffice.org running on it.

Originally published at Linux.com. Updated and revised.

Related articles:

PageDateUserTags
Better writing with OpenOffice.org and Writer's Tools 2008/03/18 12:24 Dmitri Popov
Create high-quality maps with OOoHG 2007/07/15 18:20 Dmitri Popov , ,
Creating OpenOffice.org extensions the easy way with BasicAddonBuilder 2008/02/26 14:06 Dmitri Popov
Creating an e-wallet with Base 2007/08/16 00:27 Dmitri Popov , , ,
Creating interactive forms with OpenOfice.org Writer 2007/09/07 09:51 Dmitri Popov ,
Digitally sign OpenOffice.org documents 2007/08/16 00:29 Dmitri Popov , ,
Inserting special symbols and characters into OpenOffice.org Writer documents 2008/06/16 16:29 Dmitri Popov
OpenOffice.org Base primer 2007/09/23 13:02 Dmitri Popov , ,
OpenOffice.org Basic code snippet: Insert annotation 2008/06/27 11:31 Dmitri Popov , ,
OpenOffice.org banners and logos 2008/07/04 11:32 Dmitri Popov
Pepping up OOo Writer documents with sparklines 2007/09/07 12:46 Dmitri Popov ,
Scheduling OpenOffice.org Basic macros 2008/03/20 23:54 Dmitri Popov
Scribus for OpenOffice.org users 2007/11/04 17:05 Dmitri Popov , ,
Translate words with EuroOffice Dictionary extension 2008/06/16 01:10 Dmitri Popov , ,
Turning OpenOffice.org into a document conversion tool 2008/01/03 15:09 Dmitri Popov
WNotes: Creating a Writer/MySQL web application 2007/09/20 17:25 Dmitri Popov , ,

AddThis Social Bookmark Button

 
articles/oooconvert.txt · Last modified: 2008/06/01 16:16 (external edit)
 
OpenOffice.org user? Read the Writer for Writers and Advanced Users book
GNU FDL OpenOffice.org Powered by DokuWiki