views:

409

answers:

3

We are using ColdFusion MX7.

The CFDOCUMENT tag uses iText for the PDF creation so the whole of the iText library is included in the standard CF deployment.

The problem I'm having is that I want to use a version of iText that is newer than the one included in CF7. I need to keep CFDOCUMENT functioning, so simply changing the jar file is not an option.

What I have done so far is to load the iText source into Eclipse and refactor it to a different name. That works fine and has been doing so for about a year.

However, I would like to upgraded to the newest iText release, and jumping through the hoops of refactoring again is a bit daunting.

Is there an easier way to load the jars and not have them conflict with the old version?

+5  A: 

One option is to use the JavaLoader.cfc to load a newer version of the jar. Since it uses an external classloader it can be used without disturbing the existing version.

http://www.transfer-orm.com/?action=javaloader.index

http://javaloader.riaforge.org/

However, it would still require rewriting your createObject("java", "path.to.class") statements to use javaLoader.create("path.to.class") instead. But in the long run, that might be better than refactoring, because it would be easier to update the iText jar in the future.

Leigh
A: 

if what you want is the cf8 functionality of cfdocument, then there might be an easier way. remember that railo and openbd both have cfdocument functionality that is on par with cf8 and both are free engines. what you could do is download and install one of these engines onto the same server or a different one if desired. then write a webservice within railo or openbd that wraps the cfdocument functionality and returns the pdf to you.

it's not the prettiest solution, but neither is refactoring itext or hacking the itext version that came with cf.

rip747
+2  A: 

Itext just released v5.0.0 and one of the significant changes to it is that the Package Name has been changed from "com.lowagie" to "com.itextpdf" allowing you to co-exist.

Simply download the new iText.jar file and rename to "iTextpdf.jar" and locate it in the proper LIB folder for CFMX.

When you do your createObject calls, simply use the new package name path.

JavaLoader is a great utility, but if you don't load it into server scope (the initial loader with paths to the iText jar) AND ensure it is only loaded ONCE, you can run into severe memory leak issues.

Using the latest refactoring of iText means you don't need to worry about it.

Michael Beveridge
Awesome! Thanks that is really going to help.
Tom Hubbard