IronPDF How-Tos XAML to PDF (MAUI) How to Convert XAML to PDF in MAUI Chaknith Bin Updated:August 20, 2025 .NET MAUI (Multi-platform App UI) is a cross-platform framework for building native device applications. It extends from Xamarin.Forms and is part of the unified .NET 6 ecosystem. It enables .NET application developers to create applications for desktop, web, and mobile platforms using common UI components and a single codebase. MAUI also allows you to add platform-specific code and resources when necessary. IronPdf allows you to generate PDF documents from MAUI pages, making the creation of PDF files/pages possible in these applications. However, IronPdf currently does not support mobile platforms. Get started making PDFs with NuGet now: Install IronPDF with NuGet Package Manager PM > Install-Package IronPdf Copy and run this code snippet. await new ChromePdfRenderer().RenderContentPageToPdfAsync<MainPage, App>().Result.SaveAs("page.pdf"); Deploy to test on your live environment Start using IronPDF in your project today with a free trial Free 30 day Trial How to Convert XAML to PDF in MAUI Download the IronPdf C# library for MAUI Modify the MainPage.xaml.cs file to use the RenderContentPageToPdf method Update the button in the MainPage.xaml file to trigger the new function Export the PDF document or view it in the MAUI app using a PDF viewer Download the sample MAUI project for a quick start IronPdf Extension Package The IronPdf.Extensions.Maui package is the extension of the IronPdf main package. Since it is an extension, the IronPdf main package is still needed to render the content page of a MAUI application to a PDF document. Install-Package IronPdf.Extensions.Maui Install with NuGet Install-Package IronPdf.Extensions.Maui nuget.org/packages/IronPdf.Extensions.Maui/ Render MAUI Page to a PDF Edit MainPage.xaml.cs File Go from the MainPage.xaml file to its code file, MainPage.xaml.cs. Change the function named OnCounterClicked to PrintToPdf. Use the code sample below. To turn your MAUI page to a PDF, use the RenderContentPageToPdf method. The method can be accessed by instantiating the ChromePdfRenderer class. This method will give you a PdfDocument object, which you can save or view using the SaveAs method or a PDF viewer with Viewing PDFs in MAUI. Please noteThe RenderContentPageToPdf method does not support data binding yet. :path=/static-assets/pdf/content-code-examples/how-to/xaml-to-pdf-maui-mainpage-xaml-cs.cs using IronPdf.Extensions.Maui; namespace mauiSample; public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } private void PrintToPdf(object sender, EventArgs e) { ChromePdfRenderer renderer = new ChromePdfRenderer(); // Apply HTML header renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter() { HtmlFragment = "<h1>Header</h1>", }; // Render PDF from Maui Page PdfDocument pdf = renderer.RenderContentPageToPdf<MainPage, App>().Result; pdf.SaveAs(@"C:\Users\lyty1\Downloads\contentPageToPdf.pdf"); } } Imports IronPdf.Extensions.Maui Namespace mauiSample Partial Public Class MainPage Inherits ContentPage Public Sub New() InitializeComponent() End Sub Private Sub PrintToPdf(ByVal sender As Object, ByVal e As EventArgs) Dim renderer As New ChromePdfRenderer() ' Apply HTML header renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {.HtmlFragment = "<h1>Header</h1>"} ' Render PDF from Maui Page Dim pdf As PdfDocument = renderer.RenderContentPageToPdf(Of MainPage, App)().Result pdf.SaveAs("C:\Users\lyty1\Downloads\contentPageToPdf.pdf") End Sub End Class End Namespace $vbLabelText $csharpLabel Furthermore, as you may have noticed, rendering from XAML also gives you full access to all the features available in RenderingOptions. This includes adding text and HTML headers and footers. You can also stamp images, add page numbers, and even customize the size and layout of the page. All these options are available when you use this method to create a PDF. Edit MainPage.xaml File In the MainPage.xaml file, replace the default OnCounterClicked function with the new PrintToPdf function. Clicking this button will run the PrintToPdf method and create the PDF. <Button x:Name="PrintToPdfBtn" Text="Print to pdf" SemanticProperties.Hint="Click to print page as PDF" Clicked="PrintToPdf" HorizontalOptions="Center" /> <Button x:Name="PrintToPdfBtn" Text="Print to pdf" SemanticProperties.Hint="Click to print page as PDF" Clicked="PrintToPdf" HorizontalOptions="Center" /> XML Output PDF Before you save your PDF file, you can make more changes to it using the methods available to PdfDocument. You can merge pages, split them apart, or rotate them. You can also add annotations and bookmarks to your PDF. Download .NET MAUI App Project You can download the complete code for this guide. It comes as a zipped file that you can open in Visual Studio as a .NET MAUI App project. Download the Full MAUI Sample Project Ready to see what else you can do? Check out our tutorial page here: Convert PDFs Frequently Asked Questions How can I convert a XAML page to PDF in .NET MAUI? You can convert a XAML page to PDF in .NET MAUI by using the IronPdf library. First, download the IronPdf C# library for MAUI and modify the MainPage.xaml.cs file to use the RenderContentPageToPdf method. Replace the default function in the MainPage.xaml file with the PrintToPdf function to allow PDF creation via a button click. What limitations exist for using IronPdf with .NET MAUI? Currently, IronPdf supports generating PDFs from MAUI applications only for desktop and web platforms, not for mobile platforms. This means the library can be used with MAUI applications running on Windows, macOS, and web environments. What is the purpose of the IronPdf.Extensions.Maui package? The IronPdf.Extensions.Maui package extends the functionality of the IronPdf main package, allowing you to render content pages of a MAUI application to PDF documents with advanced rendering options, such as adding headers, footers, and page numbers. How can you view or save a generated PDF in a MAUI application? After generating the PDF using the ChromePdfRenderer class in IronPdf, you can view or save the PdfDocument object using the SaveAsAsync method, specifying the desired file path for storage. Can I customize the layout of the PDF generated from a MAUI page? Yes, you can customize the layout of the generated PDF using features from IronPdf such as modifying the page size, orientation, and adding custom text, HTML headers, footers, and page numbers. What changes are necessary in the MainPage.xaml file for PDF conversion? In the MainPage.xaml file, you need to replace the default OnCounterClicked function with the PrintToPdf function. This change will enable the button to trigger the PrintToPdf method, facilitating PDF creation. Is there a sample project available for converting MAUI pages to PDF? Yes, a full MAUI sample project is available for download, providing a comprehensive code guide in a zipped file format. This sample can be opened in Visual Studio as a .NET MAUI App project, helping you implement PDF functionalities into your MAUI applications. What functionalities does the PdfDocument class offer? The PdfDocument class from IronPdf provides functionalities such as merging pages, splitting them, rotating them, and adding annotations and bookmarks to enhance the interactivity and utility of your PDFs. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Ready to Get Started? Nuget Downloads 15,607,683 | Version: 2025.10 just released Free NuGet Download Total downloads: 15,607,683 View Licenses