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:

Better writing with OpenOffice.org and Writer's Tools    
Create ODF documents without OpenOffice.org 2009/03/14 16:24 Dmitri Popov
Create high-quality maps with OOoHG    
Creating OpenOffice.org extensions the easy way with BasicAddonBuilder    
Creating an e-wallet with Base    
Creating interactive forms with OpenOfice.org Writer    
Digitally sign OpenOffice.org documents    
Getting the most out of OpenOffice.org Writer 2009/06/24 22:08 Dmitri Popov
OpenOffice.org Base primer    
Pepping up OOo Writer documents with sparklines    
Scheduling OpenOffice.org Basic macros    
Scribus for OpenOffice.org users    
Turning OpenOffice.org into a document conversion tool    
WNotes: Creating a Writer/MySQL web application    

AddThis Social Bookmark Button

 
articles/oooconvert.txt · Last modified: 2010/03/10 19:45 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Need high-quality compatible Avery labels? Get them at WorldLabel.
Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki