2.0.2 • Published 3 years ago

react-native-documentscanner-android v2.0.2

Weekly downloads
109
License
MIT
Repository
github
Last release
3 years ago

react-native-documentscanner-android

React Native module to auto scan documents (Android only)

Live document detection library. Returns either a URI of the captured image, allowing you to easily store it or use it as you wish !

Features:

  • Live detection
  • Perspective correction and image crop
  • Flash

enter image description 
here

Installation

npm

npm install react-native-documentscanner-android

yarn

yarn add react-native-documentscanner-android

Observation

In android/app/src/main/AndroidManifest.xml

Change manifest header to avoid "Manifest merger error". After you add xmlns:tools="http://schemas.android.com/tools" should look like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.<yourAppName>" xmlns:tools="http://schemas.android.com/tools">

Add tools:replace="android:allowBackup" in <application tag. It should look like this:

<application tools:replace="android:allowBackup" android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme">

Add permissions:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Usage

import DocumentScannerAndroid from "react-native-documentscanner-android";

// ...

<DocumentScannerAndroid 
    style={{flex: 1}}
    onPictureTaken={(document) => console.log(document.path)}
    onProcessing={(data) => console.log(data.processing)}
    enableTorch={false}
    detectionCountBeforeCapture={5}
/>

Properties

PropsDefaultTypeDescription
manualOnlyfalseboolif true, auto-detect is disabled
enableTorchfalseboolAllows to active or deactivate flash during document detection
detectionCountBeforeCapture15numberNumber of correct rectangle to detect before capture document
brightness10numberThis property only work to enhance document at the save moment
contrast1numberThis property only work to enhance document at the save moment
noGrayScalefalseboolCurrently this module saves pictures only in gray scale, this property adds the option to disable gray scale

Manual capture

  • Get the component ref
import { capture } from 'react-native-documentscanner-android';
  • Then
scanner.capture();

Returned Image

PropParamsTypeDescription
onPictureTakendataobjectReturns an image in a object { path: ('imageUri')}
onProcessingdataobjectReturns an object {processing: (true | false)} to show is an image is processing yet

The images are saved in Documents folder.

Todo

  • Pass overlay color dynamically
  • Pass contrast and brightness to preview
  • Use front cam
  • Use base64

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.12

5 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago