To read barcodes

  1. Create BarcodeReader object

  2. Configure direction of barcodes (default horizontal, vertical and diagonal)

  3. Activate the required barcode type(s).   Setting Auto1D to 'true' reads the most common 1D barcodes.

  4. To read the barcode values directly

  5. OR To read barcode values in event handler

 

Example:  Reading PDF417 barcodes

 

private void ReadPdf417 (string filename, int page)

{

try

{

BarcodeReader reader = new BarcodeReader();

// for faster reading specify only required direction

reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true;

// specify type

reader.Pdf417 = true;

// read barcodes

Barcode[] barcodes = reader.Read (filename, page);

// process results

foreach (Barcode bc in barcodes)

{ProcessBarcode (bc);}

}

catch(Exception ex)

{

ProcessError (ex);

}

}

 

 

Example:  Reading 1D barcodes using event handler

 

// Event Handler

private void _OnBarcodeFound (object sender, BarcodeFoundEventArgs e)

{
ProcessBarcode (
e.Barcode);

// e.cancel = (e.Count == 3); // Cancel after 3 barcodes are found

}

 

private void ReadBarcodesWithEvents (string filename, int page)

{

try

{

BarcodeReader reader = new BarcodeReader();

// configure directions

reader.Horizontal = true; reader.Vertical = false; reader.Diagonal = false;

//configure types.  Select specific types for faster processing

reader.Auto1D = true;

// configure event handler

reader.BarcodeFoundEvent +=

new BarcodeReader.BarcodeFoundEventHandler(_OnBarcodeFound);

// read barcodes

reader.Read (filename, page);

}

catch(Exception ex)

{

ProcessError (ex);

}

}