Contains the data for a single MicroPDF417 barcode.
[SerializableAttribute()]
public class MicroPDF417BarcodeData : BarcodeData
<TypeConverterAttribute()>
<SerializableAttribute()>
Public Class MicroPDF417BarcodeData
Inherits Leadtools.Barcode.BarcodeData
Implements System.ICloneable
@interface LTMicroPDF417BarcodeData : LTBarcodeData <NSCopying>
public class MicroPDF417BarcodeData extends BarcodeData
[TypeConverterAttribute()]
[SerializableAttribute()]
public ref class MicroPDF417BarcodeData : public Leadtools.Barcode.BarcodeData, System.ICloneable
The MicroPDF417BarcodeData class derives from the base BarcodeData to add specific data that can be read or written when using MicroPDF417 barcodes.
When the BarcodeReader object detects and reads a MicroPDF417 (BarcodeSymbology.MicroPDF417), the BarcodeReader.ReadBarcode and BarcodeReader.ReadBarcodes methods will return the MicroPDF417BarcodeData object for each barcode casted down to the base BarcodeData class.
You can perform standard .NET casting to get the object as MicroPDF417BarcodeData and then examine the extra data properties associated with it.
In addition to all the data members returned as usual in the base BarcodeData object, this class adds the following members:
DataCode - The MicroPDF417 barcode function code word for Code 128 emulation.
IsLinked - Indicates that the MicroPDF417 barcode is linked to a linear symbol printed below it.
In addition to the members above, other MicroPDF417 read options not related to the barcode data can be set using the MicroPDF417BarcodeReadOptions class.
The BarcodeWriter class contains the WriteBarcode method that is used to write a barcode to an image. This method accepts the data parameter as the base BarcodeData object. To write a MicroPDF417 barcode, create an instance of MicroPDF417BarcodeData and fill the required parameters then pass this object as the data parameter to WriteBarcode.
In addition to all the data members that must be set as usual in the base BarcodeData object, you must also specify the following members:
In addition to the members above, other MicroPDF417 write options not related to the barcode data can be set using the MicroPDF417BarcodeWriteOptions class.
Use the static (or Shared in VB) BarcodeData.CreateDefaultBarcodeData method to create a new instance of MicroPDF417BarcodeData that contains default parameters ready for writing to an image:
Dim microPDF417Data As MicroPDF417BarcodeData = DirectCast(BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.MicroPDF417), MicroPDF417BarcodeData)
MicroPDF417BarcodeData microPDF417Data = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.MicroPDF417) as MicroPDF417BarcodeData;
This example writes a couple of MicroPDF417 barcode with different options to an image and then reads them back.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;
public void MicroPDF417Barcode_Example()
{
string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyMicroPDF417Barcodes.tif");
BarcodeEngine engine = new BarcodeEngine();
// Create the image to write the barcodes to
int resolution = 300;
using (RasterImage image = RasterImage.Create((int)(8.5 * resolution), (int)(11.0 * resolution), 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White)))
{
// Write two MicroPDF417 barcodes
WriteBarcode(engine.Writer, image, "DATA1", MicroPDF417BarcodeSymbolSize.Smallest, true);
WriteBarcode(engine.Writer, image, "DATA2", MicroPDF417BarcodeSymbolSize.Size44X4, false);
// Save the image
using (RasterCodecs codecs = new RasterCodecs())
{
codecs.Save(image, imageFileName, RasterImageFormat.CcittGroup4, 1);
}
}
// Now read the barcodes again
using (RasterCodecs codecs = new RasterCodecs())
{
using (RasterImage image = codecs.Load(imageFileName))
{
ReadBarcodes(engine.Reader, image);
}
}
}
private void WriteBarcode(BarcodeWriter writer, RasterImage image, string value, MicroPDF417BarcodeSymbolSize symbolSize, bool topLeft)
{
// Create the barcode data
MicroPDF417BarcodeData barcode = new MicroPDF417BarcodeData();
barcode.Value = value;
barcode.DataCode = 0;
// We will use the alignment to position the barcodes, so use all of the image
barcode.Bounds = new LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel);
// Set the write options
MicroPDF417BarcodeWriteOptions options = new MicroPDF417BarcodeWriteOptions();
if (topLeft)
{
options.HorizontalAlignment = BarcodeAlignment.Near;
options.VerticalAlignment = BarcodeAlignment.Near;
}
else
{
options.HorizontalAlignment = BarcodeAlignment.Far;
options.VerticalAlignment = BarcodeAlignment.Far;
}
options.UseMode128Emulation = false;
options.IsLinked = false;
options.EnableGroupMode = false;
options.XModule = 30;
options.XModuleAspectRatio = 3;
options.LimitByRowsAndColumns = true;
options.SymbolSize = symbolSize;
// Write it
Console.WriteLine("Writing barcode with symbol size: {0} and Data: {1}", symbolSize, value);
writer.WriteBarcode(image, barcode, options);
}
private void ReadBarcodes(BarcodeReader reader, RasterImage image)
{
// Setup read options
MicroPDF417BarcodeReadOptions options = new MicroPDF417BarcodeReadOptions();
options.SearchDirection = BarcodeSearchDirection.Horizontal;
options.EnableDoublePass = false;
options.ReadMode = MicroPDF417BarcodeReadMode.Mode0;
options.ReadOptionalMacroFileNameField = false;
options.ReadOptionalMacroSegmentCountField = false;
options.ReadOptionalMacroTimestampField = false;
options.ReadOptionalMacroSenderField = false;
options.ReadOptionalMacroAddresseeField = false;
options.ReadOptionalMacroFileSizeField = false;
options.ReadOptionalMacroChecksumField = false;
options.ReadOptionalMacro79AndAZField = false;
Console.WriteLine("Reading Barcodes");
BarcodeData[] barcodes = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, new BarcodeSymbology[] { BarcodeSymbology.MicroPDF417 }, new BarcodeReadOptions[] { options });
Console.WriteLine("{0} barcodes found:", barcodes.Length);
foreach (MicroPDF417BarcodeData barcode in barcodes)
{
Console.WriteLine(" At {0} and data: {1}", barcode.Bounds, barcode.Value);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms
Imports Leadtools.Barcode
Imports Leadtools.ImageProcessing
Public Sub MicroPDF417Barcode_Example()
Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "MyMicroPDF417Barcodes.tif")
Dim engine As New BarcodeEngine()
' Create the image to write the barcodes to
Dim resolution As Integer = 300
Using image As RasterImage = RasterImage.Create(CType(8.5 * resolution, Integer), CType(11.0 * resolution, Integer), 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))
' Write two MicroPDF417 barcodes
WriteBarcode(engine.Writer, image, "DATA1", MicroPDF417BarcodeSymbolSize.Smallest, True)
WriteBarcode(engine.Writer, image, "DATA2", MicroPDF417BarcodeSymbolSize.Size44X4, False)
' Save the image
Using codecs As New RasterCodecs()
codecs.Save(image, imageFileName, RasterImageFormat.CcittGroup4, 1)
End Using
End Using
' Now read the barcodes again
Using codecs As New RasterCodecs()
Using image As RasterImage = codecs.Load(imageFileName)
ReadBarcodes(engine.Reader, image)
End Using
End Using
End Sub
Private Sub WriteBarcode(ByVal writer As BarcodeWriter, ByVal image As RasterImage, ByVal value As String, ByVal symbolSize As MicroPDF417BarcodeSymbolSize, ByVal topLeft As Boolean)
' Create the barcode data
Dim barcode As New MicroPDF417BarcodeData()
barcode.Value = value
barcode.DataCode = 0
' We will use the alignment to position the barcodes, so use all of the image
barcode.Bounds = New LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel)
' Set the write options
Dim options As New MicroPDF417BarcodeWriteOptions()
If topLeft Then
options.HorizontalAlignment = BarcodeAlignment.Near
options.VerticalAlignment = BarcodeAlignment.Near
Else
options.HorizontalAlignment = BarcodeAlignment.Far
options.VerticalAlignment = BarcodeAlignment.Far
End If
options.UseMode128Emulation = False
options.IsLinked = False
options.EnableGroupMode = False
options.XModule = 30
options.XModuleAspectRatio = 3
options.LimitByRowsAndColumns = True
options.SymbolSize = symbolSize
' Write it
Console.WriteLine("Writing barcode with symbol size: {0} and Data: {1}", symbolSize, value)
writer.WriteBarcode(image, barcode, options)
End Sub
Private Sub ReadBarcodes(ByVal reader As BarcodeReader, ByVal image As RasterImage)
' Setup read options
Dim options As New MicroPDF417BarcodeReadOptions()
options.SearchDirection = BarcodeSearchDirection.Horizontal
options.EnableDoublePass = False
options.ReadMode = MicroPDF417BarcodeReadMode.Mode0
options.ReadOptionalMacroFileNameField = False
options.ReadOptionalMacroSegmentCountField = False
options.ReadOptionalMacroTimestampField = False
options.ReadOptionalMacroSenderField = False
options.ReadOptionalMacroAddresseeField = False
options.ReadOptionalMacroFileSizeField = False
options.ReadOptionalMacroChecksumField = False
options.ReadOptionalMacro79AndAZField = False
Console.WriteLine("Reading Barcodes")
Dim barcodes() As BarcodeData = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, New BarcodeSymbology() {BarcodeSymbology.MicroPDF417}, New BarcodeReadOptions() {options})
Console.WriteLine("{0} barcodes found:", barcodes.Length)
For Each barcode As MicroPDF417BarcodeData In barcodes
Console.WriteLine(" At {0} and data: {1}", barcode.Bounds, barcode.Value)
Next
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;
using Leadtools.Examples;
public void MicroPDF417Barcode_Example(RasterImage image, Stream outStream)
{
BarcodeEngine engine = new BarcodeEngine();
// Create the image to write the barcodes to
RasterCodecs codecs = new RasterCodecs();
// Write two MicroPDF417 barcodes
WriteBarcode(engine.Writer, image, "DATA1", MicroPDF417BarcodeSymbolSize.Smallest, true);
WriteBarcode(engine.Writer, image, "DATA2", MicroPDF417BarcodeSymbolSize.Size44X4, false);
// Save the image
codecs.Save(image, outStream, RasterImageFormat.CcittGroup4, 1);
// Now read the barcodes again
ReadBarcodes(engine.Reader, image);
}
private void WriteBarcode(BarcodeWriter writer, RasterImage image, string value, MicroPDF417BarcodeSymbolSize symbolSize, bool topLeft)
{
// Create the barcode data
MicroPDF417BarcodeData barcode = new MicroPDF417BarcodeData();
barcode.Value = value;
barcode.DataCode = 0;
// We will use the alignment to position the barcodes, so use all of the image
barcode.Bounds = new LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel);
// Set the write options
MicroPDF417BarcodeWriteOptions options = new MicroPDF417BarcodeWriteOptions();
if (topLeft)
{
options.HorizontalAlignment = BarcodeAlignment.Near;
options.VerticalAlignment = BarcodeAlignment.Near;
}
else
{
options.HorizontalAlignment = BarcodeAlignment.Far;
options.VerticalAlignment = BarcodeAlignment.Far;
}
options.UseMode128Emulation = false;
options.IsLinked = false;
options.EnableGroupMode = false;
options.XModule = 30;
options.XModuleAspectRatio = 3;
options.LimitByRowsAndColumns = true;
options.SymbolSize = symbolSize;
// Write it
Console.WriteLine("Writing barcode with symbol size: {0} and Data: {1}", symbolSize, value);
writer.WriteBarcode(image, barcode, options);
}
private void ReadBarcodes(BarcodeReader reader, RasterImage image)
{
// Setup read options
MicroPDF417BarcodeReadOptions options = new MicroPDF417BarcodeReadOptions();
options.SearchDirection = BarcodeSearchDirection.Horizontal;
options.EnableDoublePass = false;
options.ReadMode = MicroPDF417BarcodeReadMode.Mode0;
options.ReadOptionalMacroFileNameField = false;
options.ReadOptionalMacroSegmentCountField = false;
options.ReadOptionalMacroTimestampField = false;
options.ReadOptionalMacroSenderField = false;
options.ReadOptionalMacroAddresseeField = false;
options.ReadOptionalMacroFileSizeField = false;
options.ReadOptionalMacroChecksumField = false;
options.ReadOptionalMacro79AndAZField = false;
Console.WriteLine("Reading Barcodes");
BarcodeData[] barcodes = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, new BarcodeSymbology[] { BarcodeSymbology.MicroPDF417 }, new BarcodeReadOptions[] { options });
Console.WriteLine("{0} barcodes found:", barcodes.Length);
foreach (MicroPDF417BarcodeData barcode in barcodes)
{
Console.WriteLine(" At {0} and data: {1}", barcode.Bounds, barcode.Value);
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms
Imports Leadtools.Barcode
Imports Leadtools.ImageProcessing
Public Sub MicroPDF417Barcode_Example(ByVal image As RasterImage, ByVal outStream As Stream)
Dim engine As BarcodeEngine = New BarcodeEngine()
' Create the image to write the barcodes to
Dim codecs As RasterCodecs = New RasterCodecs()
' Write two MicroPDF417 barcodes
WriteBarcode(engine.Writer, image, "DATA1", MicroPDF417BarcodeSymbolSize.Smallest, True)
WriteBarcode(engine.Writer, image, "DATA2", MicroPDF417BarcodeSymbolSize.Size44X4, False)
' Save the image
codecs.Save(image, outStream, RasterImageFormat.CcittGroup4, 1)
' Now read the barcodes again
ReadBarcodes(engine.Reader, image)
End Sub
Private Sub WriteBarcode(ByVal writer As BarcodeWriter, ByVal image As RasterImage, ByVal value As String, ByVal symbolSize As MicroPDF417BarcodeSymbolSize, ByVal topLeft As Boolean)
' Create the barcode data
Dim barcode As MicroPDF417BarcodeData = New MicroPDF417BarcodeData()
barcode.Value = value
barcode.DataCode = 0
' We will use the alignment to position the barcodes, so use all of the image
barcode.Bounds = New LogicalRectangle(0, 0, image.ImageWidth, image.ImageHeight, LogicalUnit.Pixel)
' Set the write options
Dim options As MicroPDF417BarcodeWriteOptions = New MicroPDF417BarcodeWriteOptions()
If topLeft Then
options.HorizontalAlignment = BarcodeAlignment.Near
options.VerticalAlignment = BarcodeAlignment.Near
Else
options.HorizontalAlignment = BarcodeAlignment.Far
options.VerticalAlignment = BarcodeAlignment.Far
End If
options.UseMode128Emulation = False
options.IsLinked = False
options.EnableGroupMode = False
options.XModule = 30
options.XModuleAspectRatio = 3
options.LimitByRowsAndColumns = True
options.SymbolSize = symbolSize
' Write it
Console.WriteLine("Writing barcode with symbol size: {0} and Data: {1}", symbolSize, value)
writer.WriteBarcode(image, barcode, options)
End Sub
Private Sub ReadBarcodes(ByVal reader As BarcodeReader, ByVal image As RasterImage)
' Setup read options
Dim options As MicroPDF417BarcodeReadOptions = New MicroPDF417BarcodeReadOptions()
options.SearchDirection = BarcodeSearchDirection.Horizontal
options.EnableDoublePass = False
options.ReadMode = MicroPDF417BarcodeReadMode.Mode0
options.ReadOptionalMacroFileNameField = False
options.ReadOptionalMacroSegmentCountField = False
options.ReadOptionalMacroTimestampField = False
options.ReadOptionalMacroSenderField = False
options.ReadOptionalMacroAddresseeField = False
options.ReadOptionalMacroFileSizeField = False
options.ReadOptionalMacroChecksumField = False
options.ReadOptionalMacro79AndAZField = False
Console.WriteLine("Reading Barcodes")
Dim barcodes As BarcodeData() = reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, New BarcodeSymbology() {BarcodeSymbology.MicroPDF417}, New BarcodeReadOptions() {options})
Console.WriteLine("{0} barcodes found:", barcodes.Length)
For Each barcode As MicroPDF417BarcodeData In barcodes
Console.WriteLine(" At {0} and data: {1}", barcode.Bounds, barcode.Value)
Next barcode
End Sub
MicroPDF417BarcodeData Members
MicroPDF417BarcodeReadOptions Class
MicroPDF417BarcodeWriteOptions Class
Programming with LEADTOOLS Barcode
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET