Using offline resources

Contents
[ ]

While Aspose.OCR for .NET can automatically fetch the necessary resources as needed, there are certain scenarios where manual downloading of these resources and providing them with your application could be beneficial:

  • Your application needs to work in an environment where Internet access is limited or unavailable.
  • You (or the application user) do not have the ability to change firewall rules.
  • You want to reduce startup time and improve overall performance, particularly for applications requiring fast response times.
  • All application files must pass the strict audit and cannot be changed/added in the runtime.

To make the application work in the offline mode:

  1. Create a folder in the application’s working directory.
  2. Download the required resource files from the Aspose.OCR resource repository to the folder. To find more information on a specific resource, refer to the following link.
  3. Provide the absolute or relative path to the folder using Aspose.OCR.Resources.SetLocalPath() method. For example: Aspose.OCR.Resources.SetLocalPath("aspose/ocr", false);.
  4. Block automatic downloading of resources by calling Aspose.OCR.Resources.AllowAutomaticDownloads(false).
  5. Do not forget to include a directory with downloaded resources in your distributive, otherwise the related functionality will fail.

You also have a flexibility to combine online and offline modes. For example, provide the most used resources with your app and download rarely used resources in the runtime.

Example

Resources.SetLocalPath("aspose/ocr");
Resources.AllowAutomaticDownloads(false);
// Set recognition language
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.Language = Aspose.OCR.Language.Ukr;