Viewing PDFs in MAUI for C# .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDF Viewer Banner

In the modern era of cross-platform development, providing users with the ability to view PDF documents directly within your app is not just a convenience, but a necessity. With the IronPDF Viewer, you can embed PDF viewing functionality into your MAUI application.

In this article, we will learn how to integrate IronPDF Viewer within a MAUI application to allow users the ability to view, save, and print PDFs.

Quickstart: Viewing PDFs in MAUI with IronPDF

Integrate IronPDF into your MAUI application with ease and start viewing PDFs effortlessly. This simple code snippet demonstrates how to instantiate the IronPDF PdfViewer and load a PDF file for immediate viewing. Perfect for developers looking to enhance their app's PDF viewing capabilities without complexity.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    new IronPdf.Viewer.Maui.PdfViewer { Source = "document.pdf" };
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer


Download and Install the IronPDF Viewer Library

Comience a usar IronPDF en su proyecto hoy con una prueba gratuita.

Primer Paso:
green arrow pointer

Visual Studio - NuGet Package Manager

In Visual Studio, right-click on your project in the solution explorer and select Manage NuGet Packages.... From there, you can search for IronPdf.Viewer.Maui and install the latest version to your solution. Alternatively, you can open the NuGet Package Manager console by navigating to Tools > NuGet Package Manager > Package Manager Console and entering the following command:

Install-Package IronPdf.Viewer.Maui

Integrate IronPDF Viewer into a MAUI Application

In the following sections, we will demonstrate how to integrate IronPDF Viewer into a default MAUI application.

Setup

Before adding IronPDF Viewer to your MAUI project, ensure it does not target the iOS and Android platforms. You can check this by right-clicking on the project file and selecting Properties. Uncheck the Target the iOS Platform and Target the Android platform checkboxes if they are not unchecked already. For this change to be successfully implemented, you may need to save the project after unchecking and restart Visual Studio.

Properties Screen

After untargeting the iOS and Android platforms, go to your MauiProgram.cs file and add the following code to initialize the viewer:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-1.cs
using IronPdf.Viewer.Maui;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            // other configuration options ...
            .ConfigureIronPdfView(); // configure the viewer on app start-up

        return builder.Build();
    }
}
Imports IronPdf.Viewer.Maui

Public Module MauiProgram
	Public Function CreateMauiApp() As MauiApp
		Dim builder = MauiApp.CreateBuilder()
		builder.UseMauiApp(Of App)().ConfigureIronPdfView() ' configure the viewer on app start-up

		Return builder.Build()
	End Function
End Module
$vbLabelText   $csharpLabel

By default, the IronPDF Viewer will display a banner at the bottom-right of the view. To remove this view, add your IronPDF (or Iron Suite) license key to ConfigureIronPdfViewer like so:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-2.cs
.ConfigureIronPdfView("YOUR-LICENSE-KEY");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Add a PDF Viewer Page

In this section, we will learn how to create a PDF Viewer page, integrate IronPDF Viewer, and create a tab for it in a MAUI application. We will demonstrate how to do this with both a XAML and C# ContentPage.

Steps

  1. Add a new page to your project by right-clicking on your project, then navigate to Add > New Item... Add New Item

  2. Navigate to the .NET MAUI section. To create a XAML page, select .NET MAUI ContentPage (XAML). For a C# file, select .NET MAUI ContentPage (C#). Give your file the name PdfViewerPage, then click Add. .NET MAUI `ContentPage`

  3. In the XAML file, add the following code and save:
:path=/static-assets/pdf/tutorials/pdf-viewing/pdf-viewing-xaml-1.xml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage ...
    xmlns:ipv="clr-namespace:IronPdf.Viewer.Maui;assembly=IronPdf.Viewer.Maui"
    ...>
    <ipv:IronPdfView x:Name="pdfView"/>
</ContentPage>
XML

If you created a C# ContentPage instead, add the following code instead and save:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-3.cs
using IronPdf.Viewer.Maui;

public class MainPage : ContentPage
{
    private readonly IronPdfView pdfView;

    public MainPage()
    {
        InitializeComponent();

        this.pdfView = new IronPdfView { Options = IronPdfViewOptions.All };

        Content = this.pdfView;
    }
}
Imports IronPdf.Viewer.Maui

Public Class MainPage
	Inherits ContentPage

	Private ReadOnly pdfView As IronPdfView

	Public Sub New()
		InitializeComponent()

		Me.pdfView = New IronPdfView With {.Options = IronPdfViewOptions.All}

		Content = Me.pdfView
	End Sub
End Class
$vbLabelText   $csharpLabel
  1. In your AppShell.xaml file, add the following:
:path=/static-assets/pdf/tutorials/pdf-viewing/pdf-viewing-xaml-2.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Shell ...
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    ...>
  <TabBar x:Name="AppTabBar">
      <Tab Title="Home">
        <ShellContent ContentTemplate="{DataTemplate local:MainPage}" Route="MainPage"/>
      </Tab>
      <Tab Title="PDF Viewer">
        <ShellContent ContentTemplate="{DataTemplate local:PdfViewerPage}" Route="PDFViewer"/>
    </Tab>
  </TabBar>
</Shell>
XML
  1. Save your project, then build and run. You should see tabs in the top-left corner as shown below, and clicking on the "PDF Viewer" tab should open the IronPDF Viewer.

IronPDF Viewer Default

Load a PDF on Start-Up

On the start-up of the application, IronPDF Viewer will prompt the user to open a PDF by default. It is possible for it to open a PDF automatically on start-up, as well. There are three ways in which you can load a PDF on start-up: by a filename, through a byte array, and through a stream.

Load by Filename

To load a PDF by filename, you could specify the source of the PDF file in the IronPdfView tag in the XAML file. An example of this is shown below:

:path=/static-assets/pdf/tutorials/pdf-viewing/pdf-viewing-xaml-3.xml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage ...
    xmlns:ipv="clr-namespace:IronPdf.Viewer.Maui;assembly=IronPdf.Viewer.Maui"
    ...>
    <ipv:IronPdfView Source="C:/path/to/my/example.pdf" />
</ContentPage>
XML

Alternatively, you can load the PDF by filename by using the IronPdfViewSource.FromFile method in a C# ContentPage:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-4.cs
// We assume an IronPdfView instance is created previously called pdfView
pdfView.Source = IronPdfViewSource.FromFile("C:/path/to/my/example.pdf");
' We assume an IronPdfView instance is created previously called pdfView
pdfView.Source = IronPdfViewSource.FromFile("C:/path/to/my/example.pdf")
$vbLabelText   $csharpLabel

Load Through Byte Array

For some use cases, it may be desirable to load a byte array of a PDF. This is not possible from XAML, but is possible in C#. You can achieve this by simply using the IronPdfViewSource.FromBytes method. An example of how to use this method is shown below:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-5.cs
pdfView.Source = IronPdfViewSource.FromBytes(File.ReadAllBytes("~/Downloads/example.pdf"));
pdfView.Source = IronPdfViewSource.FromBytes(File.ReadAllBytes("~/Downloads/example.pdf"))
$vbLabelText   $csharpLabel

Load Through Stream

Similarly, it may be more desirable for PDFs to be loaded through a stream in some use cases. This is not possible from XAML, but is possible in C#. You can achieve this by simply using the IronPdfViewSource.FromStream method. An example of how to use this method is shown below:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-6.cs
pdfView.Source = IronPdfViewSource.FromStream(File.OpenRead("~/Downloads/example.pdf"));
pdfView.Source = IronPdfViewSource.FromStream(File.OpenRead("~/Downloads/example.pdf"))
$vbLabelText   $csharpLabel

Configure the Toolbar

With IronPDF Viewer, you can choose what options to display in the toolbar. The available options are:

  • Thumbnail view
  • Filename display
  • Text search
  • Page number navigation
  • Zoom
  • Fit to width
  • Fit to height
  • Rotate clockwise
  • Rotate counterclockwise
  • Open file
  • Download file
  • Print file
  • Display annotations
  • Two-page view

By default, IronPDF Viewer will display the toolbar shown below:

Default Toolbar

In the default view, the filename display, text search, and rotate counterclockwise options are all disabled. To display everything, set the Option parameter of the IronPdfView tag in the XAML to be All:

:path=/static-assets/pdf/tutorials/pdf-viewing/pdf-viewing-xaml-4.xml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage ...
    xmlns:ipv="clr-namespace:IronPdf.Viewer.Maui;assembly=IronPdf.Viewer.Maui"
    ...>
    <ipv:IronPdfView x:Name="pdfView" Options="All"/>
</ContentPage>
XML

Alternatively, you could achieve the same in C#:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-7.cs
pdfView.Options = IronPdfViewOptions.All;
pdfView.Options = IronPdfViewOptions.All
$vbLabelText   $csharpLabel

Which will display the following:

All Toolbar

If you don't want to display anything, set the option to None. The toolbar will not appear if Options are set to this:

No Toolbar

You can choose which specific options you would like to display. For instance, if you wanted to display only the thumbnail and open file options, modify the Options parameter of IronPdfView in XAML like so:

:path=/static-assets/pdf/tutorials/pdf-viewing/pdf-viewing-xaml-5.xml
<ipv:IronPdfView x:Name="pdfView" Options="Thumbs, Open"/>
XML

Similarly, in C#:

:path=/static-assets/pdf/content-code-examples/tutorials/pdf-viewing-8.cs
pdfView.Options = IronPdfViewOptions.Thumbs | IronPdfViewOptions.Open;
pdfView.Options = IronPdfViewOptions.Thumbs Or IronPdfViewOptions.Open
$vbLabelText   $csharpLabel

Which will display the following:

Toolbar with thumbnail and open file options

Conclusion

In this tutorial, we learned how to integrate IronPDF Viewer into a MAUI application and how to customize its toolbar to best suit your needs.

This viewer comes with our IronPDF product. If you would like to make a feature request or have any general questions about IronPDF Viewer (or IronPDF), please contact our support team. We will be more than happy to assist you.

Preguntas Frecuentes

¿Cómo puedo ver archivos PDF en una aplicación MAUI?

Para ver PDFs en una aplicación MAUI, puedes integrar IronPDF Viewer instalándolo desde el Administrador de paquetes NuGet de Visual Studio y agregando el código requerido a tu proyecto.

¿Qué pasos son necesarios para integrar un visor de PDF en una aplicación MAUI?

Asegúrate de que tu proyecto MAUI sea compatible, descarga la biblioteca IronPDF Viewer a través de NuGet e inicializa el visor en tu archivo _MauiProgram.cs_ utilizando tu clave de licencia de IronPDF.

¿Cómo cargo un archivo PDF cuando mi aplicación MAUI se inicia?

Puedes cargar un PDF al inicio configurando la fuente en el archivo XAML o empleando métodos como IronPdfViewSource.FromFile, FromBytes o FromStream en tu C# ContentPage.

¿Cómo puedo personalizar la barra de herramientas en el visor de PDF para MAUI?

Personaliza la barra de herramientas configurando el parámetro 'Options' en el código XAML o C# para incluir funciones como vista en miniatura, búsqueda de texto, zoom y más, o configúralo en 'All' para obtener funcionalidad completa.

¿Es posible ocultar la barra de herramientas en el visor de PDF de MAUI?

Sí, configurando el parámetro 'Options' en 'None', puedes ocultar la barra de herramientas y evitar que muestre cualquier herramienta.

¿Cuáles son algunos pasos comunes de solución de problemas para el visor de PDF en MAUI?

Asegúrate de que IronPDF Viewer esté correctamente instalado a través de NuGet, verifica la compatibilidad de tu proyecto y comprueba que cualquier código necesario, como la inicialización de la clave de licencia, esté correctamente implementado en los archivos de tu proyecto.

¿Puedo usar el visor de PDF en aplicaciones MAUI que apunten a iOS o Android?

Actualmente, el visor de IronPDF no admite proyectos MAUI que apunten a plataformas iOS o Android. Asegúrate de que tu proyecto apunte a plataformas compatibles.

¿Cómo hago solicitudes de características u obtengo soporte para el visor de PDF?

Para solicitudes de características o soporte, contacta al equipo de soporte de IronPDF a través de su sitio web oficial para obtener asistencia con el visor de PDF.

¿Es IronPDF Viewer compatible con .NET 10 en proyectos MAUI?

Sí, IronPDF es totalmente compatible con .NET 10, al igual que con versiones anteriores como .NET 6, .NET 7 y .NET Core. Esto incluye el uso de IronPDF en aplicaciones MAUI orientadas a .NET 10 sin necesidad de configuraciones especiales ni soluciones alternativas.

Jordi Bardia
Ingeniero de Software
Jordi es más competente en Python, C# y C++. Cuando no está aprovechando sus habilidades en Iron Software, está programando juegos. Compartiendo responsabilidades para pruebas de productos, desarrollo de productos e investigación, Jordi agrega un valor inmenso a la mejora continua del producto. La experiencia variada lo mantiene ...
Leer más
¿Listo para empezar?
Nuget Descargas 16,133,208 | Versión: 2025.11 recién lanzado