Skip to footer content
USING IRONBARCODE

.NET MAUI Barcode Scanner SDK: Build a Cross-Platform Scanner in Minutes

We all know the promise of .NET MAUI: write code once and deploy it everywhere. But that "seamless" experience often hits a speedbump when you need to integrate hardware features—specifically, barcode scanning.

If you’ve ever tried to manually bridge native camera APIs, you know it can quickly turn into a rabbit hole of platform-specific configurations. It doesn’t have to be that hard. In this tutorial, we’ll skip the hours of setup and use the IronBarcode library to build a working cross-platform scanner in just a few minutes.

Ready to get started? Grab your free trial and let's code.

NuGet Install with NuGet

PM >  Install-Package BarCode

Check out IronBarcode on NuGet for quick installation. With over 10 million downloads, it’s transforming PDF development with C#. You can also download the DLL.

How Do You Set Up a Barcode Scanner SDK in .NET MAUI?

Setting up a .NET MAUI barcode scanner SDK requires creating a new project, installing the NuGet package, and configuring platform permissions. The entire configuration process takes just a few minutes in Visual Studio.

Create the .NET MAUI Project

Open Visual Studio and create a new .NET MAUI App project. Name your MAUI project something descriptive like "BarcodeScanner" and select .NET 8 or later as your target framework. Visual Studio will generate the default project structure with platform-specific folders for Android and iOS.

Install IronBarcode

Install the IronBarcode NuGet package using the Package Manager Console:

Install-Package BarCode

This command downloads and installs the barcode scanner SDK along with all required dependencies for your .NET MAUI application.

Configure Platform Permissions

Even when scanning from image files rather than a live camera, it's good practice to configure the following permissions for your .NET MAUI barcode scanner app.

For Android, add the following to Platforms/Android/AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
XML

For iOS, add these entries to Platforms/iOS/Info.plist:

<key>NSPhotoLibraryUsageDescription</key>
<string>Access needed to select barcode images for scanning.</string>
<key>NSCameraUsageDescription</key>
<string>Camera permission for barcode scanning.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Access needed to select barcode images for scanning.</string>
<key>NSCameraUsageDescription</key>
<string>Camera permission for barcode scanning.</string>
XML

Initialize the SDK

Configure IronBarcode in your MauiProgram.cs file:

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            });
        return builder.Build();
    }
}
public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            });
        return builder.Build();
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Set your license key in your app's initialization code to enable full functionality. IronBarcode offers a free trial license for development and testing.

How Can You Read Barcodes from Image Files?

The core functionality of any MAUI barcode scanner is the ability to read barcodes from selected images. IronBarcode makes this remarkably simple with its BarcodeReader class.

Design the User Interface

Create a clean interface in MainPage.xaml that allows users to select an image file and view the scanned barcode data:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="BarcodeScanner.MainPage">
    <VerticalStackLayout Padding="20" Spacing="15">
        <Label Text=".NET MAUI Barcode Scanner" FontSize="24" HorizontalOptions="Center"/>
        <Button Text="Select Image to Scan" Clicked="OnSelectImageClicked"/>
        <Image x:Name="SelectedImageView" HeightRequest="200"/>
        <Label x:Name="ResultLabel" FontSize="16"/>
    </VerticalStackLayout>
</ContentPage>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="BarcodeScanner.MainPage">
    <VerticalStackLayout Padding="20" Spacing="15">
        <Label Text=".NET MAUI Barcode Scanner" FontSize="24" HorizontalOptions="Center"/>
        <Button Text="Select Image to Scan" Clicked="OnSelectImageClicked"/>
        <Image x:Name="SelectedImageView" HeightRequest="200"/>
        <Label x:Name="ResultLabel" FontSize="16"/>
    </VerticalStackLayout>
</ContentPage>
XML

Implement Barcode Scanning

Add the scanning logic to MainPage.xaml.cs. This code handles image selection and barcode detection:

using IronBarCode;
public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }
    private async void OnSelectImageClicked(object sender, EventArgs e)
    {
        var result = await FilePicker.PickAsync(new PickOptions
        {
            FileTypes = FilePickerFileType.Images,
            PickerTitle = "Select a barcode image"
        });
        if (result != null)
        {
            // Display the selected image
            SelectedImageView.Source = ImageSource.FromFile(result.FullPath);
            // Read barcodes from the image file
            var barcodes = BarcodeReader.Read(result.FullPath);
            if (barcodes.Any())
            {
                ResultLabel.Text = $"Found: {barcodes.First().Value}";
            }
            else
            {
                ResultLabel.Text = "No barcodes detected in selected image.";
            }
        }
    }
}
using IronBarCode;
public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }
    private async void OnSelectImageClicked(object sender, EventArgs e)
    {
        var result = await FilePicker.PickAsync(new PickOptions
        {
            FileTypes = FilePickerFileType.Images,
            PickerTitle = "Select a barcode image"
        });
        if (result != null)
        {
            // Display the selected image
            SelectedImageView.Source = ImageSource.FromFile(result.FullPath);
            // Read barcodes from the image file
            var barcodes = BarcodeReader.Read(result.FullPath);
            if (barcodes.Any())
            {
                ResultLabel.Text = $"Found: {barcodes.First().Value}";
            }
            else
            {
                ResultLabel.Text = "No barcodes detected in selected image.";
            }
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

.NET MAUI Barcode Scanner SDK: Build a Cross-Platform Scanner in Minutes: Image 1 - Scanned barcode output

The BarcodeReader.Read() method analyzes the selected image and returns all detected barcodes. IronBarcode automatically recognizes multiple barcode symbologies including QR codes, Code 128, Code 39, EAN-13, and many other formats.

How Do You Scan Barcodes from PDF Documents?

One powerful capability that sets IronBarcode apart is reading barcodes directly from PDF files. This is essential for .NET MAUI apps handling document workflows.

private async void OnSelectPdfClicked(object sender, EventArgs e)
{
    var result = await FilePicker.PickAsync(new PickOptions
    {
        PickerTitle = "Select a PDF with barcodes"
    });
    if (result != null)
    {
        // Read barcodes from PDF document
        var barcodes = BarcodeReader.ReadPdf(result.FullPath);
        string output = "";
        foreach (var barcode in barcodes)
        {
            output += $"Page {barcode.PageNumber}: {barcode.Value}\n";
        }
        await DisplayAlert("Scan Results", output, "OK");
    }
}
private async void OnSelectPdfClicked(object sender, EventArgs e)
{
    var result = await FilePicker.PickAsync(new PickOptions
    {
        PickerTitle = "Select a PDF with barcodes"
    });
    if (result != null)
    {
        // Read barcodes from PDF document
        var barcodes = BarcodeReader.ReadPdf(result.FullPath);
        string output = "";
        foreach (var barcode in barcodes)
        {
            output += $"Page {barcode.PageNumber}: {barcode.Value}\n";
        }
        await DisplayAlert("Scan Results", output, "OK");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

.NET MAUI Barcode Scanner SDK: Build a Cross-Platform Scanner in Minutes: Image 2 - Output for scanning a PDF with QR codes within it

The ReadPdf() method scans all pages of a PDF and returns barcode data along with page numbers, making it easy to process documents containing multiple barcodes.

How Do You Handle Multiple Barcodes and QR Codes?

For scenarios requiring detection of multiple barcodes from a single scan or specific barcode format filtering, configure the BarcodeReaderOptions class:

var options = new BarcodeReaderOptions
{
    ExpectMultipleBarcodes = true,
    ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128,
    Speed = ReadingSpeed.Balanced
};
var barcodes = BarcodeReader.Read(imagePath, options);
foreach (var barcode in barcodes)
{
    Console.WriteLine($"Type: {barcode.BarcodeType}, Value: {barcode.Value}");
}
var options = new BarcodeReaderOptions
{
    ExpectMultipleBarcodes = true,
    ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128,
    Speed = ReadingSpeed.Balanced
};
var barcodes = BarcodeReader.Read(imagePath, options);
foreach (var barcode in barcodes)
{
    Console.WriteLine($"Type: {barcode.BarcodeType}, Value: {barcode.Value}");
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

This configuration enables scanning for multiple barcodes while limiting detection to specific barcode symbologies for improved performance. The Speed property lets you balance between scanning speed and accuracy based on your app's requirements.

What Are Key Benefits of This Barcode Scanner SDK?

IronBarcode delivers several advantages for .NET MAUI barcode scanning projects:

  • Cross-platform support: Deploy to Android, iOS platforms, and Windows from a single codebase
  • Multiple input sources: Scan barcodes from images, memory streams, and PDF files
  • Extensive format support: Decode barcodes across dozens of 1D and 2D barcode symbologies
  • Simple API: Integrate fast barcode scanning with just a few lines of code
  • No external dependencies: The .NET library works independently without requiring additional native SDKs

Conclusion

Building a .NET MAUI barcode scanner with IronBarcode demonstrates how straightforward it is to integrate barcode scanning functionality into cross-platform applications. From installing the NuGet package to reading barcodes from images and PDFs, the entire process requires minimal configuration and code.

The combination of .NET MAUI's cross-platform framework capabilities and IronBarcode's robust scanning SDK enables developers to build powerful barcode-scanning apps that run seamlessly on mobile and desktop.

Ready to add barcode scanning to your .NET MAUI project? Start your free trial or explore licensing options for production deployment.

Frequently Asked Questions

What is .NET MAUI and how does it relate to barcode scanning?

.NET MAUI is a framework that allows developers to create cross-platform applications with a single codebase. Integrating barcode scanning into a .NET MAUI app can be challenging, but IronBarcode simplifies this process by providing robust tools for scanning and reading barcodes across different platforms.

How can IronBarcode assist in developing a barcode scanner for .NET MAUI apps?

IronBarcode offers a comprehensive library that supports barcode scanning and generation. It streamlines the process of creating a barcode scanner for .NET MAUI apps by offering easy-to-use methods and functions for reading barcodes from images and PDFs.

Is IronBarcode compatible with cross-platform development in .NET MAUI?

Yes, IronBarcode is fully compatible with .NET MAUI, allowing developers to integrate barcode scanning capabilities into applications running on multiple platforms from a single codebase.

What types of barcodes can be scanned using IronBarcode in a .NET MAUI application?

IronBarcode supports a wide range of barcode formats, including QR codes, Code 128, UPC, EAN, and more, making it versatile for various applications in .NET MAUI.

How does IronBarcode simplify barcode scanning in .NET MAUI?

IronBarcode simplifies barcode scanning by providing a unified API that handles barcode detection and reading with minimal code, ensuring a smooth integration into .NET MAUI projects.

What are the advantages of using IronBarcode for PDF barcode reading in MAUI apps?

IronBarcode offers advanced features for extracting barcodes from PDF documents, enabling .NET MAUI developers to add PDF barcode reading functionality easily to their cross-platform apps.

What steps are involved in setting up IronBarcode in a .NET MAUI project?

Setting up IronBarcode in a .NET MAUI project involves installing the IronBarcode NuGet package, importing the necessary namespaces, and utilizing provided methods to implement barcode scanning and reading functionality.

Can IronBarcode handle image-based barcode scanning in .NET MAUI?

Yes, IronBarcode can effectively scan and read barcodes from images, making it a powerful tool for developers looking to implement image-based barcode scanning in their .NET MAUI applications.

Is IronBarcode suitable for real-time barcode scanning in mobile applications?

IronBarcode is designed to handle real-time barcode scanning efficiently, making it suitable for mobile applications developed with .NET MAUI that require quick and accurate barcode data processing.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More