Browse our Products

Latest release

Deprecation warning

What was changed

KeySummaryCategory
OCRJAVA‑381Automatic extraction of key details (such as a number, birth date, and the like) from passport images.New feature
OCRJAVA‑382Embedding of user-specified fonts in recognition results saved as PDFs.Enhancement

Public API changes and backwards compatibility

This section lists all public API changes introduced in Aspose.OCR for Java 24.6.1 that may affect the code of existing applications.

Added public APIs:

The following public APIs have been added to Aspose.OCR for Java 24.6.1 release:

Country enumeration

A list of countries for retrieving specific details (such as a number, name, date of birth, and so on) from passport images.

ValueCountry
Country.NONEDo not parse passport details (only recognize passport text).
Country.MADAGASCARParse Malagasy passports.
Country.USAParse US passports.

PassportRecognitionSettings.setCountry()

This function allows you to specify the passport issuing country. It is necessary for proper work of RecognitionResult.GetKeywords() method.

RecognitionResult.GetKeywords() method

Returns passport details as a collection of key-value pairs (HashMap). The specific details extracted depend on the passport’s origin, which is specified in the Country parameter of the passport recognition settings.

Updated public APIs:

The following public APIs have been changed in Aspose.OCR for Java 24.6.1 release:

SaveMultipageDocument() method

Added an optional embeddedFontPath parameter, which allows to embed a custom TrueType (.TTF) or OpenType (.OTF) font into the recognition result saved as a PDF document.

Removed public APIs:

No changes.

Examples

The code samples below illustrate the changes introduced in this release:

US passport recognition

// Initialize Aspose.OCR recognition API
AsposeOCR api = new AsposeOCR();
// Add passport image to the recognition batch
OcrInput source = new OcrInput(InputType.SingleImage);
source.add("passport.png");
// Specify the country of passport origin
PassportRecognitionSettings settings = new PassportRecognitionSettings();
settings.setCountry(Country.USA);
// Extract and parse passport details
RecognitionResult result = api.RecognizePassport(input, settings).get(0);
HashMap<String, RecognitionResult.LinesResult> keywords = result.GetKeywords();
// Output passport details
for(String key : keywords.keySet()) {
	out.print("Key: "+key);
	out.println("  Value: "+keywords.get(key).textInLine);
}

Embed custom font into saved PDF

// Initialize Aspose.OCR recognition API
AsposeOCR api = new AsposeOCR();
// Add an image to OcrInput object
OcrInput input = new OcrInput(InputType.SingleImage);
input.Add("page1.png");
input.Add("page2.png");
// Recognize image
ArrayList<RecognitionResult> results = api.Recognize(input);
// Save all pages to PDF document
AsposeOcr.SaveMultipageDocument("result.pdf", Format.PdfNoImg, results, "fonts/AdobeMingStd-Light.otf");