Search Results for

    Show / Hide Table of Contents

    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
    System.Object
    PassportInfo
    Implements
    System.IEquatable<PassportInfo>
    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

    Implements

    System.IEquatable<>
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    IronOCR_for_dotnet_log2o
    Blue key in circleGet started for FREE
    No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet started for FREE
    The trial form was submitted successfully.
    Calendar in circleBook Free Live Demo
    No contact, no card details, no commitments Book a 30-minute, personal demo.
    Here's what to expect:

    A live demo of our product and its key features

    Get project specific feature recommendations

    All your questions are answered to make sure you have all the information you need. (No commitment whatsoever.)

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation
    Support Team Member 6 related to The C# PDF Library Support Team Member 14 related to The C# PDF Library Support Team Member 4 related to The C# PDF Library Support Team Member 2 related to The C# PDF Library
    Online 24/5
    Need help? Our sales team would be glad to help you.
    Try the Enterprise Trial
    ironpdf_for_dotnet_log2o
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    bullet_checkedNo credit card or account creation required
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    Blue key in circleNo credit card or account creation required
    Green Check in orange circle
    The trial form was submitted successfully.
    badge_greencheck_in_yellowcircle
    Thank you for starting a trial

    Please check your email for the trial license key.

    If you don’t receive an email, please start a live chat or email support@ironsoftware.com

    Install with NuGet
    View Licensing
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronOCR