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);
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,357,159Version:2026.11just released