Decode US Driver License PDF417 Barcodes with C# / .NET
Call a deterministic PDF417 and AAMVA API from C# / .NET, return structured identity fields, and reject unreadable barcodes without AI guessing.
Why US Driver License PDF417 Decoding Needs a Dedicated Pipeline
The barcode on the back of a US driver license is not ordinary printed text. PDF417 uses stacked rows, error correction, and a structured AAMVA payload. Glare, blur, perspective, small barcodes, and partial cropping can prevent a reliable decode. General OCR and generative vision models may produce plausible-looking identity fields, but they cannot prove those values came from a valid barcode payload.
A Deterministic PDF417 API for C# / .NET
Send a JPG, PNG, or WebP image to the US driver license PDF417 API. StructOCR locates and decodes the barcode, validates the result, parses AAMVA elements, and returns normalized JSON. Try the workflow first in the free PDF417 scanner.
Production Use Cases
- US Customer Onboarding: Pre-fill identity and address fields from an AAMVA-compliant license-back barcode.
- Rental and Fleet Intake: Capture license number, class, restrictions, endorsements, and expiration date.
- Quality-Control Queues: Route 422 responses to a retake flow instead of accepting guessed identity data.
Implementation: C# / .NET REST Request
Read the license-back image, Base64 encode it, send it with the x-api-key header, and treat HTTP 422 as a request for a clearer image.
Prerequisite: .NET 8+ with `System.Net.Http.Json`
using System.Net.Http.Json;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
http.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("STRUCTOCR_API_KEY"));
var image = await File.ReadAllBytesAsync("license-back.jpg");
var payload = new { img = Convert.ToBase64String(image) };
using var response = await http.PostAsJsonAsync("https://api.structocr.com/v1/driver-license-pdf417", payload);
var body = await response.Content.ReadAsStringAsync();
using var result = JsonDocument.Parse(body);
if ((int)response.StatusCode == 422)
{
Console.WriteLine("Retake image: " + result.RootElement.GetProperty("error").GetString());
}
else
{
response.EnsureSuccessStatusCode();
var data = result.RootElement.GetProperty("data");
Console.WriteLine("License: " + data.GetProperty("document_number").GetString());
Console.WriteLine("DOB: " + data.GetProperty("date_of_birth").GetString());
Console.WriteLine("AAMVA: " + data.GetProperty("aamva_version").GetInt32());
}Technical Specs
- •Endpoint: POST https://api.structocr.com/v1/driver-license-pdf417
- •Authentication: x-api-key request header
- •Inputs: JPG, PNG, or WebP; Base64 JSON or multipart upload
- •Maximum file size: 4.5MB
- •Price: 2 credits for a successful decode; processing failures are refunded
- •Output: Structured AAMVA JSON; raw barcode payload is not returned
Key Features
- •No AI guessing: Identity fields come from a decoded PDF417 payload and AAMVA parser.
- •Explicit retake flow: Handle PDF417_NOT_DECODED as a 422 response and ask for a clear, glare-free image.
- •AAMVA validation: AAMVA_NOT_VALID distinguishes a readable non-license barcode from a usable driver-license record.
- •Normalized dates: Birth, issue, and expiration dates use YYYY-MM-DD when available.
Sample AAMVA JSON Output
The example uses fictional values. Optional AAMVA elements return null when absent.
{
"success": true,
"data": {
"type": "drivers_license",
"source": "pdf417",
"country_code": "USA",
"region": "CA",
"document_number": "SAMPLE1234",
"surname": "SAMPLE",
"given_names": "ALEX MORGAN",
"first_name": "ALEX",
"middle_name": "MORGAN",
"sex": "F",
"date_of_birth": "1990-01-15",
"date_of_issue": "2025-01-15",
"date_of_expiry": "2030-01-15",
"address": "100 EXAMPLE AVE",
"city": "SAMPLE CITY",
"postal_code": "90001",
"vehicle_class": "C",
"restrictions": "NONE",
"endorsements": "NONE",
"document_discriminator": "SAMPLE-DISCRIMINATOR",
"issuer_identification_number": "636000",
"aamva_version": 10,
"jurisdiction_version": 0
}
}Frequently Asked Questions
Can C# / .NET decode a PDF417 barcode without a local barcode library?
Yes. Your application only needs to send the image to the REST endpoint and parse JSON. PDF417 decoding and AAMVA parsing run in the StructOCR service.
What should my application do with PDF417_NOT_DECODED?
Treat HTTP 422 as a recoverable capture problem. Ask the user to retake the back of the license with the full barcode visible, sharp, and free from glare. Processing failures are refunded.
Is this the same as front-side driver license OCR?
No. This endpoint is dedicated to PDF417 barcodes on the back of US driver licenses and State IDs. Use the Driver License OCR API for visible printed fields and international license formats.
You May Also Like
Related tutorials, platform guides, and comparisons
C# Driver's License OCR API
Upload an image for a free test! High-accuracy C# Driver's License OCR API. Get structured JSON output from images, parse PDF417 barcodes, and eliminate manual entry errors.
New York Driver License OCR: Extract Fields with Python
Extract visible fields from New York driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.
Idaho Driver License OCR: Extract Fields with Python
Extract visible fields from Idaho driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.
Brazil Driver License OCR with Node.js SDK
Extract structured fields from a Brazil Carteira Nacional de Habilitação (CNH) with the StructOCR Node.js SDK and TypeScript + Express.
Philippines Driver License OCR with Python SDK
Extract structured fields from a Philippines LTO driver's license with the StructOCR Python SDK and FastAPI.
Canada Driver License OCR with Node.js SDK
Extract structured fields from a Canada provincial driver licence with the StructOCR Node.js SDK and TypeScript + Express.
Canada Driver License OCR with Python SDK
Extract structured fields from a Canada provincial driver licence with the StructOCR Python SDK and FastAPI.
Philippines Driver License OCR with Node.js SDK
Extract structured fields from a Philippines LTO driver's license with the StructOCR Node.js SDK and TypeScript + Express.
Go Driver License OCR API
Upload an image for a free test! Struggling with manual driver's license data entry? Our Go API delivers structured JSON in seconds, with SOC 2 Type II and AES-256 encryption.
C# Vehicle Registration OCR API
C# Vehicle Registration OCR API tutorial. Upload an image for a free test! Accurately extract standardized fields like VIN, make, and model, along with dynamically localized data for global documents.
Go US Driver License PDF417 API Tutorial
Decode US driver license PDF417 barcodes with Go. Send a license-back image, parse AAMVA fields, and handle unreadable barcode errors safely.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Driver's License OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Bolt.new app. Build car rental and mobility onboarding flows right in your browser.
Add Driver's License OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API using the Cursor AI code editor. Build car rental and mobility onboarding flows rapidly.
Add Driver's License OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Lovable.dev app. Build car rental and mobility onboarding flows with zero backend.
Add Driver's License OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Replit application. Build car rental and mobility onboarding flows using Replit Agent and Secrets.
Add Driver's License OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a v0 by Vercel app. Build car rental and mobility onboarding flows with zero backend.
Heavy KYC SDKs vs. StructOCR Passport API for Mobile Apps
Discover why modern app developers are abandoning bulky on-device OCR SDKs in favor of lightweight, edge-deployed Passport APIs.
From tutorial to production in 5 minutes.
You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.