Plugin.Maui.DocumentScanner
0.2.0
See the version list below for details.
dotnet add package Plugin.Maui.DocumentScanner --version 0.2.0
NuGet\Install-Package Plugin.Maui.DocumentScanner -Version 0.2.0
<PackageReference Include="Plugin.Maui.DocumentScanner" Version="0.2.0" />
<PackageVersion Include="Plugin.Maui.DocumentScanner" Version="0.2.0" />
<PackageReference Include="Plugin.Maui.DocumentScanner" />
paket add Plugin.Maui.DocumentScanner --version 0.2.0
#r "nuget: Plugin.Maui.DocumentScanner, 0.2.0"
#:package Plugin.Maui.DocumentScanner@0.2.0
#addin nuget:?package=Plugin.Maui.DocumentScanner&version=0.2.0
#tool nuget:?package=Plugin.Maui.DocumentScanner&version=0.2.0
Plugin.Maui.DocumentScanner
Native document scanning for .NET MAUI — no paid SDK required.
dotnet add package Plugin.Maui.DocumentScanner
- Android: ML Kit document scanner (full scanner UI, auto-crop, filters; models downloaded via Google Play services)
- iOS: VisionKit document camera for scanning, plus Vision document segmentation with a built-in corner editor for cropping already-taken photos
Supports Android API 23+ (with Google Play services) and iOS 15+.
Setup
Register the plugin in MauiProgram.cs:
builder
.UseMauiApp<App>()
.UseDocumentScanner();
UseDocumentScanner() registers IDocumentScanner in dependency injection and hooks the Android activity-result plumbing — no MainActivity changes needed.
iOS: camera permission
ScanAsync opens the camera, so add a usage description to Platforms/iOS/Info.plist — iOS terminates the app without it:
<key>NSCameraUsageDescription</key>
<string>Scan documents with the camera.</string>
ScanFromPhotosAsync uses the system photo picker and needs no photo-library permission.
Android
No permissions or manifest changes are required. ML Kit downloads its scanner module through Google Play services on first use, so the first scan on a device can take a few seconds longer.
Usage
Inject IDocumentScanner (or use DocumentScanner.Default without DI):
// Camera scan — returns file paths of cropped pages, empty list if the user cancels
IReadOnlyList<string> pages = await scanner.ScanAsync();
// iOS only: pick already-taken photos, then adjust each crop in the corner editor.
// On Android this throws NotSupportedException, so guard it.
if (OperatingSystem.IsIOS())
pages = await scanner.ScanFromPhotosAsync();
// With options
pages = await scanner.ScanAsync(new DocumentScanOptions
{
PageLimit = 3,
Mode = DocumentScannerMode.Base, // Android only: Full, BaseWithFilter, or Base
});
// With cancellation — dismisses the native UI and throws OperationCanceledException
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(2));
pages = await scanner.ScanAsync(cancellationToken: cts.Token);
Check scanner.IsSupported first. On Android ScanAsync throws NotSupportedException when ML Kit reports the device is unsupported (under ~1.7 GB RAM).
Returned files are JPEGs written to the app's cache directory — move or copy them if you need them to persist.
Platform notes
| Android | iOS | |
|---|---|---|
ScanAsync |
ML Kit scanner UI, with an import-from-gallery button | VisionKit document camera |
ScanFromPhotosAsync |
Not supported — ML Kit cannot start in the gallery, so the API throws NotSupportedException |
Photo picker + auto-detected corners + manual corner editor |
PageLimit |
Applies to the scanner | ScanFromPhotosAsync only (VisionKit has no limit) |
Mode |
Full / BaseWithFilter / Base | Ignored |
Sample
The samples/ScanTest app exercises both scan paths and shows page sizes and timings. To deploy it to a physical iPhone, copy ScanTest.local.props.example to ScanTest.local.props and fill in your signing identity.
Changelog
See CHANGELOG.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. |
-
net10.0-android36.0
- Microsoft.Maui.Controls (>= 10.0.20)
- Xamarin.AndroidX.Lifecycle.LiveData.Core (>= 2.11.0.1)
- Xamarin.GooglePlayServices.MLKit.DocumentScanner (>= 116.0.0.3)
-
net10.0-ios26.0
- Microsoft.Maui.Controls (>= 10.0.20)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.