currently I have a barcode font, but when I print as pdf with cfdocument the font is not change. In coldfusion we can add the font at font folder. How we do it in lucee?
I read in some forum, we can do it with updating the fonts.jar in /lucee/lib folder. But I cannot find it fonts.jar in that folder, anyone know about this ?
i have the same problem… i want to add barcode fonts to custom fonts… i’ve added the ttf files to fonts.jar and added font name in pd4fonts.properties
i have tried several times like below :
added fonts.jar in folder /srv/apps/lucee/lib/ ( folder lib that contains "lucee-5.X.X.XXX.jar), after that i cannot start my lucee in my vagrant… i have to delete this file then i can restart lucee successfully.
added fonts.jar in opt/lucee/lib folder (previously this folder doesn’t exist) and nothing happens
added Code39.ttf, code39u.ttf and IDAutomationHC39M.ttf in /srv/apps/lucee/jdk/jre/jre/lib/fonts/ folder (in this folder contains ttf font files). after that i cannot start my lucee properly until delete those files.
added fonts.jar in /srv/apps/lucee/tomcat/lucee-server/bundles/ folder (in this folder contains a lot of jars, so i think i can include fonts.jar in this folder), but still doesn’t work…
Finally, i tried to add fonts.jar in WEB-INF/lucee/lib/ folder in my vagrant installation and fonts.jar was loaded in WEB-INF/lucee/logs/application.log… but still i cannot use custom fonts…
is there any way that i missed, using wrong method, placing fonts.jar in wrong folder, or anything? i’m really confused why it still won’t show…
it still won’t work… i also try to show it in cfm, not in cfdocument but also doesn’t work… is there anyone have a clue what is wrong with it? i really need to use custom fonts and it kinda frustating that it won’t work at all…
I just had a long custom font loading fight with lucee too. We’re deployed on PaaS, so we can’t touch the fonts.jar file, or any of the java folders or libraries.
What we needed to do is pass the java launch some JAVA_OPTS. Here’s the JAVA_OPTS we used…
You will need to find where/how you pass in arguments to java when it launches your Tomcat (or whatever J2EE server you are running).
(The more I think about it, the more I think that JAVA_OPTS is just the method that Azure uses. You will probably want to search for adding java arguments to the command line)
i have been enjoying doing CFML for the first time in 15 years working on a PoC over lockdown and i tried your code above but i get the below error -
com/google/zxing/common/BitMatrix
The error occurred in D:\wwwroot\cps.cp3.luceeplanet.com\httpdocs\cfqr\index.cfm: line 6
4: <cfset output="My Barcode">
5: <cfset barcode=writer.encode(output,format.CODE_128,75,75)>
6: <cfset image=ImageNew(matrix.toBufferedImage(barcode))>
7: <cfoutput>#image#</cfoutput>
I have seen this code in a number of places and i have tested it multiple times, but i get the same error. I have put the core & j2se 3.4 Jar files in the lucee/lib/ directory. Lucee can see it loaded … i am just a bit stumped … is there anything else i need to do … ?
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:
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)
create cfm file barcode128.cfm with the following content:
<cfscript>
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("com.google.zxing.BarcodeFormat");
writer = loaderObj.create("com.google.zxing.oned.Code128Writer");
matrix = loaderObj.create("com.google.zxing.client.j2se.MatrixToImageWriter");
</cfscript>
<cfset output="My Barcode">
<cfset barcode=writer.encode(output,format.CODE_128,75,75)>
<cfset image=ImageNew(matrix.toBufferedImage(barcode))>
<cfoutput>#image#</cfoutput>
Here you have a working example in zip-file, I’ve uploaded this also to keep it documented for myself: barcode128Javaloader.zip (575.5 KB)