IronPDF How-Tos XAML to PDF (MAUI) How to Convert XAML to PDF in MAUI Chaknith Bin Updated:July 28, 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 PM > Install-Package IronPdf Copy the code 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 What is .NET MAUI? .NET MAUI (Multi-platform App UI) is a cross-platform framework for building native device applications. It allows developers to create applications for desktop, web, and mobile platforms using common UI components and a single codebase. How can PDFs be generated from MAUI pages in a .NET application? Using IronPdf, you can generate PDF documents from MAUI pages, enabling the creation of PDF files/pages within these applications. However, it currently does not support mobile platforms. What steps are involved in converting a page to PDF in MAUI? To convert a page to PDF in MAUI using IronPdf, you need to download the IronPdf C# library, modify the MainPage.xaml.cs file, update the MainPage.xaml file, and export the PDF document or view it in the MAUI app using a PDF viewer. What package is needed to render a MAUI page to a PDF document? The IronPdf.Extensions.Maui package is needed as an extension of the IronPdf main package to render the content page of a MAUI application to a PDF document. How do you save the generated PDF document in a MAUI application? After rendering the MAUI page to a PDF using the ChromePdfRenderer class from IronPdf, the PdfDocument object can be saved using the SaveAsAsync method, specifying the file path where the PDF should be saved. Can you customize the generated PDF document? Yes, you can customize the generated PDF document using various features available in IronPdf's RenderingOptions, such as adding text and HTML headers, footers, stamping images, adding page numbers, and customizing the size and layout. What changes need to be made in the MainPage.xaml file for PDF conversion? In the MainPage.xaml file, you need to replace the default OnCounterClicked function with the new PrintToPdf function. This allows the button to trigger the PrintToPdf method, creating the PDF. Is it possible to download a sample project for converting pages to PDF in MAUI? Yes, the full MAUI sample project is available for download, offering a comprehensive code guide in a zipped file format that can be opened in Visual Studio as a .NET MAUI App project. What are some additional features of the PdfDocument class? The PdfDocument class from IronPdf allows you to merge pages, split them, rotate them, and add annotations and bookmarks to your PDF. 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? Free NuGet Download Total downloads: 14,937,042 View Licenses