IRONSOFTWAREHOME
Read Passport
using IronOcr;
using System;

// Instantiate OCR engine
var ocr = new IronTesseract();

using var inputPassport = new OcrInput();

inputPassport.LoadImage("passport.jpg");

// Perform OCR
OcrPassportResult result = ocr.ReadPassport(inputPassport);

// Output passport information
Console.WriteLine(result.PassportInfo.GivenNames);
Console.WriteLine(result.PassportInfo.Country);
Console.WriteLine(result.PassportInfo.PassportNumber);
Console.WriteLine(result.PassportInfo.Surname);
Console.WriteLine(result.PassportInfo.DateOfBirth);
Console.WriteLine(result.PassportInfo.DateOfExpiry);
Console.WriteLine(result.PassportInfo.Gender);
Console.WriteLine(result.PassportInfo.DocumentType);
Console.WriteLine(result.PassportInfo.Nationality);
Console.WriteLine(result.PassportInfo.NationalityCode);
Console.WriteLine(result.PassportInfo.IssuingCountryCode);
Console.WriteLine(result.PassportInfo.PersonalNumber);
Console.WriteLine(result.PassportInfo.DateOfIssue);
Imports IronOcr

' Instantiate OCR engine
Dim ocr As New IronTesseract()

Using inputPassport As New OcrInput()
    
    inputPassport.LoadImage("passport.jpg")
    
    ' Perform OCR
    Dim result As OcrPassportResult = ocr.ReadPassport(inputPassport)

    ' Output passport information
    Console.WriteLine(result.PassportInfo.GivenNames)
    Console.WriteLine(result.PassportInfo.Country)
    Console.WriteLine(result.PassportInfo.PassportNumber)
    Console.WriteLine(result.PassportInfo.Surname)
    Console.WriteLine(result.PassportInfo.DateOfBirth)
    Console.WriteLine(result.PassportInfo.DateOfExpiry)
    Console.WriteLine(result.PassportInfo.Gender)
    Console.WriteLine(result.PassportInfo.DocumentType)
    Console.WriteLine(result.PassportInfo.Nationality)
    Console.WriteLine(result.PassportInfo.NationalityCode)
    Console.WriteLine(result.PassportInfo.IssuingCountryCode)
    Console.WriteLine(result.PassportInfo.PersonalNumber)
    Console.WriteLine(result.PassportInfo.DateOfIssue)

End Using
NuGet Download
PM > Install-Package IronOcr
Read Passport

Read Passport

This code example demonstrates how to use the IronTesseract OCR engine to extract and process passport information from an image.

The IronTesseract OCR engine is instantiated. An OcrInput object is created to load the image containing the passport ("passport.jpg") using the LoadImage method. The ReadPassport method is used to process the image and extract passport information, returning an OcrPassportResult object that contains details like the given names, surname, country, passport number, date of birth, and date of expiry. The extracted passport information is then outputted to the console:

  • The given names are accessed through result.PassportInfo.GivenNames.
  • The country is retrieved using result.PassportInfo.Country.
  • The passport number is available via result.PassportInfo.PassportNumber.
  • The surname is accessed with result.PassportInfo.Surname.
  • The date of birth is printed using result.PassportInfo.DateOfBirth.
  • The expiry date is outputted with result.PassportInfo.DateOfExpiry.
  • The gender is accessed through result.PassportInfo.Gender.
  • The document type is retrieved using result.PassportInfo.DocumentType.
  • The nationality is available via result.PassportInfo.Nationality.
  • The nationality code is accessed with result.PassportInfo.NationalityCode.
  • The issuing country code is retrieved using result.PassportInfo.IssuingCountryCode.
  • The personal number is available via result.PassportInfo.PersonalNumber.
  • The date of issue is accessed through result.PassportInfo.DateOfIssue.
Learn to Extract Passport Info with IronOCR
View on GitHub

Ready to Get Started?

Nuget Downloads 6,236,385Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required