DEV Community

Robin for Capawesome

Posted on Originally published at capawesome.io

Scan Documents in Capacitor with ML Kit and VisionKit

Document scanning UI is a solved problem: Google and Apple each ship a polished, ML-powered scanner with the operating system — the same flows users know from Google Drive and Apple Notes. What a Capacitor app needed was a bridge, not another camera stack. We just released the Capacitor Document Scanner plugin, and its surface is deliberately tiny.

Two API calls

Check availability, then scan:

import { DocumentScanner } from '@capawesome-team/capacitor-document-scanner';

const { available } = await DocumentScanner.isAvailable();

const { scannedImages } = await DocumentScanner.scanDocument({
  imageQuality: 80,
  pageLimit: 5,
});
Enter fullscreen mode Exit fullscreen mode

The OS detects the edges, corrects the perspective, and offers a review step before the pages come back as JPEG files in the cache directory. A user backing out is a normal outcome: the promise rejects with SCAN_CANCELED.

Get a PDF instead of loose images

const { pdf } = await DocumentScanner.scanDocument({
  generatePdf: true,
});
Enter fullscreen mode Exit fullscreen mode

One combined PDF of all scanned pages — generated by ML Kit on Android, composed from the page images on iOS. Perfect for receipts, signed contracts, and anything a backend expects as a single file.

Platform behavior, documented honestly

  • On Android, androidScannerMode selects the editing capabilities (Base for crop/rotate, BaseWithFilter adds filters, Full adds ML-based cleaning that removes stains, fingers, and shadows), and androidGalleryImportAllowed lets users import an existing photo. iOS applies its cleaning automatically and keeps its UI fixed.
  • pageLimit is enforced by the scanner on Android; on iOS it truncates the result after scanning, because VisionKit exposes no public stop API — and using a private one would risk App Review.
  • The Android scanner ships as an on-demand Google Play services module, downloaded on first use, so it adds nothing to your app size.
  • Files land in the cache directory with automatic stale-file cleanup — copy anything you want to keep.

The plugin is built exclusively on public platform APIs, is part of Capawesome Insiders, and requires Capacitor 8+. The full announcement covers the availability check semantics and the companion plugins for viewing, printing, and sharing the results.

Top comments (0)