Extract Data from PDF417 of Driver Licenses

scan drivers license barcode

According to the Card Design Standard by AAMVA, the PDF417 two-dimensional bar code symbology is the minimum mandatory machine-readable technology that must be present on compliant driving license/identification documents. The barcode encodes key information about the cardholder, including name, date of birth, sex, eye color, height and many others.

There are two ways to extract data from a driver license for a machine:

  • Using OCR technology to recognize the characters printed on an ID
  • Use barcode recognition technology to decode the PDF417 symbology and then parse it into human-readable formats

Generally speaking, the latter is more accurate and cost-effective than the former.

In this article, we discuss how to use Dynamsoft Barcode Reader SDK for text extraction from a driver license.

Online Demo: Read PDF417 from Images

To see how this works, you can give it a try at the online demo – Reading PDF417 Barcode on Driver’s License here.

free online document scan

Please note that this demo also features document scanning, which is powered by Dynamsoft’s Web TWAIN SDK.

How to Extract Data from PDF417 of Driver Licenses

Step 1. Detect and decode the PDF417 code

var barcodeImage = DWObject.GetImageURL(index, -1, -1);
dbrObject.readURLAsync(barcodeImage,
	index,
	GetBarcodeInfo,
	OnBarcodeReadFailure);
function OnBarcodeReadFailure(sImageIndex, errorCode, errorString) {
	console.log(errorString);
}
function GetBarcodeInfo(sImageIndex, result) {//This is the function called when barcode is read successfully
	//Retrieve barcode details
	var count = result.getCount();
	if (count == 0) {
		alert("The barcode for the selected format is not found.");
		return;
	} else {
		for (i = 0; i < count; i++) {
			Barcode_text = result.get(i).text;
			var x = result.get(i).x1;
			var y = result.get(i).y1;
			var format = result.get(i).formatString;
			var barcodeText = ("barcode[" + (i + 1) + "]: " + "\n" + Barcode_text + "\n");
			extractInformation();
		}
	}
}

Step 2. Parse it into a human-readable format

driverLicenseFields = [
		{ 'abbreviation': 'DAA', 'description': 'Full Name' }
		, { 'abbreviation': 'DAB', 'description': 'Last Name' }
		, { 'abbreviation': 'DAB', 'description': 'Family Name' }
		, { 'abbreviation': 'DAC', 'description': 'First Name' }
		, { 'abbreviation': 'DAC', 'description': 'Given Name' }
		, { 'abbreviation': 'DAD', 'description': 'Middle Name or Initial' }
		, { 'abbreviation': 'DAD', 'description': 'Middle Name' }
		, { 'abbreviation': 'DAE', 'description': 'Name Suffix' }
		, { 'abbreviation': 'DAF', 'description': 'Name Prefix' }
		, { 'abbreviation': 'DAG', 'description': 'Mailing Street Address1' }
		, { 'abbreviation': 'DAH', 'description': 'Mailing Street Address2' }
		, { 'abbreviation': 'DAI', 'description': 'Mailing City' }
		, { 'abbreviation': 'DAJ', 'description': 'Mailing Jurisdiction Code' }
		, { 'abbreviation': 'DAK', 'description': 'Mailing Postal Code' }
		, { 'abbreviation': 'DAL', 'description': 'Residence Street Address1' }
		, { 'abbreviation': 'DAM', 'description': 'Residence Street Address2' }
		, { 'abbreviation': 'DAN', 'description': 'Residence City' }
		, { 'abbreviation': 'DAO', 'description': 'Residence Jurisdiction Code' }
		, { 'abbreviation': 'DAP', 'description': 'Residence Postal Code' }
		, { 'abbreviation': 'DAQ', 'description': 'License or ID Number' }
		, { 'abbreviation': 'DAR', 'description': 'License Classification Code' }
		, { 'abbreviation': 'DAS', 'description': 'License Restriction Code' }
		, { 'abbreviation': 'DAT', 'description': 'License Endorsements Code' }
		, { 'abbreviation': 'DAU', 'description': 'Height in FT_IN' }
		, { 'abbreviation': 'DAV', 'description': 'Height in CM' }
		, { 'abbreviation': 'DAW', 'description': 'Weight in LBS' }
		, { 'abbreviation': 'DAX', 'description': 'Weight in KG' }
		, { 'abbreviation': 'DAY', 'description': 'Eye Color' }
		, { 'abbreviation': 'DAZ', 'description': 'Hair Color' }
		, { 'abbreviation': 'DBA', 'description': 'License Expiration Date' }
		, { 'abbreviation': 'DBB', 'description': 'Date of Birth' }
		, { 'abbreviation': 'DBC', 'description': 'Sex' }
		, { 'abbreviation': 'DBD', 'description': 'License or ID Document Issue Date' }
		, { 'abbreviation': 'DBE', 'description': 'Issue Timestamp' }
		, { 'abbreviation': 'DBF', 'description': 'Number of Duplicates' }
		, { 'abbreviation': 'DBG', 'description': 'Medical Indicator Codes' }
		, { 'abbreviation': 'DBH', 'description': 'Organ Donor' }
		, { 'abbreviation': 'DBI', 'description': 'Non-Resident Indicator' }
		, { 'abbreviation': 'DBJ', 'description': 'Unique Customer Identifier' }
		, { 'abbreviation': 'DBK', 'description': 'Social Security Number' }
		, { 'abbreviation': 'DBL', 'description': 'Date Of Birth' }
		, { 'abbreviation': 'DBM', 'description': 'Social Security Number' }
		, { 'abbreviation': 'DBN', 'description': 'Full Name' }
		, { 'abbreviation': 'DBO', 'description': 'Last Name' }
		, { 'abbreviation': 'DBO', 'description': 'Family Name' }
		, { 'abbreviation': 'DBP', 'description': 'First Name' }
		, { 'abbreviation': 'DBP', 'description': 'Given Name' }
		, { 'abbreviation': 'DBQ', 'description': 'Middle Name' }
		, { 'abbreviation': 'DBQ', 'description': 'Middle Name or Initial' }
		, { 'abbreviation': 'DBR', 'description': 'Suffix' }
		, { 'abbreviation': 'DBS', 'description': 'Prefix' }
		, { 'abbreviation': 'DCA', 'description': 'Virginia Specific Class' }
		, { 'abbreviation': 'DCB', 'description': 'Virginia Specific Restrictions' }
		, { 'abbreviation': 'DCD', 'description': 'Virginia Specific Endorsements' }
		, { 'abbreviation': 'DCE', 'description': 'Physical Description Weight Range' }
		, { 'abbreviation': 'DCF', 'description': 'Document Discriminator' }
		, { 'abbreviation': 'DCG', 'description': 'Country territory of issuance' }
		, { 'abbreviation': 'DCH', 'description': 'Federal Commercial Vehicle Codes' }
		, { 'abbreviation': 'DCI', 'description': 'Place of birth' }
		, { 'abbreviation': 'DCJ', 'description': 'Audit information' }
		, { 'abbreviation': 'DCK', 'description': 'Inventory Control Number' }
		, { 'abbreviation': 'DCL', 'description': 'Race Ethnicity' }
		, { 'abbreviation': 'DCM', 'description': 'Standard vehicle classification' }
		, { 'abbreviation': 'DCN', 'description': 'Standard endorsement code' }
		, { 'abbreviation': 'DCO', 'description': 'Standard restriction code' }
		, { 'abbreviation': 'DCP', 'description': 'Jurisdiction specific vehicle classification description' }
		, { 'abbreviation': 'DCQ', 'description': 'Jurisdiction-specific' }
		, { 'abbreviation': 'DCR', 'description': 'Jurisdiction specific restriction code description' }
		, { 'abbreviation': 'DCS', 'description': 'Family Name' }
		, { 'abbreviation': 'DCS', 'description': 'Last Name' }
		, { 'abbreviation': 'DCT', 'description': 'Given Name' }
		, { 'abbreviation': 'DCT', 'description': 'First Name' }
		, { 'abbreviation': 'DCU', 'description': 'Suffix' }
		, { 'abbreviation': 'DDA', 'description': 'Compliance Type' }
		, { 'abbreviation': 'DDB', 'description': 'Card Revision Date' }
		, { 'abbreviation': 'DDC', 'description': 'HazMat Endorsement Expiry Date' }
		, { 'abbreviation': 'DDD', 'description': 'Limited Duration Document Indicator' }
		, { 'abbreviation': 'DDE', 'description': 'Family Name Truncation' }
		, { 'abbreviation': 'DDF', 'description': 'First Names Truncation' }
		, { 'abbreviation': 'DDG', 'description': 'Middle Names Truncation' }
		, { 'abbreviation': 'DDH', 'description': 'Under 18 Until' }
		, { 'abbreviation': 'DDI', 'description': 'Under 19 Until' }
		, { 'abbreviation': 'DDJ', 'description': 'Under 21 Until' }
		, { 'abbreviation': 'DDK', 'description': 'Organ Donor Indicator' }
		, { 'abbreviation': 'DDL', 'description': 'Veteran Indicator' }
		, { 'abbreviation': 'PAA', 'description': 'Permit Classification Code' }
		, { 'abbreviation': 'PAB', 'description': 'Permit Expiration Date' }
		, { 'abbreviation': 'PAC', 'description': 'Permit Identifier' }
		, { 'abbreviation': 'PAD', 'description': 'Permit IssueDate' }
		, { 'abbreviation': 'PAE', 'description': 'Permit Restriction Code' }
		, { 'abbreviation': 'PAF', 'description': 'Permit Endorsement Code' }
		, { 'abbreviation': 'ZVA', 'description': 'Court Restriction Code' }
	]

Download the full sample

The full sample code is also available on the website. If you have any questions or comments, please feel free to contact us support@dynamsoft.com.

Mvi case study graphic

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.

Subscribename@email.com