Integrating our OCR SDK into Android

This guide explains the process of integrating the OCR library of Nutrient for Android into your project. The OCR library is designed to work best with Android Studio and the Gradle build system. We recommend Android Studio as the IDE and Android Gradle plugin 8.2.0 or higher for development.

Setting up OCR

Below is a list of steps required to set up OCR.

Step 1 — Adding Nutrient and OCR to your project

  1. In your top-level build.gradle file, add the Nutrient Maven repository:

    allprojects {
        repositories {
            maven {
                url 'https://my.nutrient.io/maven/'
            }
        }
    }
  2. In your app-level build.gradle file, add the Nutrient and OCR dependencies:

    dependencies {
        final pspdfkit_version = '2024.7.0'
        implementation "com.pspdfkit:pspdfkit:$pspdfkit_version"
        implementation "com.pspdfkit:pspdfkit-ocr:$pspdfkit_version"
    }

Step 2 — Adding OCR language packs

For each [supported language][language support] you want to perform OCR for, your app needs to contain a language pack. Each language pack has to be added as a dependency, either to your primary application module, or transitively — for example, by adding it to a dynamic feature APK module, which can be downloaded to a device on demand using [Play Feature Delivery][].

To add one or more OCR language packs to an Android module, specify them inside the dependencies block of that module:

dependencies {
    // The language pack version has to match the PSPDFKit and OCR library versions.
    final pspdfkit_version = '2024.7.0'

    // Pick one or more language packs from this list.
    api "com.pspdfkit:pspdfkit-ocr-croatian:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-czech:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-danish:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-dutch:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-english:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-finnish:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-french:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-german:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-indonesian:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-italian:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-malay:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-norwegian:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-polish:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-portuguese:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-serbian:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-slovak:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-slovenian:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-spanish:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-swedish:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-turkish:$pspdfkit_version"
    api "com.pspdfkit:pspdfkit-ocr-welsh:$pspdfkit_version"
}

ℹ️ Note: When adding language packs transitively to submodules of your primary app module (for example, with [Play Feature Delivery][]), make sure to specify the language packs using the api configuration instead of implementation.

Catalog example

You can find a runnable [OcrExample][ocr example] inside our Catalog app, and it showcases the use of OCR. To try out the OCR example in action, check out the [Catalog Getting Started][catalog getting started] section.

Next steps

Check out our OCR [usage][ocr usage] guide to see how to use OCR inside your Android application with Java or Kotlin.

[my.nutrient.io: https://my.nutrient.io [play feature delivery]: https://developer.android.com/guide/playcore/feature-delivery [ocr example]: https://github.com/PSPDFKit/pspdfkit-android-catalog/blob/9eac1be5767cdeb5a58d879d0749c2338d4f77fb/app/src/main/java/com/pspdfkit/catalog/examples/kotlin/OcrExample.kt [catalog getting started]: https://github.com/PSPDFKit/pspdfkit-android-catalog#getting-started [integrating pspdfkit]: /guides/android/getting-started/integrating-pspdfkit [language support]: /guides/android/ocr/language-support [ocr usage]: /guides/android/ocr/usage