With a little side of applesauce...

Monday, August 18, 2008

coldfusion / jodconverter example

Here is a working example of using Coldfusion to interact with the cool jodconverter:

<cfobject type="java" class="com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter" name="jodDocumentConverter">
<cfobject type="java" class="com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection" name="jodOpenOfficeConnection">
<cfobject type="java" class="java.io.File" name="jodFile">

<cfset inputFile = jodFile.init("/path/to/document.odt")>
<cfset outputFile = jodFile.init("/tmp/document.pdf")>

<cfset jodOpenOfficeConnection.init("localhost", 8100)>
<cfset jodOpenOfficeConnection.connect()>
<cfset success = jodOpenOfficeConnection.isConnected()>

<cfif success EQ "YES">
<cfset jodDocumentConverter.init(jodOpenOfficeConnection)>
<cfset jodDocumentConverter.convert(inputFile, outputFile)>

<cfset disconn = jodOpenOfficeConnection.disconnect()>

I downloaded the zip, pulled the jar files out of it and put them in my Coldfusion Classpath. Easy-peasy :)


Darin Kadrioski said...

Perfect! Just what I was looking for.

Heath Stein said...

Thank You!!! Worked great on Railo