Browse our Products

Aspose.OCR for .NET 24.2.0 - Release Notes

What was changed

KeySummaryCategory
OCRNET‑791Advanced OCR features are now selectively downloaded as needed.New feature
OCRNET‑793Significantly improved PDF recognition.Enhancement

Public API changes and backwards compatibility

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

Added public APIs:

The major change introduced in Aspose.OCR for .NET 24.2.0 is that the distributive now offers basic recognition capabilities only. Additional features can be added via downloadable resources, freely available in our online repository.

This approach allows you to selectively choose which features you need for your project, keeping your codebase lean and modular.

By default, Aspose.OCR for .NET automatically downloads the required resources as needed, saving you time and effort in managing dependencies. However, you have the option to manually manage the resources for your project using the static methods of Aspose.OCR.Resources class:

Aspose.OCR.Resources.SetRepository() method

Allows you to specify the URL of the online repository from which Aspose.OCR for .NET resources will be downloaded. You can provide any of the following:

  • A link to the root directory of the branch in a public GitHub repository in form https://github.com/{project}/{repository}/blob/{branch}/.
    The default repository is https://github.com/aspose-ocr/resources/blob/main.
  • A link to the directory on a web site (either intranet or public). For example http://localhost/aspose-ocr-resources.
  • HTTP link to the directory on a publicly accessible S3 bucket or other online storage which supports web (HTTP/HTTPS) access.

By default, the resources are downloaded from https://github.com/aspose-ocr/resources/.

Aspose.OCR.Resources.GetRepository() method

Returns the URL of the online repository from which Aspose.OCR for .NET resources are downloaded.

Aspose.OCR.Resources.AllowAutomaticDownloads() method

Allow (true) or block (false) automatic downloading of required resources from the online repository. By default, Aspose.OCR for .NET automatically downloads the required resources as needed.

If you do not want your application to access the Internet at runtime, manually download all required resources from our repository and call Aspose.OCR.Resources.AllowAutomaticDownloads(false).

Aspose.OCR.Resources.ListRemote() method

Returns the list of all compatible resources from the online repository as a string array.

Aspose.OCR.Resources.SetLocalPath() method

Allows you to specify an absolute or relative path to the directory where the resources will be downloaded. Pass false to the create parameter to prevent the directory from being created automatically.

By default, the resources will be downloaded into the aspose_data subdirectory in the application’s working directory.

Aspose.OCR.Resources.GetLocalPath() method

Returns the full path to the local directory where the resources will be downloaded.

Aspose.OCR.Resources.ListLocal() method

Returns the list of all Aspose.OCR resources stored in the local directory as a string array.

Aspose.OCR.Resources.FetchAll() method

Download all resources compatible with the current version of Aspose.OCR for .NET from the online repository. The existing resource files will be overwritten.

Aspose.OCR.Resources.FetchResources() method

Download one or more resources specified in the names parameter from the online repository. Existing resources will be overwritten.

Use Aspose.OCR.Resources.ListRemote() method to get the full list of resource names, compatible with the current release of Aspose.OCR .NET.

Aspose.OCR.Resources.FetchResource() method

Download a specific resource from the online repository. If the resource has already been downloaded, it will be overwritten.

Use Aspose.OCR.Resources.ListRemote() method to get the full list of resource names, compatible with the current release of Aspose.OCR .NET.

Aspose.OCR.Resources.RemoveLocal() method

Delete a locally stored resource.

Use Aspose.OCR.Resources.ListLocal() method to get the full list of locally downloaded resources.

Updated public APIs:

No changes.

Removed public APIs:

No changes.

Changes in application logic

PDF recognition has been significantly redesigned. Now all page content is pre-rendered as a single image, which is recognized as a whole rather than as a collection of images. As a result, Aspose.OCR for .NET can extract all types of textual content on a page, including machine-readable characters, vector images, pictures, and so on.

All related operations are performed in the background, so you do not need to perform any additional processing. However, it slightly changes the behavior and output of certain methods:

  • All image preprocessing is applied to the whole page rather than separate images on a page.
  • Images saved on disk with Save() method now include entire PDF pages.
  • OcrInput object returned by Render() or Save() methods contains the number of images equal to the number of pages in the original PDF document.
  • The number of Aspose.OCR.RecognitionResult objects returned from recognition methods now equals to the number of pages in the original PDF.

Examples

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

Cyrillic characters recognition

// Download Hindi OCR model to "aspose/ocr" directory in the application working directory
Aspose.OCR.Resources.SetLocalPath("aspose/ocr");
Aspose.OCR.Resources.FetchResource("aspose-ocr-cyrillic-v1");
// Initialize Aspose.OCR for .NET recognition API
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Add images to OcrInput object
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source1.png");
input.Add("source2.jpg");
// Set recognition language
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.Language = Aspose.OCR.Language.Ukr;
// Recognize image
List<Aspose.OCR.RecognitionResult> results = recognitionEngine.Recognize(input, recognitionSettings);
foreach(Aspose.OCR.RecognitionResult result in results)
{
	Console.WriteLine(result.RecognitionText);
}

Use manually downloaded resources

  1. Create aspose\ocr folder in the application’s working directory.
  2. Download https://github.com/aspose-ocr/resources/blob/main/aspose-ocr-cyrillic-v1.ocr file to the aspose\ocr folder.
  3. Block automatic resource downloading in the code.
Resources.SetLocalPath("aspose/ocr");
Resources.AllowAutomaticDownloads(false);
// Set recognition language
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.Language = Aspose.OCR.Language.Ukr;