Barcode Xpress in Coldfusion
In the category of ‘things I wish I’d found when I was looking in Google’. This is a simple demo of integrating the Barcode XPress java SDK into ColdFusion, so that we can find and read DataMatrix barcodes. It loops through a list of image files found in the sub-directory ‘uploads’. Any CF-readable image will do. Uses the brilliant javaloader
<cfset pathArray = ArrayNew(1) />
<cfset pathArray[1] = expandPath("tasbar5.jar") />
<cfset loader = createObject("component", "javaloader.JavaLoader").init(pathArray) />
<cfset uploads = ExpandPath("uploads") />
<cfdirectory action="list" directory="#uploads#" name="files" />
<cfdump var="#files#" expand="false" />
<cfoutput query="files">
<p>#name#</p><hr />
<cfset start = GetTickCount() />
<cfimage name="scan" source="uploads/#name#" action="read" />
<cfset BarReader = loader.create("tasman.bars.BarReader").init(ImageGetBufferedImage(scan)) />
<cfset ReadOptions = loader.create("tasman.bars.ReadOptions").init() />
<cfset ReadOptions.codeDataMatrix = true />
<cfset barCodes = BarReader.readBars(ReadOptions) />
<cfloop from="1" to="#ArrayLen(barCodes)#" index="i">
<cfset bc = barCodes[i] />
<cfdump var="#bc.toString()#" />
</cfloop>
<br />Detection complete in #GetTickCount() - start#ms
</cfoutput>
Simon Harper
Please wait - comments are loading

Loading…

