Sunday, December 2, 2007

How to determine the version of iText

I ran into a problem converting one of the iText examples. While I suspected it might be a version problem with CF's built in iText.jar, I did not know how to check the version number. Enter this tip from Paulo Soares to the rescue.

Here is the cfscript I used. (Note:  ColdFusion uses an earlier branch of iText. As of iText 5.0.0 the package names were changed. So if you are running iText 5.x, use com.itextpdf.text.Document , instead of com.lowagie.text.Document )

<cfscript>
   document = createObject("java", "com.lowagie.text.Document").init();
   WriteOutput("iText Version = "& document.getVersion());  
   document.close();
</cfscript>


The results from MX7, CF8 and CF 9.0.1 were
(CF8) iText Version = iText 1.4 (by lowagie.com)
(MX7) iText Version = iText by lowagie.com (r1.02b;p128)
(CF9.0.1) iText Version = iText 2.1.0 (by lowagie.com) 



Update The iText FAQ's mention a second method for determining the iText version. Open a PDF generated by iText and check File -> Document Properties. The PDF Producer value will display the product used to produce the file.

Interestingly I noticed the PDF Producer value seemed to blank in some cases. Usually for files I created with CF8's <cfpdf action="merge" ..> I do not know if this applies to all files created with action="merge", but it was surprising to me. I would have expected the Producer value to be "iText 1.4 (by lowagie.com)" because that is the CF8 library used to create the final merged PDF file. But apparently not.

0 comments:

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Header image adapted from atomicjeep