Get Started Pixelnetica™ Document Scanning SDK for .NET MAUI
Installation
The Pixelnetica Document Scanning SDK for .NET MAUI is distributed as a NuGet package. To install the Pixelnetica.DocScanSDK.Maui package in Visual Studio:
- Open your solution in Visual Studio.
- Select the target project and go to
Project→Manage NuGet Packages. - Ensure
nuget.orgis set as the package source and search forPixelnetica.DocScanSDK.Maui. - Click
Installto add the DSSDK package to your project.
After installation, the SDK is referenced in your project and ready to use.
Permissions
Android Permissions
Add the following entries to your app’s AndroidManifest.xml file:
Require OpenGL ES 2.0 support:
<uses-feature android:glEsVersion="0x00020000" android:required="true" />Enable large heap and hardware acceleration in the
<application>tag:<application android:label="@string/ApplicationName" android:icon="@drawable/Icon" android:largeHeap="true" android:hardwareAccelerated="true">Request camera and flashlight access:
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.FLASHLIGHT" />
iOS Permissions
To allow document scanning from the camera and photo library, add the following keys to your app’s Info.plist file:
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera to take document photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library to load documents.</string>
Initialization
Initialize DSSDK before using it. Initialization must be performed only once per application lifetime.
Pass your license key as a parameter to UsePixelnetica(). The license key can be loaded from a variable, a file, or another storage mechanism. If UsePixelnetica() is called without parameters, the SDK will attempt to locate the license key in the default locations of the main application project:
Resources/Raw/Android_License.key— Android license keyResources/Raw/iOS_License.key— iOS license key
For both files, set the Build Action to MauiAsset.
It is recommended to embed the license key directly in the application code. This approach ensures maximum availability and security; however, it reduces flexibility, as any license update will require recompilation of the application.
SDK initialization requires a call to UsePixelnetica inside the CreateMauiApp method. The following example shows how to add UsePixelnetica to an existing CreateMauiApp implementation:
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UsePixelnetica() // or .UsePixelnetica(LicenseKeyString)
.UseMauiCommunityToolkit()
Alternatively, the license key can be stored on an external server and retrieved at runtime during SDK initialization. Be aware that this approach introduces a dependency on server availability: users without network access will not be able to use the SDK.
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UsePixelnetica(DeviceInfo.Current.Platform == DevicePlatform.Android ? AndroidKey : iOSKey) // AndroidKey and iOSKey are string values containing the Android and iOS licenses
.UseMauiCommunityToolkit()