public BarcodeData(BarcodeSymbology symbology,string value)
public:BarcodeData(BarcodeSymbology symbology,String^ value)
symbology
Barcode symbology to use.
value
A String that specifies the ASCII text representation of the barcode data.
This constructor initializes the BarcodeData member as follows:
s
| Member | Value |
|---|---|
| Symbology | symbology |
| Bounds | LeadRect.Empty |
| RotationAngle | 0 |
| BarWidthReduction | 0 |
| Byte array inside GetData | The raw value of the bytes array in value. if this parameter is null, then the data is null too. |
| Value | value. |
| Tag | null (Nothing in Visual Basic) |
To quickly construct a new BarcodeData object with a specific symbology and data as a raw byte array, use BarcodeData(BarcodeSymbology symbology, byte[] data) to construct a default BarcodeData, use BarcodeData().
To create an instance of BarcodeData suitable for writing for a specified symbology, use CreateDefaultBarcodeData.
This example creates a BarcodeData with specified symbology and ASCII text. It then writes it to an image.
using Leadtools;using Leadtools.Codecs;using Leadtools.Barcode;using Leadtools.ImageProcessing;public void BarcodeData_FromStringExample(){string outFileName = Path.Combine(LEAD_VARS.ImagesDir, @"MyBarcode.tif");// This is UPC data to save a a stringstring dataString = "01234567890";// Create a BarcodeData object from this dataBarcodeData data = new BarcodeData(BarcodeSymbology.UPCA, dataString);data.Bounds = new LeadRect(0, 0, 400, 200);// Make sure it is the sameDebug.Assert(data.Value == dataString);// Write it to an imageBarcodeEngine engine = new BarcodeEngine();using (RasterCodecs codecs = new RasterCodecs()){int resolution = 300;LeadRect pixels = data.Bounds;using (RasterImage image = RasterImage.Create(pixels.Width, pixels.Height, 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))){engine.Writer.WriteBarcode(image, data, null);codecs.Save(image, outFileName, RasterImageFormat.Tif, 1);}}}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 barcodeDataFromStringExample() {final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";String outFileName = combine(LEAD_VARS_IMAGES_DIR, "barcode1.tif");// This is UPC data to save a a stringString dataString = "01234567890";// Create a BarcodeData object from this dataBarcodeData data = new BarcodeData(BarcodeSymbology.UPC_A, dataString);data.setBounds(new LeadRect(0, 0, 400, 200));// Write it to an imageBarcodeEngine engine = new BarcodeEngine();RasterCodecs codecs = new RasterCodecs();int resolution = 300;LeadRect pixels = data.getBounds();RasterImage image = RasterImage.create(pixels.getWidth(), pixels.getHeight(), 1, resolution, RasterColor.fromKnownColor(RasterKnownColor.WHITE));assertTrue(image.getWidth() == 400 && image.getHeight() == 200);engine.getWriter().writeBarcode(image, data, null);codecs.save(image, outFileName, RasterImageFormat.TIF, 1);assertTrue("File does not exist", new File(outFileName).exists());System.out.println("Command run and file exported to: " + outFileName);image.dispose();codecs.dispose();}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
