Installation
NSCameraUsageDescription
Basic Usage
ScanDocument
Status
success
cancel
ScannedImages
Configuration Options
The ScanDocument action accepts an optional configuration object with the following parameters:
ResponseType — Controls the output format. Set to imageFilePath to receive file paths on disk (default) or base64 to receive base64-encoded strings. Use base64 when you need to upload images directly to a server or display them inline.
imageFilePath
base64
MaxNumDocuments — Sets the maximum number of pages the user can scan in a single session. Defaults to 24 on Android. Set to 1 for single-document mode where the scanner closes automatically after one capture.
CroppedImageQuality — Android only. Controls the JPEG quality of cropped images, from 0 (lowest) to 100 (highest). Defaults to 100. Lower values reduce file size at the cost of image clarity.
LetUserAdjustCrop — Android only. When set to true (default), the user can manually adjust the detected crop area before saving. Setting this to false forces automatic cropping and limits capture to a single document.
Brightness — Adjusts brightness of the scanned output. Accepts values from -255 to 255, where 0 is no change, positive values brighten the image, and negative values darken it. Useful for compensating low-light scans.
Contrast — Adjusts contrast of the scanned output. Accepts values from 0.0 to 10.0, where 1.0 is no change. Values above 1.0 increase contrast, which can improve text legibility in poorly lit scans.
ScannerMode — Android only. Controls which ML Kit features are available during scanning. Three options are available: base provides basic crop and rotate only; base_with_filter adds grayscale and auto-enhancement filters; full (default) enables all features including ML-based image cleaning that automatically removes stains, fingers, and other artifacts.
base
base_with_filter
full
Example Flow
MaxNumDocuments
ResponseType
CroppedImageQuality
Troubleshooting
If scanning fails on Android, verify that the device is not an emulator. The ML Kit Document Scanner does not support emulated environments due to Google Play Services limitations. Always test on a physical device.
If the camera does not open on iOS, confirm that the NSCameraUsageDescription key is present in your Info.plist and that the user has granted camera permissions.