Add new font for cfdocument

May be this jars won’t be loaded because of not being OSGI compliant? You can try creating the OSGI Manifest/Metadata (what I’ve never done) or try using Mark Mandels Javaloader, a very valuable tip that I’ve learnt from @Julian_Halliwell1. If this works for you, do the following:

  1. Go to Mark Mandels Github Javaloader Repository and download the Javaloader (this is the javaloader-folder in his repository) to your webroot:

  2. Create a folder in your webroot named lib, and add the jars to the lib directory (in this case I’ve added the barcode image processing library ZXING core-3.4.0.jar and javase-3.4.0.jar)

  3. create cfm file barcode128.cfm with the following content:

filePaths = ArrayNew(1);
filePaths[1] = expandPath("lib\core-3.4.0.jar");
filePaths[2] = expandPath("lib\javase-3.4.0.jar");
//Creating a java loader object by passing in the array containing the file paths –
loaderObj =createObject("component","Javaloader.JavaLoader").init(filePaths);

format 	= loaderObj.create("");
writer 	= loaderObj.create("");
matrix 	= loaderObj.create("");


<cfset output="My Barcode">
<cfset barcode=writer.encode(output,format.CODE_128,75,75)>
<cfset image=ImageNew(matrix.toBufferedImage(barcode))>

Here you have a working example in zip-file, I’ve uploaded this also to keep it documented for myself: (575.5 KB)

1 Like