←Select platform

Value Property

Summary
Gets or sets the data of this barcode as an ASCII text string.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public virtual string Value { get; set; } 
@property (nonatomic, copy, nullable) NSString *value; 
public String getValue() 
public void setValue(String value) 
public: 
virtual property String^ Value { 
   String^ get(); 
   void set (    String^ ); 
} 
Value # get and set (BarcodeData) 

Property Value

A String that represents the data of this barcode as an ASCII text string. Default value is null (Nothing in VB).

Remarks

The Value property simply calls GetData and internally SetData to get or set the data inside this BarcodeData as an ASCII text value.

Some barcodes like QR and PDF417 support data that is not necessary ASCII text. For example, an image, a URL or just raw stream of bytes. For these barcodes when reading a barcode, the Value property may not return an accurate representation of the data. Instead, use the BarcodeData.GetData method and parse them yourself. Also, when writing barcodes, you must set the raw data using the SetData method

The Australian post barcode (BarcodeSymbology.AustralianPost4State) string has a special format to distinguish different fields (i.e. FCC, DPID, and CIF). The string format puts dashes between fields as follows: "FCC-DIPD-CIF", where FCC is a 2-digit field (valid values are 11, 87, 45, 92, 59, 62, and 44), DPID is an 8-digit field representing the address, and CIF (optional) represents the customer information field. For more information, refer to the standard. This string format applies for both read and write.

GS1 Databar Expanded (BarcodeSymbology.GS1DatabarExpanded) and GS1 Databar Expanded Stacked (BarcodeSymbology.GS1DatabarExpandedStaceked) barcode strings need to be written conforming to a string format that indicates a particular encoding method, such as Method "1", Method "0100", Method "0101", … etc. For example, a string (01)00012345678905(10)ABC123" is encoded using Method "1" (i.e. General Identification Data). Note that 14th digit of the item identification number (in this case, "5"), if it exists, is considered as a check digit and is ignored. A string that is written without following any of these special encoding formats will be encoded by Method "00" (i.e. General Purpose Data).

When a BarcodeData is returned from a read operation, an extra digit in curly brackets (i.e. "{" and "}") is added to indicate the linkage bit at the beginning of the string. The curly brackets are not part of the encoded barcode data, and they are not defined in the standard. Rather, they distinguish the linkage digit from other data. For example, if a barcode is written with string "(01)00012345678905(10)ABC123" while the linkage bit is set to zero, the read function result will be "{0}(01)00012345678905(10)ABC123", where {0} is the linkage digit and the remaining characters are the barcode data.

Derived Types

Some barcode symbologies contain extra information that are not available in BarcodeData, for these types, LEADTOOLS adds derived classes to contain the extra information. Refer to BarcodeData for more information.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeData_GetDataExample() 
{ 
   string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode2.tif"); 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Load the image 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
      { 
         // Read the first QR barcode from the image 
         BarcodeData data = engine.Reader.ReadBarcode(image, LeadRect.Empty, BarcodeSymbology.QR); 
 
         // Show the barcode data found (if any) 
         if (data != null) 
         { 
            Console.WriteLine($"Data value: {data.Value}"); 
            Console.WriteLine($"Raw data is:"); 
            byte[] bytes = data.GetData(); 
            if (bytes != null) 
            { 
               int counter = 0; 
               for (int i = 0; i < bytes.Length; i++) 
               { 
                  Console.Write("{0:X2} ", bytes[i]); 
                  counter++; 
                  if (counter > 7) 
                  { 
                     Console.WriteLine(); 
                     counter = 0; 
                  } 
               } 
            } 
            else 
            { 
               Console.WriteLine("Empty"); 
            } 
         } 
         else 
         { 
            Console.WriteLine("No barcode found"); 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.nio.charset.StandardCharsets; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.barcode.*; 
import leadtools.codecs.*; 
 
 
public void barcodeDataGetDataExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String imageFileName = combine(LEAD_VARS_IMAGES_DIR, "Barcode2.tif"); 
 
   // Create the Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Load the image 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.load(imageFileName, 0, CodecsLoadByteOrder.BGR_OR_GRAY, 1, 1); 
 
   // Read the first QR barcode from the image 
   BarcodeData data = engine.getReader().readBarcode(image, LeadRect.getEmpty(), BarcodeSymbology.QR); 
 
   // Show the barcode data found (if any) 
   if (data != null) { 
      System.out.println(String.format("Data value: %s", data.getValue())); 
      System.out.println("Raw data is:"); 
      byte[] bytes = data.getData(); 
      if (bytes != null) { 
         int counter = 0; 
         for (int i = 0; i < bytes.length; i++) { 
            System.out.println(String.format("%02X", bytes[i] & 0xFFFFF)); 
            counter++; 
            if (counter > 7) { 
               System.out.println(); 
               counter = 0; 
            } 
         } 
      } else { 
         System.out.println("No barcode found"); 
      } 
   } 
} 
Requirements

Target Platforms

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

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