Skip to content

regulaforensics/DocumentReader-web-csharp-client

Folders and files

NameName
Last commit message
Last commit date
Apr 2, 2025
Apr 11, 2025
Oct 13, 2023
Mar 27, 2025
Apr 11, 2025
Oct 13, 2023
Mar 21, 2025
Apr 9, 2021
Mar 28, 2025
Mar 26, 2025
Mar 27, 2025
Sep 13, 2024
Jan 13, 2025
Mar 20, 2025

Repository files navigation

Regula.DocumentReader.WebClient - the C# library for the Regula Document Reader Web API

NuGet version (Regula.OpenApi.WebClient) OpenAPI documentation live

Documents recognition as easy as reading two bytes.

If you have any problems with or questions about this client, please contact us through a GitHub issue. You are invited to contribute new features, fixes, or updates, large or small. We are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Frameworks supported

  • .NET Standard 2.0
  • .NET Framework 4.6.1 or later
  • .Net Core 2.0 or later

Install package

Regula.DocumentReader.WebClient is on the NuGet Package Index:

PM> Install-Package Regula.DocumentReader.WebClient -Version 5.2.0

Example

Performing request:

var imageBytes = File.ReadAllBytes("australia_passport.jpg");
var image = new ProcessRequestImage(new ImageData(imageBytes), Light.WHITE);

var requestParams = new RecognitionParams()
    .WithScenario(Scenario.FULL_PROCESS)
    .WithResultTypeOutput(new List<int> { Result.STATUS, Result.TEXT, Result.IMAGES, Result.DOCUMENT_TYPE });
var request = new RecognitionRequest(requestParams, image);

var api = licenseFromEnv != null 
    ? new DocumentReaderApi(apiBaseUrl).WithLicense(licenseFromEnv)
    : new DocumentReaderApi(apiBaseUrl).WithLicense(licenseFromFile);

var response = api.Process(request);

Parsing results:

var response = api.Process(request);

// status examples
var status = response.Status();
string docOverallStatus = status.OverallStatus == CheckResult.OK ? "valid" : "not valid";
string docOpticalTextStatus = status.DetailsOptical.Text == CheckResult.OK ? "valid" : "not valid";

// text fields examples
var docNumberField = response.Text().GetField(TextFieldType.DOCUMENT_NUMBER);
string docNumberVisual = docNumberField.GetValue(Source.VISUAL);
string docNumberMrz = docNumberField.GetValue(Source.MRZ);
int docNumberVisualValidity = docNumberField.SourceValidity(Source.VISUAL);
int docNumberMrzValidity = docNumberField.SourceValidity(Source.MRZ);
int docNumberMrzVisualMatching = docNumberField.CrossSourceComparison(Source.MRZ, Source.VISUAL);

// images fields examples
var documentImage = response.Images().GetField(GraphicFieldType.DOCUMENT_FRONT).GetValue();
var portraitField = response.Images().GetField(GraphicFieldType.PORTRAIT);
var portraitFromVisual = portraitField.GetValue(Source.VISUAL);

You can find this sample in the example.