generateTD1

fun generateTD1(documentType: String, issuingState: String, documentNumber: String, primaryIdentifier: String, secondaryIdentifier: String, nationality: String, dateOfBirth: LocalDate, sex: Sex, dateOfExpiry: LocalDate, optionalData1: String, optionalData2: String, transliteration: TransliterationProfile? = null): GenerationResult

Encodes a TD1 (identity card) MRZ from field values.

Joins the identifiers with <<, or uses only the primary if the secondary is empty, and replaces spaces with <. The name field holds up to 30 characters. Pads short fields with < and computes every check digit.

Return

GenerationResult.Success with the MRZ lines, or GenerationResult.Failure with MrzGenerationNumericInNameField, MrzGenerationUnsupportedCharacters, or MrzGenerationFieldOverflow. The result metadata holds the transliteration details when the profile processed a non-empty identifier.

Parameters

documentType

the document type code, up to 2 characters.

issuingState

the issuing state code, up to 3 characters.

documentNumber

the document number, up to 9 characters.

primaryIdentifier

the primary identifier (surname). Must not contain digits.

secondaryIdentifier

the secondary identifier (given names). Must not contain digits.

nationality

the nationality code, up to 3 characters.

dateOfBirth

the date of birth. Only the last two digits of the year are written.

sex

the sex. Sex.UNSPECIFIED is written as <.

dateOfExpiry

the date of expiry. Only the last two digits of the year are written.

optionalData1

the optional data on line 1, up to 15 characters.

optionalData2

the optional data on line 2, up to 11 characters.

transliteration

the profile that maps both identifiers to the MRZ alphabet, or null to use them as given. Defaults to null.