generate

fun generate(@ObjCName(name = "document") document: MrzDocument): GenerationResult

Encodes a document of any format as MRZ lines.

Pads short fields with < and computes every check digit; the check digits stored in the document are not used. Checks that the name field has no digit, then the width and characters of the document type, issuing state, name field, document number, nationality, optional data, and each date part, then the sex character. A date part must be exactly 2 characters; a shorter one is never padded, because < in a date means "unknown". The sex character rawSex must be M, F, or <: ICAO Doc 9303 allows X only in the visual zone, so X fails too. This overload applies no transliteration profile: the name field must already be in the MRZ alphabet. To convert a name field in the source script, use the overload that takes a TransliterationProfile.

In Swift this is generate(document:), and the overloads for one format are generate(td3:), generate(td2:), generate(td1:), generate(mrvA:), and generate(mrvB:).

Return

GenerationResult.Success with the MRZ lines, or GenerationResult.Failure with MrzGenerationNumericInNameField, MrzGenerationFieldOverflow, MrzGenerationFieldTooShort, MrzGenerationUnsupportedCharacters, or MrzGenerationInvalidSexValue.

Parameters

document

the document to encode.


fun generate(@ObjCName(name = "td3") document: TD3): GenerationResult

Encodes a TD3 (passport) document as 2 MRZ lines. Reports as generate does.


fun generate(@ObjCName(name = "td2") document: TD2): GenerationResult

Encodes a TD2 document as 2 MRZ lines. Reports as generate does.


fun generate(@ObjCName(name = "td1") document: TD1): GenerationResult

Encodes a TD1 (identity card) document as 3 MRZ lines. Reports as generate does.


fun generate(@ObjCName(name = "mrvA") document: MrvA): GenerationResult

Encodes an MRV-A (Type-A visa) document as 2 MRZ lines. Reports as generate does.


fun generate(@ObjCName(name = "mrvB") document: MrvB): GenerationResult

Encodes an MRV-B (Type-B visa) document as 2 MRZ lines. Reports as generate does.


fun generate(@ObjCName(name = "document") document: MrzDocument, transliteration: TransliterationProfile): GenerationResult

Encodes a document of any format as MRZ lines, converting its name field with a profile first.

Checks that the raw name field has no digit, then runs transliteration over the whole raw name field, and then encodes the document with the converted name field as the one-argument generate(document) does, with the same checks. Only the raw name field is converted; every other field must already be in the MRZ alphabet. A converted name field can be longer than the original (the AZE profile writes SH for Ş), so it can overflow its field.

Pass a profile only when the name field holds the name in its source script, for example Ş or Ü. Never pass one for a document that came from parsing an MRZ: a profile may also change letters that are already in the MRZ alphabet. The AZE profile maps J to ZH, C to J, X to KH, and Q to G. A parsed name field keeps its < filler and fills its whole width, so a parsed name would change (C becomes J) or no longer fit (J becomes ZH).

In Swift this is generate(document:transliteration:), and the overloads for one format are generate(td3:transliteration:), generate(td2:transliteration:), generate(td1:transliteration:), generate(mrvA:transliteration:), and generate(mrvB:transliteration:).

Return

GenerationResult.Success with the MRZ lines, or GenerationResult.Failure with MrzGenerationNumericInNameField (checked before the profile runs), MrzGenerationUnsupportedCharacters (also when the profile cannot map a character), MrzGenerationFieldOverflow, MrzGenerationFieldTooShort, or MrzGenerationInvalidSexValue. When the profile ran on a non-empty name field, the result metadata holds the transliteration details: one entry for the whole raw name field.

Since

0.6.0

Parameters

document

the document to encode.

transliteration

the profile that maps the raw name field to the MRZ alphabet.


fun generate(@ObjCName(name = "td3") document: TD3, transliteration: TransliterationProfile): GenerationResult

Encodes a TD3 (passport) document as 2 MRZ lines, converting its name field with a profile first. Works and reports as the MrzDocument overload with a profile does.

Since

0.6.0


fun generate(@ObjCName(name = "td2") document: TD2, transliteration: TransliterationProfile): GenerationResult

Encodes a TD2 document as 2 MRZ lines, converting its name field with a profile first. Works and reports as the MrzDocument overload with a profile does.

Since

0.6.0


fun generate(@ObjCName(name = "td1") document: TD1, transliteration: TransliterationProfile): GenerationResult

Encodes a TD1 (identity card) document as 3 MRZ lines, converting its name field with a profile first. Works and reports as the MrzDocument overload with a profile does.

Since

0.6.0


fun generate(@ObjCName(name = "mrvA") document: MrvA, transliteration: TransliterationProfile): GenerationResult

Encodes an MRV-A (Type-A visa) document as 2 MRZ lines, converting its name field with a profile first. Works and reports as the MrzDocument overload with a profile does.

Since

0.6.0


fun generate(@ObjCName(name = "mrvB") document: MrvB, transliteration: TransliterationProfile): GenerationResult

Encodes an MRV-B (Type-B visa) document as 2 MRZ lines, converting its name field with a profile first. Works and reports as the MrzDocument overload with a profile does.

Since

0.6.0