ID Scanning Examples
Complete examples for ID scanning (Universal ID & MRZ) with the Anyline Web SDK.
| The Web SDK supports MRZ documents (passports, ID cards with MRZ), European driving licenses (Austria, Croatia, Germany, Italy, Portugal, Spain), and European identity cards (Italy, Portugal, Spain). Only Latin characters are supported. |
MRZ (Passports & ID Cards)
Scan passports and ID cards with Machine Readable Zones:
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'universalid_mrz'
});
anyline.onResult = ({ result }) => {
console.log('MRZ Result:', result.mrzResult);
};
anyline.startScanning();
Available preset: universalid_mrz
Driving License - Austria & Germany
Scan Austrian and German driving licenses:
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'universalid_dl_at_de'
});
anyline.onResult = ({ result }) => {
console.log('Universal ID Result:', result.universalIdResult);
};
anyline.startScanning();
Available presets:
-
universalid_dl_at_de- Standard scanning -
universalid_dl_at_de_strict- Stricter validation thresholds
Driving License & ID Card - Southern Europe
Scan Spanish, Italian, Portuguese, and Croatian documents:
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'universalid_es_it_pt'
});
anyline.onResult = ({ result }) => {
console.log('Universal ID Result:', result.universalIdResult);
};
anyline.startScanning();
Available preset: universalid_es_it_pt
Custom Configuration
MRZ with Strict Mode
Configure MRZ scanning with strict validation and mandatory fields:
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'universalid_mrz',
config: {
mrzConfig: {
strictMode: true,
minConfidence: 75,
cropAndTransformID: true,
mrzFieldScanOptions: {
surname: 'mandatory',
givenNames: 'mandatory',
documentNumber: 'mandatory',
dateOfBirth: 'mandatory',
dateOfExpiry: 'mandatory',
personalNumber: 'optional'
}
},
cancelOnResult: true
}
});
anyline.onResult = ({ result }) => {
console.log('MRZ Result:', result.mrzResult);
};
anyline.startScanning();
Filter Specific Document Layouts
Restrict scanning to specific document layouts:
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'universalid_es_it_pt',
config: {
universalIdConfig: {
allowedLayouts: {
drivingLicense: ['ES_DVL_O_06001_F'],
idFront: ['ES_IDC_O_05001_F']
}
}
}
});
anyline.onResult = ({ result }) => {
console.log('Universal ID Result:', result.universalIdResult);
};
anyline.startScanning();
| For optimal performance and accuracy, specify exact document layouts rather than enabling all layouts with an empty array. |
Mandatory Field Validation
Configure specific fields as mandatory with minimum confidence thresholds:
import { init } from '@anyline/anyline-js';
const anyline = init({
license: 'YOUR_LICENSE_KEY',
element: document.getElementById('scanner-root'),
preset: 'universalid_dl_at_de',
config: {
universalIdConfig: {
allowedLayouts: {
drivingLicense: ['AT_DVL_O_04001_F', 'DE_DVL_O_02007_F']
},
drivingLicense: {
lastName: { scanOption: 'mandatory', minConfidence: 80 },
firstName: { scanOption: 'mandatory', minConfidence: 80 },
dateOfBirth: { scanOption: 'mandatory', minConfidence: 80 },
documentNumber: { scanOption: 'mandatory', minConfidence: 80 }
}
},
cancelOnResult: true
}
});
anyline.onResult = ({ result }) => {
console.log('Universal ID Result:', result.universalIdResult);
};
anyline.startScanning();
Configuration Reference
For detailed information about all configuration parameters including universalIdConfig, mrzConfig, field configuration options, and their default values, see Universal ID Technical Capabilities and MRZ Technical Capabilities.
Result Structure
For the complete result structure, see the Plugin Result JSON Schema.
See Also
-
Universal ID Technical Capabilities - Complete Universal ID configuration
-
MRZ Technical Capabilities - Complete MRZ configuration
-
General Examples - Common SDK examples
-
API Reference - Complete API documentation
-
Plugin Configuration - Configuration options
-
Getting Started - Getting started guide