# ML Kit Document Scanner in action

DevFeed: [ML Kit Document Scanner in action](<https://devfeed.tech/articles/ml-kit-document-scanner-in-action-25944.md>)

Original publisher: [Read original article](<https://medium.com/google-developer-experts/ml-kit-document-scanner-in-action-1c3a49ef5a33?source=rss-cbfc736ddcd3------2>)

Author: Julien Salvi

Published: 2024-04-15T09:53:27Z

Content type: tutorial

Language: en

Sources: [Julien Salvi](<https://devfeed.tech/sources/stories-by-julien-salvi-on-medium.md>)

Topics: [ML Kit](<https://devfeed.tech/topics/ml-kit.md>), [aosp](<https://devfeed.tech/topics/aosp.md>), [Library](<https://devfeed.tech/topics/library.md>), [Image](<https://devfeed.tech/topics/image.md>), [Documentation](<https://devfeed.tech/topics/documentation.md>)

Tags: [aircall](<https://devfeed.tech/tags/aircall.md>), [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [api](<https://devfeed.tech/tags/api.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [machine-learning](<https://devfeed.tech/tags/machine-learning.md>), [messaging](<https://devfeed.tech/tags/messaging.md>), [ml-kit](<https://devfeed.tech/tags/ml-kit.md>), [ml-kit-android](<https://devfeed.tech/tags/ml-kit-android.md>), [scan](<https://devfeed.tech/tags/scan.md>), [scanner](<https://devfeed.tech/tags/scanner.md>)

## AI overview

ML Kit Document Scanner adds in-app document capture for Android through a scan flow delivered by Google Play Services, so the article says apps need no camera permission and gain about 300 KB in download size. It provides automatic capture, edge detection, rotation, and three editing modes: basic, filters, or ML image cleaning. Developers can set a page limit, allow gallery import, and choose PDF or JPEG output. The article describes integrating it into Aircall messaging: configure the scanner, launch it with an ActivityResultLauncher, retrieve the PDF cache path, and use FileProvider to expose the file URI for upload. Aircall built a proof of concept in a day and later released the feature for sending scanned documents as MMS. The library was still in beta; the author notes PDF-generation controls such as image compression as a desired improvement.

## Source excerpt

Recently, ML Kit released a new library to digitize physical documents directly from your Android application. ML Kit Document Scanner allows the users to easily scan documents with maximum controls and minimum code integration. During my time at Aircall, I took some time to explore and integrate the library to build an Android-exclusive feature for the messaging scope. Discovering the library ML Document Scanner is the newborn of the ML Kit family. It allows users to convert physical documents into digital formats. The library now brings this feature to any apps with many capabilities like applying filters, cleaning the image, removing shadows and many more. The entire scan flow is delivered by the Play Services so no camera permission is mandatory and the library size (~300KB download size increase) has a low impact in your app (the ML models are also managed by the Play Services). So let's dig into the what the library offers. The ML Kit Document Scanner offers key capabilities like a high-quality user interface that ensures consistency across Android applications. With automatic capture and document detection, the users can effortlessly scan documents, while accurate edge detection ensures optimal cropping results. Additionally, automatic rotation detection ensures that scanned documents are presented upright. For developers seeking customization options, the Document Scanner API offers flexibility. You can set a limit on the number of pages scanned and enable or disable the capability to import from the photo gallery. Moreover, there are 3 editing modes available: basic editing capabilities, editing with image filters or editing with ML-enabled image cleaning capabilities (erase stains, fingers...). You will find a complete overview of the library with the official documentation. ML Kit | Google for Developers Build with Document ScannerCrafting the feature It's now time to craft our new feature with ML Kit Document Scanner. Here, we want to give the ability to t