@capgo/capacitor-document-scanner

April 4, 2026 · View on GitHub

Capgo - Instant updates for capacitor

➡️ Get Instant updates for your App with Capgo

Missing a feature? We’ll build the plugin for you 💪

Capacitor plugin to scan document iOS and Android

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/document-scanner/

Compatibility

Plugin versionCapacitor compatibilityMaintained
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.

Install

npm install @capgo/capacitor-document-scanner
npx cap sync

Important Notes

Android Emulator Limitations

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.

Demo

Scanning one note

iOSAndroid
iOS DemoAndroid Demo

API

scanDocument(...)

scanDocument(options?: ScanDocumentOptions | undefined) => Promise<ScanDocumentResponse>

Opens the device camera and starts the document scanning experience.

ParamType
optionsScanDocumentOptions

Returns: Promise<ScanDocumentResponse>


Interfaces

ScanDocumentResponse

PropTypeDescription
scannedImagesstring[]Scanned images in the requested response format.
statusScanDocumentResponseStatusIndicates whether the scan completed or was cancelled.
MethodSignatureDescription
getPluginVersion() => Promise<{ version: string; }>Get the native Capacitor plugin version

ScanDocumentOptions

PropTypeDescriptionDefault
croppedImageQualitynumberAndroid only: quality of the cropped image from 0 - 100 (100 is best).100
letUserAdjustCropbooleanAllow the user to adjust the detected crop before saving. On iOS this forces the native VisionKit preview/editor after each capture using the private VisionKit navigation hooks needed to keep the scanner flow alive. On Android this enables ML Kit's crop adjustment flow.true
reviewCapturedDocumentbooleanWhen enabled, shows the current scanned page before continuing so the user can review it and explicitly continue or finish the flow. On iOS this forces the native VisionKit preview/editor between captures. On Android this switches to a one-page-at-a-time flow between ML Kit sessions. The review/editor screen is still shown automatically when the scan limit is reached.false
maxNumDocumentsnumberMaximum number of documents to scan. On iOS: VisionKit caps scans at 24 pages (system limit), and the hacked native flow can still stop earlier when you pass a smaller limit. On Android: customizable limit; defaults to 20 for performance (clamped 1-24). Set to 1 for single-scan mode where the scanner stops after one document.20 on Android, 24 on iOS
responseTypeResponseTypeFormat to return scanned images in (file paths or base64 strings).ResponseType.ImageFilePath
brightnessnumberBrightness adjustment applied to scanned images. Range: -255 to 255 (0 = no change, positive = brighter, negative = darker) Useful for compensating low-light scans.0
contrastnumberContrast 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
scannerModeScannerModeAndroid 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

Type Aliases

ResponseType

'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect'

Enums

ScanDocumentResponseStatus

MembersValueDescription
Success'success'The scan completed successfully.
Cancel'cancel'The user cancelled the scan flow.

ResponseType

MembersValueDescription
Base64'base64'Return scanned images as base64-encoded strings.
ImageFilePath'imageFilePath'Return scanned images as file paths on disk.

ScannerMode

MembersValueDescription
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.

credits

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