Getting Started

This guide explains the process of integrating the OCR library of PSPDFKit 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 3.6.3 as the IDE and Android Gradle plugin 3.6.3 or higher for development.

Setting Up OCR

Step 1: Adding PSPDFKit and OCR to Your Project

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

    build.gradle
    1
    2
    3
    4
    5
    6
    7
    
    allprojects {
        repositories {
            maven {
                url 'https://customers.pspdfkit.com/maven/'
            }
        }
    }
    
  2. In your app-level build.gradle file, add the PSPDFKit and OCR dependencies:

    Copy
    app/build.gradle
    1
    2
    3
    4
    5
    
    dependencies {
        final pspdfkit_version = '6.5.3'
        implementation "com.pspdfkit:pspdfkit:$pspdfkit_version"
        implementation "com.pspdfkit:pspdfkit-ocr:$pspdfkit_version"
    }
    

Step 2: Adding OCR Language Packs

For each supported language 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 Dynamic Delivery.

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

Copy
module/build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
dependencies {
    // The language pack version has to match the PSPDFKit and OCR library versions.
    final pspdfkit_version = '6.5.3'

    // 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 Dynamic Delivery), make sure to specify the language packs using the api configuration instead of implementation.

Catalog Example

You can find a runnable OcrExample 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 section.

Next Steps

Check out our OCR Usage guide to see how to use OCR inside your Android application with Java or Kotlin.