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.

4 comments:

  1. Hi,
    I have problem with registering iec16022sharp.dll.
    The message I get is:
    ........dll was loaded but the DllRegisterServer entry point was not found.

    If you have some time to help me with this I'll be grateful.

    Thank you for your time.
    Marin
    marin64[at]hotmail.com

    ReplyDelete
  2. Hi Marin,
    The simplest way is copying the dll to your executable folder. HTH.

    Alex Wijoyo

    ReplyDelete
  3. Dear Alex,
    I assume that I need to add a reference of dll in my project (Visial Studio 2002, Windows application).

    When I try to add a reference I’m getting the message:
    ….....a reference could not be added. This is not a valid assembly or COM component.

    When I try to register the dll file I’m getting:
    ........dll was loaded but the DllRegisterServer entry point was not found.

    Thanx a lot.
    Marin

    ReplyDelete
  4. bytes.com/topic/net/answers/548979-how-can-i-create-dll-c-net

    ReplyDelete