Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating QR Code with Coldfusion

Has anyone gotten the "Open Source QR Code Library" to work with ColdFusion? I need to generate QR Codes in ColdFusion.

I also found this tutorial on how to generate it using Zxing.

But the tutorial is not clear on how to configure the files, e.g. what needs to be in which dir...

Any help and alternatives are welcomed, thanks.

like image 300
n_kips Avatar asked Nov 15 '10 02:11

n_kips


3 Answers

Zxing uses two (2) jars: core.jar and javase.jar. The easiest way to install them is to place both jars anywhere in the CF classpath (example: C:\ColdFusion8\wwwroot\web-inf\lib). Then restart the CF server. That is it.

Note: You can either compile the zxing jars yourself or download a slightly older version from this handy entry on blog.getRailo.com) Update: The barcode_samples.zip file does contain sample CF code. But it is for Railo only. Adobe CF does not support the extra parameters for createObject("java"). To use the code in Adobe CF, you need to remove the extra parameters.

<!--- Railo syntax --->
<cfset object = createObject('java','path.to.classtoinvoke','/path/to/jar/file/on/system')>
<!--- Adobe CF --->
<cfset object = createObject('java','path.to.classtoinvoke')>

If you do not have access to the classpath, you can use the JavaLoader.cfc to load the two (2) zxing jars instead. Just download the project. It includes some pretty good examples on installation and usage. But if you have further questions, let me know.

like image 87
Leigh Avatar answered Nov 03 '22 06:11

Leigh


Essentially wrap the google API.

Here is the core of the code:

<cfhttp method="Get" url="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=#url.text#" getAsBinary = "yes">

Click here to see my blog post for further detail

like image 3
Richard Hughes Avatar answered Nov 03 '22 05:11

Richard Hughes


I created a ColdFusion / jQuery QR code generator on my web site. Basically, you just send the info you want to convert in a URL string to Google. They create and host the image.

You can check it out on my site at http://www.EvikJames.com/?StackOverflow It's in the jQuery examples section, "Ajax QR Code Generator"

You can use the code below to see how I did it.

$(document).ready(function() {

$("#TextBox").keyup(updateImage);
$("#ImageSize").change(updateImage);

function updateImage() {
    var Message = $(this).attr("value");
    var ImageSize = $("#ImageSize").attr("value");
    $("#ResultImage").animate({ height: ImageSize, width: ImageSize}, 500);
    ImageSize = ImageSize + 'x' + ImageSize;
    MyURL = "https://chart.googleapis.com/chart?chs=" + ImageSize +  "&cht=qr&chl=" + Message;
    $("#ResultImage").attr("src", MyURL);
}

});
like image 1
Evik James Avatar answered Nov 03 '22 06:11

Evik James