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: Implementing IronPDF Viewer in MAUI

Get started with integrating the IronPDF Viewer in your MAUI application with just a few lines of code. This quick guide demonstrates how to effortlessly load a PDF file using IronPDF's powerful library. Ideal for developers eager to enhance their apps with seamless PDF viewing capabilities, this approach highlights ease of use and rapid implementation. Simply initialize the IronPDF Viewer and load your PDF to enable convenient PDF viewing in your app.

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.

    var viewer = 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 PDFs en una aplicación MAUI usando C#?

Para ver PDFs en una aplicación MAUI usando C#, puedes integrar la biblioteca IronPDF Viewer. Esto implica instalar la biblioteca a través de NuGet en Visual Studio y configurarla dentro de tu proyecto para habilitar las funciones de visualización de PDF.

¿Cuál es el proceso para integrar un visor de PDF en una aplicación MAUI?

Integrar un visor de PDF en una aplicación MAUI requiere instalar la biblioteca IronPDF Viewer usando NuGet Package Manager y configurar el visor en tu proyecto usando MauiProgram.cs y XAML o ContentPage de C# para mostrar PDFs.

¿Puede el IronPDF Viewer usarse en plataformas iOS y Android en un proyecto MAUI?

Actualmente, el IronPDF Viewer está diseñado para proyectos MAUI que no tienen como objetivo plataformas iOS y Android. Es mejor utilizarlo en proyectos dirigidos a entornos de escritorio.

¿Cómo cargo un archivo PDF al iniciar la aplicación en mi proyecto MAUI?

Puedes cargar un archivo PDF en el inicio utilizando los métodos de IronPDF Viewer como IronPdfViewSource.FromFile, FromBytes o FromStream dentro de tu aplicación MAUI.

¿Cuáles son las opciones de configuración de la barra de herramientas para IronPDF Viewer?

La barra de herramientas de IronPDF Viewer se puede personalizar para incluir opciones como vista en miniatura, búsqueda de texto, navegación por páginas, zoom, rotación y operaciones de archivo. Puedes configurarlo para mostrar todas las opciones, ninguna, o solo herramientas específicas según tus requerimientos.

¿Cómo personalizo la barra de herramientas del visor de PDF?

Para personalizar la barra de herramientas para mostrar herramientas específicas, ajusta el parámetro 'Options' en tu código XAML o C# para incluir solo las opciones deseadas, como 'ThumbnailView,OpenFile'.

¿Es posible ocultar la barra de herramientas en IronPDF Viewer?

Sí, puedes ocultar la barra de herramientas configurando el parámetro 'Options' en 'None', lo que eliminará la barra de herramientas de la interfaz del visor.

¿Cómo puedo abordar problemas con la representación de PDF en una aplicación MAUI?

Si encuentras problemas con la representación de PDF en una aplicación MAUI, asegúrate de que la biblioteca IronPDF esté correctamente instalada y configurada. Además, verifica cualquier limitación específica de la plataforma o busca soporte del equipo técnico de IronPDF.

¿Dónde puedo encontrar soporte para integrar IronPDF Viewer en aplicaciones MAUI?

Puedes comunicarte con el equipo de soporte de IronPDF a través de su sitio web oficial para obtener asistencia o realizar solicitudes de características relacionadas con la integración de IronPDF Viewer en aplicaciones MAUI.

¿IronPDF Viewer es totalmente compatible con proyectos .NET 10?

Sí. IronPDF es compatible con .NET 10 en todas sus principales líneas de productos, incluido el componente Viewer para aplicaciones MAUI. El paquete IronPDF Viewer es compatible con plataformas de destino como net10.0-windows y net10.0-maccatalyst, lo que permite a los desarrolladores integrar la funcionalidad de visualización de PDF en proyectos .NET 10 de escritorio sin necesidad de soluciones alternativas.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 16,154,058 | Versión: 2025.11 recién lanzado