5

Is there any way with pure ColdFusion/cfscript to produce a QR code, without relying on external APIs or JavaScript?

ale
  • 6,369
  • 7
  • 55
  • 65
Computerman1597
  • 214
  • 3
  • 10
  • I want to clarify that by external, i mean something hosted somewhere other than my own site, like using google charts api. – Computerman1597 Apr 09 '12 at 16:41
  • As long as you can install jars and use `createObject("java")` any of the components/libraries mentioned below should work. (Except barbecue, which does not support QR code) – Leigh Apr 09 '12 at 16:51

4 Answers4

7

No. ColdFusion cannot generate bar codes by itself. You need a separate tool or library. It is easy enough to install a java library, like ZXing. Then generate the images from CF. Alternately, you could do a <cfhttp> call to an external server that generates the bar code image for you, or basically do the same thing with javascript. You would not need to install anything for the latter two (2) options. But they still rely on an external resource.

Bottom line you need something more than just ColdFusion. What is the reason you cannot use either an external API or javascript? Because without either of those, you are probably out of luck.

Edit based on comments:

If the only restriction is the images must generated locally, then you can use ZXing as described in the link above -OR- any of the other components/libraries mentioned in the other responses, like Joe's suggestion which uses iText (though also based on ZXing).

Community
  • 1
  • 1
Leigh
  • 28,765
  • 10
  • 55
  • 103
  • 1
    Down voter, please leave a comment as to why. The answer is accurate. If there is some hidden CF feature I am missing, I would love to hear it. – Leigh Apr 09 '12 at 02:58
2

Some other external APIs

http://cfbarbecue.riaforge.org/

http://zanstra.com/my/Barcode.html?barcode=3PTSP8827A231

JS Mitrah
  • 686
  • 5
  • 12
  • The second option is a neat way to generate 1D bar codes with just javascript/css. But unfortunately neither it or barbecue support QR codes. – Leigh Apr 09 '12 at 16:37
1

Tim Cunningham wrote a library that is hosted on Github that utilizes iText that does just this very thing. https://github.com/boltz/QRToad

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
  • Nice idea, but it does require installing a newer version of iText (also a new license). So I assume it too falls into the "external library" category. But for my $0.02, it looks like a great project :) – Leigh Apr 07 '12 at 23:12
1

If you really wanted to, you could look up (perhaps you need to buy?) the encoding standard for QR codes, which I believe is an ISO standard. Then you could write a program which would output a table with the appropriate number of rows and columns, each with either a black or a white background. I wouldn't recommend this form of "rolling your own" though; it's a lot of work to do essentially what's been done before.

Matt Gutting
  • 284
  • 3
  • 10
  • +1 Agreed. It it would be a great learning experience. But with so many existing tools available, the amount of development and testing time it would involve is much better spent on other things. – Leigh Apr 09 '12 at 16:44
  • Indeed, unless there's some overriding reason to do that in a very specific case. I can't think of any such thing, though. – Matt Gutting Apr 09 '12 at 17:18
  • Actually they just updated their requirements to say the only restriction was that it must be done locally. (Thank goodness) – Leigh Apr 09 '12 at 17:21