Provides information encoded in an AAMVA CDS related to ID card or driver's license, of the cardholder.
public class AAMVAID : IDisposable
Public Class AAMVAID
Implements System.IDisposable
@interface AAMVAID : NSObject
public class AAMVAID
public ref class AAMVAID : public System.IDisposable
The class will be filled by calling BarcodeData.ParseAAMVAData(byte[], bool) when reading PDF417 barcodes from North American ID cards and driver's licenses.
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;
public void AAMVA_Example()
{
RasterSupport.SetLicense(@"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC", File.ReadAllText(@"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC.KEY"));
const string JURISDICTION_VERSION = "00";
const string SUBFILE_TYPE_CODE = "DL";
const int SUBFILES_COUNT = 1;
const int BITS_PER_PIXEL = 24;
const int IMAGE_DPI = 300;
BarcodeEngine barcodeEngine = new BarcodeEngine();
RasterCodecs codecs = new RasterCodecs();
AAMVAID driversLicenseID = null;
DateTime birthday = new DateTime(DateTime.Now.Year - 16, DateTime.Now.Month, DateTime.Now.Day);
string[,] driversLicenseData = new string[,] {{"DDF", "N"}, // First name truction (N = not truncated)
{"DDE", "N"}, // Last name truction (N = not truncated)
{"DCG", "USA"}, // Country identification
{"DCF", "NONE"}, // Document discriminator
{"DAQ", "1234567890"}, // ID Number
{"DAK", "123456 "}, // Postal code
{"DAJ", "PA"}, // Address Jurisdiction Code
{"DAI", "Any Town"}, // Address City
{"DAG", "123 Main Street"}, // Address Street 1
{"DAU", "072 in"}, // Height (inches or centimeters)
{"DAY", "BRO"}, // Eye color
{"DBC", "1"}, // Sex (Male = 1, Female = 2, 9 = Not specified)
{"DBB", birthday.ToString("MMddyyyy")}, // Date of Birth
{"DBD", DateTime.Now.ToString("MMddyyyy")}, // Document Issue Date
{"DAD", "NONE"}, // Middle Name
{"DAC", "John"}, // First name
{"DCS", "Doe"}, // Last name
{"DBA", DateTime.Now.AddYears(6).ToString("MMddyyyy")},// Expiration date
{"DCD", "M"}, // Jurisdiction-specific endorsement codes
{"DCB", "NONE"}, // Jurisdiction-specific restriction codes
{"DCA", "C"}, // Jurisdiction-specific vehicle class
{"DDJ", birthday.AddYears(21).ToString("MMddyyyy")}, // Under 21 until
{"DDI", birthday.AddYears(19).ToString("MMddyyyy")}, // Under 19 until
{"DDH", birthday.AddYears(18).ToString("MMddyyyy")}, // Under 18 until
{"DAZ", "BRO"}}; // Hair color
using (AAMVAIDBuilder builder = new AAMVAIDBuilder())
{
builder.SetJurisdiction(AAMVAJurisdiction.Pennsylvania, AAMVAID.LookupIssuerIdentificationNumber(AAMVAJurisdiction.Pennsylvania))
.SetVersion(AAMVAVersion.Version2016)
.SetJurisdictionVersion(JURISDICTION_VERSION)
.SetNumberOfEntries(SUBFILES_COUNT);
builder.SetSubfileType(SUBFILES_COUNT - 1, AAMVASubfileType.DL, SUBFILE_TYPE_CODE);
for (int i = 0; i < driversLicenseData.GetLength(0); i++)
builder.AddDataElementToSubfile(0, driversLicenseData[i, 0], driversLicenseData[i, 1]);
driversLicenseID = builder.Build();
}
PDF417BarcodeData data = new PDF417BarcodeData();
data.Symbology = BarcodeSymbology.PDF417;
data.SetData(driversLicenseID.GetBytes());
PDF417BarcodeWriteOptions pdf417WriteOptions = (PDF417BarcodeWriteOptions)barcodeEngine.Writer.GetDefaultOptions(BarcodeSymbology.PDF417);
//Refer to AAMVA CDS 2016 Section D.3 thru D.11.2
//Must range from 0.0066 to 0.015 inches
pdf417WriteOptions.XModule = 15; //0.015
//Must >= 3
pdf417WriteOptions.XModuleAspectRatio = 3;
//Error level must be at least 3, 5 is recommended
pdf417WriteOptions.ECCLevel = PDF417BarcodeECCLevel.Level5;
//Default WidthAspectRatio is 2:1. 4:1 looks similar to ID barcodes in the wild
pdf417WriteOptions.SymbolWidthAspectRatio = 4;
//Default quiet zone for PDF417 is 2 * XModule
barcodeEngine.Writer.CalculateBarcodeDataBounds(LeadRect.Empty, IMAGE_DPI, IMAGE_DPI, data, pdf417WriteOptions);
using (RasterImage image = RasterImage.Create(data.Bounds.Width, data.Bounds.Height, BITS_PER_PIXEL, IMAGE_DPI, new RasterColor(255, 255, 255)))
{
barcodeEngine.Writer.WriteBarcode(image, data, pdf417WriteOptions); // Write the barcode
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "MyDriversLicense.png"), RasterImageFormat.Png, 1); // write the output to file
}
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Barcode
Public Sub AAMVA_Example()
RasterSupport.SetLicense("C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC", File.ReadAllText("C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC.KEY"))
Const JURISDICTION_VERSION As String = "00"
Const SUBFILE_TYPE_CODE As String = "DL"
Const SUBFILES_COUNT As Integer = 1
Const BITS_PER_PIXEL As Integer = 24
Const IMAGE_DPI As Integer = 300
Dim barcodeEngine As BarcodeEngine = New BarcodeEngine()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim driversLicenseID As AAMVAID = Nothing
Dim birthday As DateTime = New DateTime(DateTime.Now.Year - 16, DateTime.Now.Month, DateTime.Now.Day)
Dim driversLicenseData As String(,) = New String(,) {{"DDF", "N"},
{"DDE", "N"},
{"DCG", "USA"},
{"DCF", "NONE"},
{"DAQ", "1234567890"},
{"DAK", "123456 "},
{"DAJ", "PA"},
{"DAI", "Any Town"},
{"DAG", "123 Main Street"},
{"DAU", "072 in"},
{"DAY", "BRO"},
{"DBC", "1"},
{"DBB", birthday.ToString("MMddyyyy")},
{"DBD", DateTime.Now.ToString("MMddyyyy")},
{"DAD", "NONE"}, {"DAC", "John"},
{"DCS", "Doe"},
{"DBA", DateTime.Now.AddYears(6).ToString("MMddyyyy")},
{"DCD", "M"}, {"DCB", "NONE"},
{"DCA", "C"},
{"DDJ", birthday.AddYears(21).ToString("MMddyyyy")},
{"DDI", birthday.AddYears(19).ToString("MMddyyyy")},
{"DDH", birthday.AddYears(18).ToString("MMddyyyy")},
{"DAZ", "BRO"}} ' Hair color
Using builder As AAMVAIDBuilder = New AAMVAIDBuilder()
builder.SetJurisdiction(AAMVAJurisdiction.Pennsylvania, AAMVAID.LookupIssuerIdentificationNumber(AAMVAJurisdiction.Pennsylvania))
builder.SetVersion(AAMVAVersion.Version2016)
builder.SetJurisdictionVersion(JURISDICTION_VERSION)
builder.SetNumberOfEntries(SUBFILES_COUNT)
builder.SetSubfileType(SUBFILES_COUNT - 1, AAMVASubfileType.DL, SUBFILE_TYPE_CODE)
Dim i As Integer = 0
Do While i < driversLicenseData.GetLength(0)
builder.AddDataElementToSubfile(0, driversLicenseData(i, 0), driversLicenseData(i, 1))
i += 1
Loop
driversLicenseID = builder.Build()
End Using
Dim data As PDF417BarcodeData = New PDF417BarcodeData()
data.Symbology = BarcodeSymbology.PDF417
data.SetData(driversLicenseID.GetBytes())
Dim pdf417WriteOptions As PDF417BarcodeWriteOptions = CType(barcodeEngine.Writer.GetDefaultOptions(BarcodeSymbology.PDF417), PDF417BarcodeWriteOptions)
'Refer to AAMVA CDS 2016 Section D.3 thru D.11.2
'Must range from 0.0066 to 0.015 inches
pdf417WriteOptions.XModule = 15 '0.015
'Must >= 3
pdf417WriteOptions.XModuleAspectRatio = 3
'Error level must be at least 3, 5 is recommended
pdf417WriteOptions.ECCLevel = PDF417BarcodeECCLevel.Level5
'Default WidthAspectRatio is 2:1. 4:1 looks similar to ID barcodes in the wild
pdf417WriteOptions.SymbolWidthAspectRatio = 4
'Default quiet zone for PDF417 is 2 * XModule
barcodeEngine.Writer.CalculateBarcodeDataBounds(LeadRect.Empty, IMAGE_DPI, IMAGE_DPI, data, pdf417WriteOptions)
Using image As RasterImage = RasterImage.Create(data.Bounds.Width, data.Bounds.Height, BITS_PER_PIXEL, IMAGE_DPI, New RasterColor(255, 255, 255))
barcodeEngine.Writer.WriteBarcode(image, data, pdf417WriteOptions) ' Write the barcode
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "MyDriversLicense.png"), RasterImageFormat.Png, 1) ' write the output to file
End Using
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
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