Viewing PDFs in MAUI for C# .NET
View PDFs directly in your MAUI application using IronPDF Viewer, which provides a full-featured PDF viewing component with toolbar options for navigation, zoom, search, and printing in just one line of code.
Cross-platform applications often need to display PDF documents directly within the app. The IronPDF Viewer lets you embed PDF viewing functionality into your MAUI application, enabling document viewing across Windows and macOS platforms.
The IronPDF Viewer is a free-to-use component from the team behind the IronPDF library. It installs as a package in its own right and provides native integration with .NET MAUI applications, and applying an IronPDF or Iron Suite license key removes the branding banner it displays by default.
This article shows how to integrate IronPDF Viewer within a MAUI application to allow users to view, save, and print PDFs. The sections that follow cover installing the package, adding the viewer to a page, loading a document on start-up, and configuring the toolbar to suit your application.
Quickstart: Viewing PDFs in MAUI with IronPDFIntegrate IronPDF into your MAUI application and start viewing PDFs immediately. This code snippet demonstrates how to instantiate the IronPdfView control and load a PDF file for viewing. The view's Source is an IronPdfViewSource, which you build with one of its static factory methods:
-
1Install IronPDF with NuGet Package Manager
-
2Copy and run this code snippet.
new IronPdf.Viewer.Maui.IronPdfView { Source = IronPdf.Viewer.Maui.IronPdfViewSource.FromFile("document.pdf") };New IronPdf.Viewer.Maui.IronPdfView With { .Source = IronPdf.Viewer.Maui.IronPdfViewSource.FromFile("document.pdf") }New IronPdf.Viewer.Maui.IronPdfView With { .Source = IronPdf.Viewer.Maui.IronPdfViewSource.FromFile("document.pdf") } -
3Deploy to test on your live environment
Start using IronPDF in your project today with a free trial
Minimal Workflow (5 steps)
- Download and install the IronPDF Viewer library
- Integrate IronPDF Viewer into a MAUI Application
- Add a PDF viewer page by adding either XAML or C#
ContentPage - Load a PDF on start-up by filename, Byte Array, and Stream
- Configure the toolbar
How Do I Download and Install the IronPDF Viewer Library?
How Do I Install via NuGet Package Manager?
In Visual Studio, right-click on your project in the solution explorer and select Manage NuGet Packages.... From there, search for IronPdf.Viewer.Maui and install the latest version to your solution. For more detailed installation guidance, consult our Installation Overview. Alternatively, open the NuGet Package Manager console by navigating to Tools > NuGet Package Manager > Package Manager Console and entering the following command:
The IronPDF Viewer package is self-contained and includes everything needed to display PDFs in MAUI applications. It carries its own rendering engine and does not take a dependency on the core IronPdf package, so you can add it to a project that does not otherwise use IronPDF.
The package ships net7.0-windows10.0.19041 and net7.0-maccatalyst16.1 assemblies, which makes .NET 7 the minimum rather than a limit. A MAUI project targeting a later version of .NET resolves the same assemblies under NuGet's framework compatibility rules, and the steps on this page were verified against both a .NET 9 and a .NET 10 MAUI application on Windows. If you are working on .NET 10, see the note under loading by filename for the one build setting you will need. It is also worth knowing that IronPdf.Viewer.Maui carries its own version number, separate from the core IronPdf package, so the two will not match when you browse NuGet.
How Do I Integrate IronPDF Viewer into a MAUI Application?
The following sections demonstrate how to integrate IronPDF Viewer into a default MAUI application, from untargeting the mobile platforms through to initializing the viewer on start-up.
What Setup Is Required Before Integration?
Before adding IronPDF Viewer to your MAUI project, ensure it does not target iOS and Android platforms. Currently, the IronPDF Viewer supports Windows and macOS desktop platforms.
Right-click the project and select Properties, then open Application → General. Scroll to the iOS Targets and Android Targets sections and clear the two checkboxes underlined below, Enable targeting of the iOS platform. and Enable targeting of the Android platform. Save the project afterwards. You may need to reload it for the change to take effect.
Editing the project file directly does the same thing and is quicker to verify. Replace the generated TargetFrameworks lines with the single platform you are building for:
<TargetFrameworks>net10.0-windows10.0.19041.0</TargetFrameworks>
After untargeting iOS and Android platforms, go to your MauiProgram.cs file and add the following code to initialize the viewer:
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();
}
}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 ModuleImports 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 ModuleBy default, the IronPDF Viewer displays a banner at the bottom-right of the view. To remove this banner, add your IronPDF (or Iron Suite) license key to ConfigureIronPdfView:
.ConfigureIronPdfView("YOUR-LICENSE-KEY");.ConfigureIronPdfView("YOUR-LICENSE-KEY");.ConfigureIronPdfView("YOUR-LICENSE-KEY").ConfigureIronPdfView("YOUR-LICENSE-KEY")For detailed information on obtaining and applying license keys, refer to our License Keys guide.
How Do I Add a PDF Viewer Page?
This section covers how to create a PDF Viewer page, integrate IronPDF Viewer, and create a tab for it in a MAUI application. We demonstrate this with both a XAML and C# ContentPage. Choose the approach that best fits your development style and project requirements.
What Are the Steps to Add a Viewer Page?
- Add a new page to your project by right-clicking on your project, then navigate to
Add > New Item... - Navigate to the
.NET MAUIsection. To create a XAML page, select.NET MAUI ContentPage (XAML). For a C# file, select.NET MAUI ContentPage (C#). Give your file the namePdfViewerPage, then clickAdd. - In the XAML file, add the following code and save:
<?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>
If you created a C# ContentPage instead, add the following code and save. A code-only page has no XAML behind it, so there is no generated InitializeComponent to call. Build the view and assign it to Content directly:
using IronPdf.Viewer.Maui;
public class PdfViewerPage : ContentPage
{
private readonly IronPdfView pdfView;
public PdfViewerPage()
{
this.pdfView = new IronPdfView { Options = IronPdfViewOptions.All };
Content = this.pdfView;
}
}
-
In your
AppShell.xamlfile, add the following to create navigation tabs:<?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 -
Save your project, then build and run. You should see tabs in the top-left corner as shown below. Clicking on the "PDF Viewer" tab opens the IronPDF Viewer. The viewer provides a feature-rich interface for PDF document interaction.
How Can I Load a PDF on Start-Up?
On application start-up, IronPDF Viewer prompts the user to open a PDF by default. However, it can open a PDF automatically on start-up, which improves the user experience for applications that need to display specific documents immediately. You can load a PDF on start-up in three ways: by filename, through a byte array, and through a stream. The method you choose depends on where the PDF comes from and how your application is structured.
How Do I Load by Filename?
To load a PDF by filename, specify the source of the PDF file in the IronPdfView tag in the XAML file. This is the simplest approach when working with local files:
<?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>
On .NET 10, setting Source from XAML needs one project setting. The .NET 10 MAUI project template switches XAML compilation to a source generator by adding <MauiXamlInflator>SourceGen</MauiXamlInflator> to the .csproj, and the generated code cannot reach the internal type converter that turns the Source string into an IronPdfViewSource. The build fails with:
error CS0122: 'be' is inaccessible due to its protection level
Opt that one page out of the source generator in your .csproj:
<ItemGroup>
<MauiXaml Update="PdfViewerPage.xaml" Inflator="Runtime" />
</ItemGroup>
Setting <MauiXamlInflator>Runtime</MauiXamlInflator> for the whole project works too, as does deleting the property the template added. Only Source is affected. Options compiles cleanly under the source generator, and assigning Source from C# sidesteps the problem entirely. A project that does not set MauiXamlInflator, including anything on .NET 9 or earlier, needs no change.
With a Source set, the viewer skips the file prompt and renders the document as soon as the page opens:
Alternatively, load the PDF by filename programmatically using the IronPdfViewSource.FromFile method in a C# ContentPage. This approach offers more flexibility for dynamic file loading:
// 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");' 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")How Do I Load Through Byte Array?
When working with PDFs stored in databases or received from web services, you may need to load a byte array of a PDF. This is not possible from XAML, but you can achieve it in C# using the IronPdfViewSource.FromBytes method:
string file = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads", "example.pdf");
pdfView.Source = IronPdfViewSource.FromBytes(File.ReadAllBytes(file));
This method is useful when integrating with document management systems or when PDFs are generated dynamically using IronPDF's HTML to PDF capabilities.
How Do I Load Through Stream?
For PDFs that reach your application as a stream, such as a network response or a database reader, use the IronPdfViewSource.FromStream method in C#:
string file = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads", "example.pdf");
pdfView.Source = IronPdfViewSource.FromStream(File.OpenRead(file));
This keeps the loading code close to whatever is already producing the stream, rather than writing the document out to disk first.
How Do I Configure the Toolbar?
With IronPDF Viewer, you can choose which controls appear in the toolbar, so the interface shows only the features your users need. Set the Options property on IronPdfView to any combination of the following flags:
IronPdfViewOptions flag | Toolbar control |
|---|---|
Thumbs | Thumbnail panel toggle |
FileName | Filename display |
Search | Text search |
Navigation | Page number and page back/forward |
Zoom | Zoom out, zoom level, zoom in |
FitWidth | Fit to width |
FitHeight | Fit to height |
RotateCw | Rotate clockwise |
RotateCcw | Rotate counterclockwise |
Open | Open file |
Save | Download file |
Print | Print file |
More | Overflow (⋮) menu |
Two composite values are also defined: All, which turns on every flag above, and Default, which is what you get when you do not set Options at all.
By default, IronPDF Viewer displays the toolbar shown below:
The default omits four controls: filename display, text search, rotate counterclockwise, and download file. To display everything, set the Options parameter of the IronPdfView tag in the XAML to All:
<?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>
Alternatively, achieve the same in C#:
pdfView.Options = IronPdfViewOptions.All;pdfView.Options = IronPdfViewOptions.All;pdfView.Options = IronPdfViewOptions.AllpdfView.Options = IronPdfViewOptions.AllThis displays the full toolbar, adding the filename, the search icon, rotate counterclockwise, and the download button:
To hide the toolbar completely, set the option to None:
<ipv:IronPdfView x:Name="pdfView" Options="None"/>
The document then fills the whole view with no chrome above it, which suits a kiosk or read-only screen:
You can choose specific options to display. For instance, to display only the thumbnail and open file options, modify the Options parameter of IronPdfView in XAML:
<ipv:IronPdfView x:Name="pdfView" Options="Thumbs, Open"/>
Similarly, in C#:
pdfView.Options = IronPdfViewOptions.Thumbs | IronPdfViewOptions.Open;pdfView.Options = IronPdfViewOptions.Thumbs | IronPdfViewOptions.Open;pdfView.Options = IronPdfViewOptions.Thumbs Or IronPdfViewOptions.OpenpdfView.Options = IronPdfViewOptions.Thumbs Or IronPdfViewOptions.OpenThis displays:
This level of control lets you tailor the viewer to the application. You might remove the download option in a secure document viewer, for example, or strip the interface back for a simple read-only screen.
Can I Download the Finished Project?
A complete, runnable version of everything covered above is available to download as a MAUI sample project (285 KB). It targets .NET 10 on Windows, references IronPdf.Viewer.Maui, and includes the MauiProgram.cs registration, the viewer page, the tabbed AppShell, and a sample PDF to open.
Unzip it and build from the folder containing the solution:
dotnet build -f net10.0-windows10.0.19041.0
dotnet run --project IronPdfViewerMauiSample -f net10.0-windows10.0.19041.0
You can also open IronPdfViewerMauiSample.slnx in Visual Studio and press F5. When the app starts, click the PDF Viewer tab, choose Browse file, and pick the included sample.pdf to test it out yourself. Building it requires the .NET MAUI workload, which you can install with dotnet workload install maui.
Conclusion
This tutorial covered installing IronPDF Viewer, adding it to a MAUI page in either XAML or C#, loading a PDF by filename, byte array, or stream, and configuring which toolbar controls appear. Between the two approaches you can fit the viewer into whichever structure your project already uses.
The viewer sits alongside IronPDF itself, which handles PDF generation, editing, and manipulation. 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 happy to assist you.
For more advanced PDF operations, see rasterizing a PDF to images or learn about applying license keys for production use of IronPDF.
Frequently Asked Questions
What is IronPDF Viewer used for in a .NET MAUI application?
IronPDF Viewer is used to integrate full-featured PDF viewing capabilities into a .NET MAUI application, offering functionalities like navigation, zoom, search, and printing.
How do I install the IronPDF Viewer library?
You can install the IronPDF Viewer library via the NuGet Package Manager in Visual Studio by searching for 'IronPdf.Viewer.Maui' and installing the latest version to your solution.
Is IronPDF Viewer supported on iOS and Android platforms?
No, currently IronPDF Viewer supports Windows and macOS desktop platforms and does not target iOS and Android.
How do I integrate IronPDF Viewer into a MAUI application?
To integrate IronPDF Viewer, you should ensure your project targets Windows and macOS, add the viewer configuration in the 'MauiProgram.cs' file, and initialize the viewer using the 'ConfigureIronPdfView' method.
What options are available for toolbar configuration in IronPDF Viewer?
The toolbar in IronPDF Viewer can be configured to display options like thumbnail view, filename display, text search, navigation, zoom, rotation, file opening, downloading, and printing controls.
Can I load a PDF automatically on application start-up with IronPDF Viewer?
Yes, IronPDF Viewer allows you to load a PDF automatically on start-up by specifying the file source using methods like 'FromFile', 'FromBytes', or 'FromStream'.
How do I create a PDF Viewer page in a MAUI application with IronPDF?
To create a PDF Viewer page, add a new .NET MAUI ContentPage to your project, integrate IronPDF Viewer, and include navigation tabs in the 'AppShell.xaml' file.
What are the benefits of using IronPDF Viewer in enterprise applications?
IronPDF Viewer provides a smooth and feature-rich PDF viewing experience, making it ideal for enterprise applications that require reliable document display, like document management systems or educational software.
How can I manage PDF loading using a byte array in IronPDF Viewer?
You can load PDFs from a byte array using the 'IronPdfViewSource.FromBytes' method, which is helpful when dealing with PDFs from databases or web services.
What should I do to change or apply a license key for IronPDF Viewer?
To apply a license key, include it in the 'ConfigureIronPdfView' method. Refer to the 'License Keys guide' for obtaining and applying license keys. A key removes the viewer's branding banner.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.