# react-native-documentscanner-android

> React native package to auto scan documents

Latest version **2.0.2** (published 2021-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-documentscanner-android
pnpm add react-native-documentscanner-android
yarn add react-native-documentscanner-android
bun add react-native-documentscanner-android
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2021-09-30 |
| First published | 2018-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 36 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | André Junqueira |
| Maintainers | andrejunqueira, erickmaeda, guihendias |
| Keywords | react-native, android |

## Links

- npm: https://www.npmjs.com/package/react-native-documentscanner-android
- Repository: https://github.com/andreluisjunqueira/react-native-document-scanner-android
- Issues: https://github.com/andreluisjunqueira/react-native-document-scanner-android/issues
- npm.io page: https://npm.io/package/react-native-documentscanner-android

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2021-09-30
- 2.0.1 — 2021-09-30
- 2.0.0 — 2021-09-30
- 1.3.0 — 2019-08-02
- 1.2.1 — 2019-03-28
- 1.2.0 — 2019-02-08
- 1.1.12 — 2018-11-21
- 0.1.13 — 2018-10-25
- 0.1.12 — 2018-10-19
- 0.1.11 — 2018-07-18
- 0.1.10 — 2018-04-27
- 0.1.9 — 2018-03-28
- 0.1.8 — 2018-03-12
- 0.1.7 — 2018-02-02
- 0.1.6 — 2018-02-01
- … 6 more at https://npm.io/package/react-native-documentscanner-android/versions

## README

# 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](https://media.giphy.com/media/KZBdm9gbGGRBlRZV1t/giphy.gif)
## Installation

`npm`
```sh
npm install react-native-documentscanner-android
```
`yarn`
```sh
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

```tsx
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

| Props                       | Default | Type     | Description                                                                                                  |
| --------------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| manualOnly                  | false   | `bool`   | if true, auto-detect is disabled                                                                             |
| enableTorch                 | false   | `bool`   | Allows to active or deactivate flash during document detection                                               |
| detectionCountBeforeCapture | 15      | `number` | Number of correct rectangle to detect before capture document                                                |
| brightness                  | 10      | `number` | This property only work to enhance document at the save moment                                               |
| contrast                    | 1       | `number` | This property only work to enhance document at the save moment                                               |
| noGrayScale                 | false   | `bool`   | Currently this module saves pictures only in gray scale, this property adds the option to disable gray scale |

### Manual capture

- Get the component ref

```tsx
import { capture } from 'react-native-documentscanner-android';

```

- Then

```ts
scanner.capture();
```

### Returned Image

| Prop           | Params | Type   | Description                                                                            |
| -------------- | ------ | ------ | -------------------------------------------------------------------------------------- |
| onPictureTaken | data   | object | Returns an image in a object `{ path: ('imageUri')}`                                   |
| onProcessing   | data   | object | Returns 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](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---
_Source: https://npm.io/package/react-native-documentscanner-android · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
