Code Sample

The distribution package includes a ready to use code sample that shows the module work.

The code sample is found in the root folder of the distribution package.

How to run the sample from distributive

1. Request ABBYY Mobile Capture trial version on the ABBYY website and add it to the sample:

  • Copy iOS assets directory to the sample project into ../assets folder
  • Copy your license file into ../assets with MobileCapture.License name
  • Copy Android libs directory to the sample project into ../libs/android folder
  • Copy iOS libs directory to the sample project into ../libs/ios folder

 Important! Make sure that a folder structure is as following or change the paths to libs, assets and license file if your folder structure differs from the following one:

assets/
  bcr/
     ...
  dictionaries/
     ...
  ...
  MobileCapture.License
libs/
  android/
     abbyy-rtr-sdk-1.0.aar
     abbyy-ui-1.0.aar
  ios/
     AbbyyRtrSDK.framework
     AbbyyUI.framework
     ...
sample-ionic/
  ...

2. Add the plugin and apply changes from the sample-ionic sample project directory:

npm install
ionic build
ionic cap sync

3. To run application do the following:

Android iOS
  • From console:
    • Execute npx cap open android from the sample root
  • From Android Studio:
    • Click Run app button
  • From console:
    • Execute npx cap open ios from the sample root
  • From XCode
    • Click Run button

Code sample

The code below shows how to call ABBYY Mobile Capture SDK Cordova Plugin to capture one image and save the result as base64. This code can be found in the sample-ionic/src/hooks/imageCapture.ts file of your distribution.

...
declare let AbbyyRtrSdk: any;
...

const takePhoto = async () => {
  AbbyyRtrSdk.startImageCapture( (result: { images: { base64: any; }[]; resultInfo: { uriPrefix: any; }; }) => {
     if (result.images && result.images[0]) {
        setImage({
           base64: result.resultInfo.uriPrefix + result.images[0].base64
        })
     } else {
        console.log(result.error);
     }
  }, {
     licenseFileName: "MobileCapture.License",
     destination: 'base64',
     isCaptureButtonVisible: true,
     requiredPageCount: 1,
  });
 };

02.03.2022 12:59:15

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.