Creating QR Code with Coldfusion
Asked Answered
B

3

9

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.

Barbarian answered 15/11, 2010 at 2:55 Comment(0)
Z
11

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.

Zoubek answered 15/11, 2010 at 4:2 Comment(3)
Thanks for the info. I pasted the two files in web-ini\lib and this is what I get when I run the Zxing's index.cfm ERROR: Unable to generate barcode The java object type is unknown for the CreateObject function. Any Ideas?Barbarian
@Barbarian - The code samples are for Railo only. If you are running ACF you need to make some adjustments. Please see my updated comments above.Zoubek
@marc esher the code was the un-tempered barcode_samples.zip & Leigh got to the bottom of it.Barbarian
C
4

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

Clump answered 16/5, 2013 at 19:28 Comment(0)
S
1

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);
}

});
Shush answered 26/8, 2011 at 13:35 Comment(2)
+1 Yep. Google charts provides a simple interface to the zxing library. It can be a nice alternative for applications that do not need to keep the processing internal only.Zoubek
An you benefit from Google covering the bandwidthEmmalynn

© 2022 - 2024 — McMap. All rights reserved.