Get started Pixelnetica™ Document Scanning SDK for Android
Initialization
The SDK should be initialized only once. There’s no need to pass the Application
object to every SDK call. Overriding Application.onCreate()
is recommended.
class DemoApp : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Image SDK
// Assume the license key is stored in assets
ScanningSdkLibrary.load(this)
}
}
At least one of the following three options can be used to pass the license key to DSSDK:
- Store the license key file in the application’s assets folder
For example, place your file in
src/main/assets/pixelnetica/scanning/<file>
, where<file>
matches whatScanningSdkLibrary.load()
expects.
Then,ScanningSdkLibrary.load(app)
can be called with only the Application argument (see the sample above). - Use a license key string
Pass your long license key string to
ScanningSdkLibrary.load(app, licenseKey)
- Use a resource ID Pass a resource ID instead of a license key string.
The license can also be stored on an external server. Although this approach simplifies license updates (because the main application doesn’t need to be updated), it introduces several drawbacks by making the application’s functionality dependent on internet and server availability.
Setup OCR Languages
DSSDK supports more than 100 languages for text recognition and extraction. To enable this functionality, you must set up the appropriate language files in your application.
Getting Language Files
Language files are available in a single archive from our server.
Download Language Archive, unzip it, and make its contents accessible to your application. Language files can either be placed on a remote server or bundled with your application as described below.
Important Notice: In the DSSDK demo application (EasyScan), language files are hosted on our server for development purposes. However, this location may change without prior notice.
For reliable and uninterrupted service, do not use the hosted files in production. Instead, store the language files on a remote private server or bundle them with your application.
Setting Up Languages in Your Application
There are two approaches to configure and use language files for text recognition (OCR):
-
Using the Pixelnetica UI Control to Manage Language Files
This setup process is detailed in the relevant documentation. This method is employed in the DSSDK demo application (EasyScan), allowing users to download any available language from the server. It is a practical solution for applications requiring support for multiple languages and regions.However, if your application requires a restricted, predefined set of languages or a fully customized UI, you should consider the manual approach described below.
-
Managing Language Files Manually
- Create a directory accessible by your application. This directory will be referred to as
languagesDir
. - Use the function
ScanningSdkLibrary.unpackLanguageFile(languageFile, languagesDir)
to unpack the desired language files into thelanguagesDir
. Store the names of the unpacked files in a list, referred to aslanguageNames
.- The
languageFile
can either be downloaded from a remote server or bundled with your application.
- The
- Unpack the file
osd.pxl
to enable the document orientation detector. This file plays a critical role in detecting and correcting the orientation of documents, ensuring text is accurately recognized, improving overall OCR performance, and enhancing text readability. It is recommended to bundle this file with your application, as demonstrated in the demo application.
- Create a directory accessible by your application. This directory will be referred to as