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.
Note: I submitted this to RIAforge.org and should have it approved and available there soon as well.