Class PassportInfo
Passport info struct containing all fields decoded from the ICAO 9303 MRZ (Machine Readable Zone) and, where available, the VIZ (Visual Inspection Zone).
MRZ fields (machine-extracted, highly reliable): DocumentType, Surname, GivenNames, PassportNumber, Country / IssuingCountryCode, Nationality / NationalityCode, DateOfBirth, Gender, DateOfExpiry, PersonalNumber.
VIZ fields (best-effort from full OCR text, may be empty): DateOfIssue.
Raw codes vs mapped names: Properties like Country and Nationality return English names mapped from ISO 3166-1 alpha-3. For custom localization, use the raw codes IssuingCountryCode and NationalityCode to perform your own mapping.
Inheritance
Implements
Namespace: IronOcr
Assembly: IronOcr.dll
Syntax
public sealed class PassportInfo : ValueType, IEquatable<PassportInfo>
Constructors
PassportInfo(String, String, String, String, String, String)
Initializes a new instance of the PassportInfo struct with the core MRZ fields.
This constructor is preserved for binary compatibility with existing compiled code.
Declaration
public PassportInfo(string surname, string givenName, string passportNumber, string country, string dateOfBirth, string dateOfExpiry)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | surname | Holder's surname. |
| System.String | givenName | Holder's given name(s). |
| System.String | passportNumber | Passport number. |
| System.String | country | Issuing state/country English name. |
| System.String | dateOfBirth | Date of birth formatted as yyyy-MM-dd. |
| System.String | dateOfExpiry | Expiry date formatted as yyyy-MM-dd. |
PassportInfo(String, String, String, String, String, String, Gender, String, String, String, String, String, String)
Initializes a new instance of the PassportInfo struct with all MRZ and VIZ decoded fields.
Declaration
public PassportInfo(string surname, string givenName, string passportNumber, string country, string dateOfBirth, string dateOfExpiry, Gender gender, string documentType, string nationality, string personalNumber, string dateOfIssue, string issuingCountryCode, string nationalityCode)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | surname | Holder's surname decoded from MRZ first row. |
| System.String | givenName | Holder's given name(s) decoded from MRZ first row. |
| System.String | passportNumber | Passport number from MRZ second row, positions 1-9. |
| System.String | country | Issuing state/country English name, mapped from MRZ first row positions 3-5. |
| System.String | dateOfBirth | Date of birth formatted as yyyy-MM-dd. |
| System.String | dateOfExpiry | Expiry date formatted as yyyy-MM-dd. |
| Gender | gender | Gender extracted from MRZ second row position 21. |
| System.String | documentType | Document type from MRZ first row positions 1-2 (e.g. "P", "PS"). |
| System.String | nationality | Holder's nationality English name, mapped from MRZ second row positions 11-13. |
| System.String | personalNumber | Optional personal/national ID number from MRZ second row positions 29-42. |
| System.String | dateOfIssue | Date of issue in yyyy-MM-dd format, extracted from VIZ (not in MRZ). |
| System.String | issuingCountryCode | Raw ISO 3166-1 alpha-3 code of the issuing state (e.g. "HRV", "USA"). |
| System.String | nationalityCode | Raw ISO 3166-1 alpha-3 code of the holder's nationality (e.g. "HRV", "USA"). |
Fields
Empty
A default empty PassportInfo with all string fields initialized to empty strings.
Declaration
public static readonly PassportInfo Empty
Field Value
| Type | Description |
|---|---|
| PassportInfo |
InvalidCountryCodePrefix
Prefix used in Country and Nationality when a country code from the MRZ could not be resolved to a known country name.
Example value: "Invalid country code (XYZ)".
Usage: if (info.Country.StartsWith(PassportInfo.InvalidCountryCodePrefix)) { ... }
Declaration
public const string InvalidCountryCodePrefix = "Invalid country code"
Field Value
| Type | Description |
|---|---|
| System.String |
Properties
Country
Issuing state/country English name, mapped from the three-letter country code (ISO 3166-1 alpha-3).
This is the country that issued the passport. For the holder's nationality, see Nationality.
For the raw ISO alpha-3 code (e.g. "HRV", "USA"), see IssuingCountryCode.
Declaration
public string Country { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
DateOfBirth
Holder's date of birth in yyyy-MM-dd format.
Returns an empty string if the date could not be parsed from the MRZ.
Declaration
public string DateOfBirth { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
DateOfExpiry
Passport expiry date in yyyy-MM-dd format.
Returns an empty string if the date could not be parsed from the MRZ.
Declaration
public string DateOfExpiry { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
DateOfIssue
Passport issue date in yyyy-MM-dd format.
Note: This field is not part of the ICAO 9303 MRZ. It is extracted on a best-effort basis from the VIZ (Visual Inspection Zone) — the human-readable printed area of the passport.
Returns an empty string if extraction was not successful.
Declaration
public string DateOfIssue { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
DocumentType
Document type indicator.
Typically "P" for a standard passport. The second character may indicate a subtype, e.g. "PD" for diplomatic passport, "PS" for service passport, or only "P" if no subtype.
Declaration
public string DocumentType { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Gender
Holder's Gender/sex.
'M' = Male, 'F' = Female, 'X' or '<' = Unspecified.
Declaration
public Gender Gender { get; }
Property Value
| Type | Description |
|---|---|
| Gender |
GivenNames
Holder's given name(s).
Multiple given names are separated by spaces.
Declaration
public string GivenNames { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
IssuingCountryCode
Raw ISO 3166-1 alpha-3 code of the issuing state (e.g. "HRV", "USA", "GBR").
Use this for custom localization or when you need the standard code rather than the English name from Country.
Declaration
public string IssuingCountryCode { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Nationality
Holder's nationality English name, mapped from the three-letter code (ISO 3166-1 alpha-3).
This may differ from Country (the issuing state) for dual citizens or diplomatic passports.
For the raw ISO alpha-3 code (e.g. "HRV", "USA"), see NationalityCode.
Declaration
public string Nationality { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
NationalityCode
Raw ISO 3166-1 alpha-3 code of the holder's nationality (e.g. "HRV", "USA", "GBR").
Use this for custom localization or when you need the standard code rather than the English name from Nationality.
Declaration
public string NationalityCode { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
PassportNumber
Unique passport number.
Declaration
public string PassportNumber { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
PersonalNumber
Optional personal number (typically a national ID number).
This field is optional per ICAO 9303. Returns an empty string if not present or filled with '<' characters.
Declaration
public string PersonalNumber { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Surname
Holder's surname (family name).
Declaration
public string Surname { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
Equals(PassportInfo)
Declaration
public bool Equals(PassportInfo others)
Parameters
| Type | Name | Description |
|---|---|---|
| PassportInfo | others |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Operators
Equality(PassportInfo, PassportInfo)
Equality operator.
Declaration
public static bool operator ==(PassportInfo left, PassportInfo right)
Parameters
| Type | Name | Description |
|---|---|---|
| PassportInfo | left | |
| PassportInfo | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Inequality(PassportInfo, PassportInfo)
Inequality operator.
Declaration
public static bool operator !=(PassportInfo left, PassportInfo right)
Parameters
| Type | Name | Description |
|---|---|---|
| PassportInfo | left | |
| PassportInfo | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |