I recently had to come up with a solution for Word-to-PDF file conversions on a server that was running Railo (UPDATE: Works on Lucee as well). After much searching and combining of various articles that I read, I decided to put together a simple CFC to make this easier for others (and reusable for me). This CFC will convert any document format that can be opened with OpenOffice (including Word, Excel, Powerpoint) to PDF format. While it was written and tested for Railo 3.2, it will work on Lucee 4/5, ColdFusion 7 and 8. It may also work on BlueDragon, but I do not have an installation of that to test with. If you have ColdFusion 9, you don’t need this CFC – you already have built-in PDF conversion.
This currently only works for Windows servers. If anyone wants to help modify it for Linux-based servers please do so, and share the code here. I will put it in the download and credit you as well.
The pieces needed…
- OpenOffice 3.3 – OpenOffice must be installed on the server that Railo/Lucee (or your CFML engine) is running on.
- UPDATE 3/20/17 – This will also work with OpenOffice4, but you need to update the default executable path in oolib.cfc to point to the OpenOffice 4 folder (on line 7).
- JODconverter 2.2 – This is a Java library for interacting with the OpenOffice API. The JAR files for this need to be in your CFML engine’s classpath (there is more about this in the readme.txt included in the download below).
- oolib.cfc – This is the CFC that connects ColdFusion to JODconverter, and then to OpenOffice.
All of this is better explained in the download.
DOWNLOAD CODE AND SAMPLE FILES HERE
Note: I submitted this to RIAforge.org and should have it approved and available there soon as well.
Nice! Thanks for sharing.
great, thank you for sharing~
Hello, thank you for this article.
When trying to use the JODConverter with Railo I get the following error at this point:
cannot load class through its string name, because no definition for the class with the specified name [com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter] could be found caused by (java.lang.ClassNotFoundException:com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter not found by lucee.core [64];java.lang.ClassNotFoundException:com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;)
I copied the .jars that belong to JODconverter to C:\lucee\lib – do I have to do anything else?
Thank you for any help!
Best regards, Ruediger
(continuing from above)
The error occurs at this point within oolib.cfc:
cfobject type=”java” class=”com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter” name=”jodDocumentConverter”
@Ruediger did you restart Lucee after moving the files?