Skip to main content

Classic UI

Our Classic UI components allow you to build custom screens which are flexible and fully customizable. It is a set of easy to integrate components (Views, Buttons, Handlers, Controllers, etc.) which can be embedded and extended in your custom screens.

Document Scanner View

The Document Scanner view exposes a configurable camera view that allows you to detect documents in real time.

Integration prerequisites

Required: Permission validation

Classic components do not automatically validate camera access permissions. It's up to developers to request and secure these permissions within their applications. Before integrating camera functionalities, ensure that your app has obtained the necessary permissions to provide users with a seamless experience.

Classic UI component: Document Scanner

Embed the component in your layout and use the OnSnappedDocumentImageResult callback to handle the document result. The OnUpdateDetectionStatus callback provides the detection status of the document being scanned. Customize the UI and behavior of DocumentScannerView by using the component's properties. Each property is optional, and falls back to its default value if not specified. More on the available properties can be found here.

You can utilize the DocumentScannerView class from xmlns:classicComponent="clr-namespace:ScanbotSDK.MAUI.Document.ClassicComponent;assembly=DocumentSDK.MAUI" to integrate document scanning functionality into your application seamlessly. This component encapsulates the document scanning feature within a single UI component.

Classic UI layout
loading...
Classic UI EventHandlers
loading...
Classic UI EventHandlers Implementation
loading...

Frequent Use Cases

Note: Below information covers MAUI Classic Component only i.e. the DocumentScannerView.

Camera View Visibility

The Scanbot SDK provides a convenient way to control the visibility of the DocumentScannerView, including automatic handling of the camera resource. It is useful when the DocumentScannerView is expected to be hidden completely.

Use the IsVisible property to toggle the visibility of the scanner view. When IsVisible is set to false, scanning stops, the camera preview is turned off, and the DocumentScannerView becomes hidden.

IsVisible Property
documentScannerView.IsVisible = false; // Hides the view and stops scanning.
documentScannerView.IsVisible = true; // Shows the view and resumes scanning.
info

You may also use this property if you need to navigate forward from the DocumentScannerView page to another page and plan to return to it later.

Camera View Start/Stop

The Scanbot SDK DocumentScannerView has the ability to freeze/unfreeze the camera preview. It is useful to showcase the camera preview is stopped(freezed), on the last scanned frame before the freeze operation.

Use the IsCameraFrozen property to freeze/unfreeze the camera preview of the DocumentScannerView. When IsCameraFrozen is set to true, scanning stops and the camera preview is paused on the last scanned frame.

IsCameraFrozen Property
documentScannerView.IsCameraFrozen = false; // Unfreeze the camera preview and resumes the document scanning.
documentScannerView.IsCameraFrozen = true; // Freezes the camera preview and stops the document scanning.
info

You may use this property if you need to navigate forward from the DocumentScannerView page to another page and plan to return to it later. Or you wish to show any popup over the camera preview.

The DocumentScannerView in the Scanbot SDK is a .NET MAUI implementation (wrapper) built using a ViewHandler, which natively integrates the iOS SBSDKDocumentScannerViewController and Android DocumentScannerView.

The .NET MAUI ViewHandler has its own lifecycle methods. For more details, see the official Microsoft documentation.

When navigating between pages, it’s important to properly handle camera resources and view deallocation to avoid potential memory leaks.

DisconnectHandler

The DisconnectHandler() method is responsible for removing and deallocating all native classes and camera resources used by the DocumentScannerView (i.e., the common ViewHandler implementation).

In .NET 9, this method is invoked automatically by the MAUI framework. In .NET 8, it must be handled explicitly by the user, as described below.

You should call DisconnectHandler() only when navigating back (for example, using Navigation.Pop...Async();) from the DocumentScannerView's page. In this case, the SDK automatically disposes of and deallocates all related resources.

If you are navigating forward (for example, using Navigation.PushAsync();) from the DocumentScannerView's page, it is recommended to temporarily disable the camera instead of fully disconnecting it. You can do this by setting either: IsCameraFrozen = true, or IsVisible = false.

When you navigate back to the DocumentScannerView page, simply set: IsCameraFrozen = false, or IsVisible = true, to resume scanning and camera preview functionality.

DisconnectHandler Function
// Invoke only when you are no longer using the scanner again.
// e.g., Navigating back from the Screen (.NET 8 only)
documentScannerView.Handler?.DisconnectHandler();

Note: If you need to invoke DisconnectHandler() regardless of navigation direction, make sure to reinitialize the DocumentScannerView before accessing it again.

Pause/Resume

During the document scanning flow, there may be scenarios where you need to pause the camera to show a popup, or when you navigate to the next page from the DocumentScannerView page with the intention to return later. In such cases, please refer to the CameraView Visibility or the CameraView Start/Stop sections above.

For a fully functional example, please see our .NET and MAUI example apps on GitHub.

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get free trial license