←Select platform

Data Property

Summary
Gets the barcode data found.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public BarcodeData Data { get; } 
@property (nonatomic, strong, readonly, nullable) LTBarcodeData *data 
public BarcodeData getData() 
public: 
property BarcodeData^ Data { 
   BarcodeData^ get(); 
} 

Property Value

A BarcodeData object that contains the data of the barcode found.

Remarks

Only valid if Operation is BarcodeReadSymbologyOperation.PostRead and no error occurred. Otherwise, it will be null (Nothing in VB).

Note that this property may consist of an object of a derived class that may contain extra information for the symbology. Refer to BarcodeData for more information.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeReader_ReadSymbologyExample() 
{ 
   string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif"); 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Get the Barcode reader instance 
   BarcodeReader reader = engine.Reader; 
          
   // Load the image 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
      { 
         // Subscribe to the ReadSymbology event 
         reader.ReadSymbology += new EventHandler<BarcodeReadSymbologyEventArgs>(reader_ReadSymbology); 
         // Read all barcodes in the image 
         reader.ReadBarcodes(image, LeadRect.Empty, 0, null); 
         reader.ReadSymbology -= new EventHandler<BarcodeReadSymbologyEventArgs>(reader_ReadSymbology); 
      } 
   } 
} 
 
private void reader_ReadSymbology(object sender, BarcodeReadSymbologyEventArgs e) 
{ 
   if (e.Operation == BarcodeReadSymbologyOperation.PreRead) 
   { 
      // Before reading, show the symbologies the engine is going to try to read 
      Console.WriteLine("Trying to read the following symbologies:"); 
      BarcodeSymbology[] symbologies = e.GetSymbologies(); 
      for (int i = 0; i < symbologies.Length; i++) 
      { 
         Console.Write(symbologies[i]); 
         if (i != (symbologies.Length - 1)) 
         { 
            Console.Write(", "); 
            Console.WriteLine(e.Options.FriendlyName); 
         } 
         else 
         { 
            Console.WriteLine(); 
         } 
      } 
   } 
   else if (e.Operation == BarcodeReadSymbologyOperation.PostRead) 
   { 
      if (e.Error == null) 
      { 
         // No errors 
         BarcodeData barcode = e.Data; 
         if (barcode != null) 
         { 
            // Found a barcode, show it 
            Console.WriteLine("  {0} at {1} with data {2}", barcode.Symbology, barcode.Bounds, barcode.Value); 
         } 
         else 
         { 
            Console.WriteLine("  No barcodes found"); 
         } 
      } 
      else 
      { 
         // Show the error 
         Console.WriteLine("Error: {0}", e.Error.Message); 
 
         // Tell the reader top stop reading barcodes 
         e.Status = BarcodeReadSymbologyStatus.Abort; 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.9
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Barcode Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.