Showing posts with label datamatrix. Show all posts
Showing posts with label datamatrix. Show all posts

Saturday, September 12, 2009

Generate DataMatrix Barcode from Your .NET Application

Data Matrix barcode has several advantages over 1D barcodes such as:
  • Contains more character even alphanumeric.
  • Has square form for easier layout on printout.
  • Digital camera friendly even using your old cellphone camera.
  • Redundant information, you can scan 75% area of the barcode only for scanning.
  • A little bit omni scan direction.
Too bad my trusted DevExpress XtraReport XRBarcode doesn't have this symbology. Since I can't wait for DevExpress to implement Data Matrix so I decided to find open source solutions. Thanks God, I found external link on Data Matrix Wiki page for iec16022sharp an open source .NET Data Matrix generator library. Since I use VB.NET, I built the iec16022sharp assembly and use it by adding a reference to it. I am glad that iec16022sharp usage is very easy.
Here is my iec16022sharp usage snippet:
...
Imports IEC16022Sharp
...
Dim aReport As New RptBarcode
Dim aDataMatrix As New DataMatrix(BindSrcMaster.GetDataValue("BarcodeNum").ToString.Trim)

HierarchyRefreshDataRow(BindSrcMaster.GetDataRow)
With aReport
.CallingForm = Me
.PbDataMatrix.Image = DMImgUtility.SimpleResizeBmp(aDataMatrix.Image, 6, 0)
.QueryLoad(Application.StartupPath + "\CustomReport\Barcode.xml", BindSrcMaster)
.ShowPreview()
End With
...

The only functions I called from this library is a DataMatrix constructor and a static function DMImgUtility.SimpleResizeBmp. From the DataMatrix constructor I already have a small DataMatrix barcode. For enlarging the generated DataMatrix I just called the SimpleResizeBmp for enlarging it six times with zero pixel border. Hope my post give you an idea on using DataMatrix. Thank you.
...Read more