VintaSoft Barcode .NET SDK v12.0 (Standard+WPF edition)
Vintasoft.Barcode.SymbologySubsets.AAMVA Namespace / AamvaBarcodeSymbology Class
Members Example




In This Topic
    AamvaBarcodeSymbology Class
    In This Topic
    Defines the AAMVA (DL/ID Card Design Standard) barcode symbology - subset of PDF417 barcode symbology.
    Object Model
    AamvaBarcodeSymbology ClassBarcodeSymbologySubset Class
    Syntax
    'Declaration
     
    Public Class AamvaBarcodeSymbology 
       Inherits Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubset
    'Usage
     
    Dim instance As AamvaBarcodeSymbology
    public class AamvaBarcodeSymbology : Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubset 
    public __gc class AamvaBarcodeSymbology : public Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubset 
    public ref class AamvaBarcodeSymbology : public Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubset 
    Example
    This example shows how to generate and recognize AAMVA barcode.
    Imports System.Drawing   
       
    Imports Vintasoft.Barcode   
    Imports Vintasoft.Barcode.BarcodeInfo   
    Imports Vintasoft.Barcode.SymbologySubsets   
    Imports Vintasoft.Barcode.SymbologySubsets.AAMVA   
       
    Class AAMVAExample   
    	''' <summary>   
    	''' Generates and recognizes AAMVA barcode.   
    	''' </summary>   
    	Public Shared Sub Test()   
            ' create DL data elements   
            Dim dlElements As AamvaDataElement() = New AamvaDataElement() { _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAQ, "C12345678"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DCS, "CARPENTER"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DDE, "N"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAC, "JON"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DDF, "N"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAD, "T"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DDG, "N"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DCA, "D"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DCB, "1"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DCD, "NONE"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DBD, "10052015"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DBB, "07241984"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DBA, "01092022"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DBC, "1"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAU, "067 in"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAY, "BLK"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAG, "3211 SANCTUARY LANE"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAI, "LOUISVILLE"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAJ, "KY"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DAK, "123454321"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DCF, "9876543210123456"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DCG, "USA"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DCK, "1234567890123456"), _   
                New AamvaDataElement(AamvaDataElementIdentifiers.DDB, "01062016")}   
       
            ' create ZK data elements   
            Dim zkElements As AamvaDataElement() = New AamvaDataElement() { _   
                New AamvaDataElement("ZKA", "Y"), _   
                New AamvaDataElement("ZKB", "TEST"), _   
                New AamvaDataElement("ZKC", "9876"), _   
                New AamvaDataElement("ZKD", "DUP")}   
       
    		' create subfiles   
    		Dim subfiles As AamvaSubfile() = New AamvaSubfile() {New AamvaSubfile("DL", dlElements), New AamvaSubfile("ZK", zkElements)}   
       
    		' create AAMVA barcode value   
    		Dim barcodeValue As New AamvaBarcodeValue(AamvaVersionLevel.AAMVA2016, 636046, 0, subfiles)   
       
    		' generate barcode image   
    		Using barcodeImage As Image = Generate(barcodeValue)   
    			' recognize barcode value   
    			Dim recognizedBarcode As AamvaBarcodeInfo = Recognize(barcodeImage)   
       
    			' check value   
    			If barcodeValue.ToString() <> recognizedBarcode.AamvaValue.ToString() Then   
    				Throw New ApplicationException()   
    			End If   
       
    			' print value   
    			Console.WriteLine("Version:         {0}", recognizedBarcode.VersionLevel)   
    			Console.WriteLine("Country:         {0}", recognizedBarcode.CountryId)   
    			Console.WriteLine("IIN:             {0}", recognizedBarcode.IssuerIdentificationNumber)   
    			Console.WriteLine("License number:  {0}", recognizedBarcode.LicenseNumber)   
    			Console.WriteLine("First name:      {0}", recognizedBarcode.FirstName)   
    			Console.WriteLine("Family name:     {0}", recognizedBarcode.FamilyName)   
    			Console.WriteLine("Middle name:     {0}", recognizedBarcode.MiddleName)   
    			Console.WriteLine("Sex (1=M;2=F):   {0}", recognizedBarcode.Sex)   
    			Console.WriteLine("Eye color:       {0}", recognizedBarcode.EyeColor)   
    			Console.WriteLine("Date of birth:   {0}", recognizedBarcode.DateOfBirth.ToShortDateString())   
    			Console.WriteLine("Issue date:      {0}", recognizedBarcode.IssueDate.ToShortDateString())   
    			Console.WriteLine("Expiration date: {0}", recognizedBarcode.ExpirationDate.ToShortDateString())   
    			Console.WriteLine("State code:      {0}", recognizedBarcode.AddressStateCode)   
    			Console.WriteLine("City:            {0}", recognizedBarcode.AddressCity)   
    			Console.WriteLine("Postal code:     {0}", recognizedBarcode.AddressPostalCode)   
    			Console.WriteLine("Street:          {0}", recognizedBarcode.AddressStreet1)   
    			Console.WriteLine()   
    			Console.WriteLine("Data elements:")   
    			For Each subfile As AamvaSubfile In recognizedBarcode.Subfiles   
    				Console.WriteLine("[{0}] subfile:", subfile.SubfileType)   
    				For Each dataElement As AamvaDataElement In subfile.DataElements   
    					If dataElement.Identifier.VersionLevel <> AamvaVersionLevel.Undefined Then   
    						Console.Write("  [{0}] {1}:", dataElement.Identifier.ID, dataElement.Identifier.Description)   
    					Else   
    						Console.Write("  [{0}]:", dataElement.Identifier.ID)   
    					End If   
    					Console.WriteLine(" {0}", dataElement.Value)   
    				Next   
    			Next   
    		End Using   
    	End Sub   
       
    	''' <summary>   
    	''' Generates the AAMVA barcode image.   
    	''' </summary>   
    	''' <param name="barcodeValue">The barcode value.</param>   
    	Private Shared Function Generate(barcodeValue As AamvaBarcodeValue) As Image   
    		' create barcode writer   
    		Dim writer As New BarcodeWriter()   
       
    		' encode AAMVA barcode to writer settings   
    		BarcodeSymbologySubsets.AAMVA.Encode(barcodeValue, writer.Settings)   
       
    		' generate barcode image   
    		Return writer.GetBarcodeAsBitmap()   
    	End Function   
       
    	''' <summary>   
    	''' Recognizes the AAMVA barcode from image.   
    	''' </summary>   
    	''' <param name="barcodeImage">The barcode image.</param>   
    	Private Shared Function Recognize(barcodeImage As Image) As AamvaBarcodeInfo   
    		' create barcode reader   
    		Using reader As New BarcodeReader()   
    			reader.Settings.AutomaticRecognition = True   
       
    			' specify that AAMVA barcode must be recognizeds   
    			reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.AAMVA)   
       
    			' recognize barcodes   
    			Dim info As IBarcodeInfo = reader.ReadBarcodes(barcodeImage)(0)   
       
    			' return AAMVA value   
    			Return DirectCast(info, AamvaBarcodeInfo)   
    		End Using   
    	End Function   
    End Class
    using System;
    using System.Drawing;
                
    using Vintasoft.Barcode;
    using Vintasoft.Barcode.BarcodeInfo;
    using Vintasoft.Barcode.SymbologySubsets;
    using Vintasoft.Barcode.SymbologySubsets.AAMVA;
                
    class AAMVAExample
    {
        /// <summary>
        /// Generates and recognizes AAMVA barcode.
        /// </summary>
        public static void Test()
        {
            // create DL data elements
            AamvaDataElement[] dlElements = new AamvaDataElement[] {
                new AamvaDataElement(AamvaDataElementIdentifiers.DAQ, "C12345678"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DCS, "CARPENTER"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DDE, "N"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAC, "JON"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DDF, "N"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAD, "T"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DDG, "N"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DCA, "D"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DCB, "1"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DCD, "NONE"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DBD, "10052015"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DBB, "07241984"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DBA, "01092022"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DBC, "1"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAU, "067 in"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAY, "BLK"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAG, "3211 SANCTUARY LANE"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAI, "LOUISVILLE"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAJ, "KY"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DAK, "123454321"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DCF, "9876543210123456"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DCG, "USA"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DCK, "1234567890123456"),
                new AamvaDataElement(AamvaDataElementIdentifiers.DDB, "01062016")
            };
                
            // create ZK data elements
            AamvaDataElement[] zkElements = new AamvaDataElement[] {
                new AamvaDataElement("ZKA", "Y"),
                new AamvaDataElement("ZKB", "TEST"),
                new AamvaDataElement("ZKC", "9876"),
                new AamvaDataElement("ZKD", "DUP"),
            };
                
            // create subfiles
            AamvaSubfile[] subfiles = new AamvaSubfile[]{
                new AamvaSubfile("DL", dlElements),
                new AamvaSubfile("ZK", zkElements)
            };
            
            // create AAMVA barcode value
            AamvaBarcodeValue barcodeValue = new AamvaBarcodeValue(AamvaVersionLevel.AAMVA2016, 636046, 0, subfiles);
            
            // generate barcode image
            using (Image barcodeImage = Generate(barcodeValue))
            {
                // recognize barcode value
                AamvaBarcodeInfo recognizedBarcode = Recognize(barcodeImage);
                
                // check value
                if (barcodeValue.ToString() != recognizedBarcode.AamvaValue.ToString())
                    throw new ApplicationException();
                
                // print value
                Console.WriteLine("Version:         {0}", recognizedBarcode.VersionLevel);
                Console.WriteLine("Country:         {0}", recognizedBarcode.CountryId);
                Console.WriteLine("IIN:             {0}", recognizedBarcode.IssuerIdentificationNumber);
                Console.WriteLine("License number:  {0}", recognizedBarcode.LicenseNumber);
                Console.WriteLine("First name:      {0}", recognizedBarcode.FirstName);
                Console.WriteLine("Family name:     {0}", recognizedBarcode.FamilyName);
                Console.WriteLine("Middle name:     {0}", recognizedBarcode.MiddleName);
                Console.WriteLine("Sex (1=M;2=F):   {0}", recognizedBarcode.Sex);
                Console.WriteLine("Eye color:       {0}", recognizedBarcode.EyeColor);            
                Console.WriteLine("Date of birth:   {0}", recognizedBarcode.DateOfBirth.ToShortDateString());
                Console.WriteLine("Issue date:      {0}", recognizedBarcode.IssueDate.ToShortDateString());
                Console.WriteLine("Expiration date: {0}", recognizedBarcode.ExpirationDate.ToShortDateString());
                Console.WriteLine("State code:      {0}", recognizedBarcode.AddressStateCode);
                Console.WriteLine("City:            {0}", recognizedBarcode.AddressCity);
                Console.WriteLine("Postal code:     {0}", recognizedBarcode.AddressPostalCode);
                Console.WriteLine("Street:          {0}", recognizedBarcode.AddressStreet1);
                Console.WriteLine();
                Console.WriteLine("Data elements:");
                foreach (AamvaSubfile subfile in recognizedBarcode.Subfiles)
                {
                    Console.WriteLine("[{0}] subfile:", subfile.SubfileType);
                    foreach (AamvaDataElement dataElement in subfile.DataElements)
                    {
                        if (dataElement.Identifier.VersionLevel != AamvaVersionLevel.Undefined)
                            Console.Write("  [{0}] {1}:", dataElement.Identifier.ID, dataElement.Identifier.Description);
                        else
                            Console.Write("  [{0}]:", dataElement.Identifier.ID);
                        Console.WriteLine(" {0}", dataElement.Value);
                    }
                }
            }
        }
                
        /// <summary>
        /// Generates the AAMVA barcode image.
        /// </summary>
        /// <param name="barcodeValue">The barcode value.</param>
        private static Image Generate(AamvaBarcodeValue barcodeValue)
        {
            // create barcode writer
            BarcodeWriter writer = new BarcodeWriter();
                
            // encode AAMVA barcode to writer settings
            BarcodeSymbologySubsets.AAMVA.Encode(barcodeValue, writer.Settings);
            
            // generate barcode image
            return writer.GetBarcodeAsBitmap();
        }
                
        /// <summary>
        /// Recognizes the AAMVA barcode from image.
        /// </summary>
        /// <param name="barcodeImage">The barcode image.</param>
        private static AamvaBarcodeInfo Recognize(Image barcodeImage)
        {
            // create barcode reader
            using (BarcodeReader reader = new BarcodeReader())
            {
                reader.Settings.AutomaticRecognition = true;
                
                // specify that AAMVA barcode must be recognizeds
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.AAMVA);
                
                // recognize barcodes
                IBarcodeInfo info = reader.ReadBarcodes(barcodeImage)[0];
                
                // return AAMVA value
                return (AamvaBarcodeInfo)info;
            }
        }    
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubset
          Vintasoft.Barcode.SymbologySubsets.AAMVA.AamvaBarcodeSymbology

    Requirements

    Target Platforms: .NET Framework 2.0, 3.0, 3.5, 4.x

    See Also