Shaun Mccran

My digital playground

30
J
A
N
2011

QRcfc released on RIAforge.org

I've released the first version of a ColdFusion QR barcode generator on http://qrcfc.riaforge.org/.

It is a CFC based wrapper for the Google ZXing barcode Java library http://code.google.com/p/zxing/.

There is a demo here: ColdFusion QR barcode generator

This demo above is a form that allows you to pick a format and post the required data to 'qr.cfc'. qr.cfc then uses the javaloader library (http://javaloader.riaforge.org/) to load in two jar files that translate the argument strings into a bitmatrix, which you can output as a QR image.

It requires at least a JVM of 1.5 to be running, the demo above does work, but I've discovered that this server is running 1.4, I have a service request 'in' to have it updated to 1.6

Also the svn release uses cfimage to create the output image, if you are running ColdFusion server 7 or below this won't work (cfimage was introduced in ColdFusion 8) so you'll need to do something like this:

view plain print about
1<cfset buff = converter.toBufferedImage( bitMatrix ) />
2<!--- convert it to a CF compatible image --->
3<!--- CF 8 version <cfset createdImage = ImageNew( buff ) />--->
4
5<cfset strPath = ExpandPath( "./" ) />
6<cfset strPath = strPath & 'images\'>
7
8<cfscript>
9    saveToFile = strPath & 'myBarcode.png';
10    ImageIO = createObject("java", "javax.imageio.ImageIO");
11    outStream = createObject("java", "java.io.FileOutputStream").init(saveToFile);
12
13    // formats ie "png", "gif", ....
14
    wasWritten = ImageIO.write( buff, "png", outStream);
15    outStream.close();
16
17    createdImage = 'images/myBarcode.png';
18
</cfscript>

QR data formats

The biggest hurdle with this project is the format of each of the QR types. Most of them are different in some way. This is why there is a series of functions in the CFC. As it is an open platform it seems to have developed organically, so the format for an email is different from a vcard, for example.

Thanks to...

http://matez.de/qr_codes/?show=MEBKM and http://www.qr-barcodes.com/data-formats/ - for string format examples.

Also thanks to Leigh of http://cfsearching.blogspot.com who was a great help with cfimage issues and it was his blog articles that inspired me to look into this.

TweetBacks
Comments
tschilbi's Gravatar The demo code does not produce real results..only http://www.play.com!
# Posted By tschilbi | 26/07/11 04:52
Shaun McCran's Gravatar Good spot!

I was playing with some Java.io file writing stuff and I'd left it in there, it all works again now.
# Posted By Shaun McCran | 26/07/11 06:51
Back to top