Capacitor plugin to scan document iOS and Android
npm install @capgo/capacitor-document-scanner
The most complete doc is available here: https://capgo.app/docs/plugins/document-scanner/
| Plugin version | Capacitor compatibility | Maintained |
| -------------- | ----------------------- | ---------- |
| v8.\.\ | v8.\.\ | ✅ |
| v7.\.\ | v7.\.\ | On demand |
| v6.\.\ | v6.\.\ | ❌ |
| v5.\.\ | v5.\.\ | ❌ |
> Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.
``bash`
npm install @capgo/capacitor-document-scanner
npx cap sync
The ML Kit Document Scanner does not work on Android emulators. This is a limitation of Google Play Services and ML Kit on emulated devices. When testing your app:
- ✅ Use a physical Android device for testing document scanning
- ❌ Android emulators will show an error: "Document scanner is not supported on Android emulators"
This limitation is due to:
- Google Play Services compatibility issues with emulator environments
- ML Kit Document Scanner requiring actual hardware camera capabilities
- Emulators lacking the necessary ML Kit runtime components
For development and testing, always use a real Android device.
| iOS | Android |
|:---:|:-------:|
| !iOS Demo | !Android Demo |
* scanDocument(...)
* Interfaces
* Type Aliases
* Enums
`typescript`
scanDocument(options?: ScanDocumentOptions | undefined) => Promise
Opens the device camera and starts the document scanning experience.
| Param | Type |
| ------------- | ------------------------------------------------------------------- |
| options | ScanDocumentOptions |
Returns: Promise<ScanDocumentResponse>
--------------------
#### ScanDocumentResponse
| Prop | Type | Description |
| ------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------ |
| scannedImages | string[] | Scanned images in the requested response format. |
| status | ScanDocumentResponseStatus | Indicates whether the scan completed or was cancelled. |
| Method | Signature | Description |
| -------------------- | -------------------------------------------- | --------------------------------------- |
| getPluginVersion | () => Promise<{ version: string; }> | Get the native Capacitor plugin version |
#### ScanDocumentOptions
| Prop | Type | Description | Default |
| ------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------- |
| croppedImageQuality | number | Android only: quality of the cropped image from 0 - 100 (100 is best). | 100 |
| letUserAdjustCrop | boolean | Android only: allow the user to adjust the detected crop before saving. Disabling this forces single-document capture. | true |
| maxNumDocuments | number | Maximum number of documents to scan. On Android: limits documents the user can scan (1-24). On iOS: prevents scanning more than the specified number of pages (uses internal API swizzling). Set to 1 for single-scan mode where the scanner stops after one document. | 24 on Android, unlimited on iOS |
| responseType | ResponseType | Format to return scanned images in (file paths or base64 strings). | ResponseType.ImageFilePath |
| brightness | number | Brightness adjustment applied to scanned images. Range: -255 to 255 (0 = no change, positive = brighter, negative = darker) Useful for compensating low-light scans. | 0 |
| contrast | number | Contrast adjustment applied to scanned images. Range: 0.0 to 10.0 (1.0 = no change, >1 = more contrast, <1 = less contrast) Helps improve text clarity in poorly lit scans. | 1.0 |
| scannerMode | ScannerMode | Android only: scanner mode that controls ML Kit features and filters. - 'base': Basic scan with crop/rotate, no filters or ML cleaning - 'base_with_filter': Adds grayscale and auto-enhancement filters - 'full': All features including ML-based image cleaning (erases stains, fingers, etc.) | ScannerMode.Full |
#### ResponseType
'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect'
#### ScanDocumentResponseStatus
| Members | Value | Description |
| ------------- | ---------------------- | --------------------------------- |
| Success | 'success' | The scan completed successfully. |
| Cancel | 'cancel' | The user cancelled the scan flow. |
#### ResponseType
| Members | Value | Description |
| ------------------- | ---------------------------- | ------------------------------------------------ |
| Base64 | 'base64' | Return scanned images as base64-encoded strings. |
| ImageFilePath | 'imageFilePath' | Return scanned images as file paths on disk. |
#### ScannerMode
| Members | Value | Description |
| -------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Base | 'base' | Basic document scanning with crop and rotate features only. No filters or ML-based enhancements. |
| BaseWithFilter | 'base_with_filter' | Basic features plus automatic filters (grayscale, auto-enhancement). |
| Full` | 'full' | Full feature set including ML-based image cleaning. Automatically removes stains, fingers, and other artifacts. |
This plugin is a re implementation of the original https://document-scanner.js.org
Thanks for the original work, we recoded it with more modern SDK but explodes the same API