Skip to footer content
USING IRONPDF

How to Display PDF Embedded Text in .NET MAUI

Learn how to extract and display embedded text from PDF files in .NET MAUI applications using IronPDF. This powerful C# library enables you to read PDF content and present it in cross-platform apps with just a few lines of code.

.NET Multi-platform App UI (MAUI) simplifies multi-platform app development. With this evolution of Xamarin.Forms, you can create apps for Android, iOS, macOS, and Windows from a single project. PDF files, known for preserving fonts, images, and layout, are commonly managed using this technology.

The IronPDF library offers powerful PDF handling capabilities. You can leverage IronPDF to work with embedded text effortlessly, simplifying the process of generating and manipulating PDF files while maintaining consistent rendering with default settings.

What Is PDF Embedded Text and Font Embedding?

PDF-embedded text refers to text entities embedded in a PDF file. It ensures consistency and accurate rendering across PDF viewer applications, including Adobe InDesign. By embedding fonts within the PDF document, the correct fonts are preserved, regardless of the viewer application or whether the specific font is installed on the viewer's device.

Embedding fonts can increase file size, but it's crucial for maintaining the original document's appearance. Adobe PDF settings often determine whether fonts are embedded. PDF compression techniques can help reduce file size when embedding fonts.

There are three types of embedded fonts in PDFs:

  1. Embedded fonts: The entire font is embedded in the document.
  2. Subset embedded fonts: Only a subset of the fonts used in the original document is embedded.
  3. No embedded fonts: No fonts are embedded in the document.

In Adobe Acrobat, you can verify font embedding by checking the document properties. By default, fonts are embedded in PDFs. However, these settings can be modified using Adobe Acrobat Pro or tools like IronPDF's font management features.

A 'flattened PDF' contains all embedded fonts, making it self-contained and ensuring consistent appearance across all systems. IronPDF supports flattening PDF documents to ensure consistent rendering.

What Is IronPDF C#?

IronPDF Documentation is a powerful C# PDF library that allows you to generate, read, and edit PDF files in .NET applications. You can generate PDF files from HTML with IronPDF.

A key feature is working with embedded text in PDF files. Embedding fonts in PDFs preserves the document's original appearance, even when viewed on systems without the original fonts. Let's explore how to display embedded text using IronPDF in .NET MAUI.

IronPDF offers extensive text extraction capabilities for working with PDF content programmatically. Whether you need to parse PDFs in C# or convert PDF content to other formats, IronPDF provides the necessary tools.

  1. .NET MAUI: Microsoft's unified UI toolkit that allows you to create apps for Android, iOS, macOS, and Windows with a single shared codebase. You can download the .NET MAUI from the Microsoft website.
  2. Visual Studio 2022 (or later): A powerful and user-friendly Integrated Development Environment (IDE) for .NET programming. You can download Visual Studio from the Microsoft website. Ensure you have the .NET MAUI workloads installed on Visual Studio 2022.
  3. IronPDF library: This is a PDF processing library for .NET, and we will use it to interact with the PDF files. You can install IronPDF via NuGet, which is a package manager for the Microsoft development platform.
  4. An Adobe PDF file: For the sake of this tutorial, we will need a PDF file.

Before starting, ensure you have these requirements:

  1. .NET MAUI: Microsoft's unified UI toolkit for creating cross-platform apps. Download from Microsoft's website.
  2. Visual Studio 2022 (or later): A powerful IDE for .NET programming with .NET MAUI workloads installed.
  3. IronPDF library: Install via NuGet package manager. Learn about IronPDF NuGet packages.
  4. A PDF file: Any PDF file for testing purposes.

For platform-specific setup:

How Do I Create a .NET MAUI App?

Follow these steps to create a new .NET MAUI App:

Launch Visual Studio 2022: After launching, navigate to File > New > Project. In the project template window, select .NET MAUI App and then click on Next.

Visual Studio's New Project dialog showing various .NET MAUI project templates including .NET MAUI App, .NET MAUI Blazor App, and .NET MAUI Class Library options. Figure 1: The Visual Studio New Project dialog with .NET MAUI templates highlighted, showing the first step in creating a new .NET MAUI application.

Name your project: In the next window, you'll need to give your project a name. Let's name it IronPDF_Read_and_View. Choose a location to save your project and then click Next.

Visual Studio configuration screen for creating a new .NET MAUI App project named 'IronPDF Read and View' with platform options for Android, iOS, Mac Catalyst, macOS, MAUI, Tizen, and Windows. Figure 2: Configure the project - Setting up a new .NET MAUI application with IronPDF integration for cross-platform PDF viewing capabilities.

Select Framework: Select .NET Framework from the drop-down list. Select the latest .NET Framework for a smooth process and click the "Create" button.

Visual Studio project creation wizard showing .NET MAUI App configuration with .NET 7.0 framework selected and platform options for Android, iOS, Mac Catalyst, macOS, MAUI, Tizen, and Windows Figure 3: Selecting the .NET framework version and target platforms for a new .NET MAUI application

How Do I Install IronPDF?

After creating the .NET MAUI App, install the IronPDF library:

  1. Open the NuGet Package Manager: Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.

    Visual Studio Tools menu expanded showing NuGet Package Manager options with 'Manage NuGet Packages for Solution' highlighted Figure 4: Access the NuGet Package Manager by navigating to Tools > NuGet Package Manager > Manage NuGet Packages for Solution in Visual Studio

  2. Search for IronPDF: In the opened window, click on Browse and type IronPdf in the search box.

    NuGet Package Manager interface in Visual Studio showing search results for 'IronPdf' with multiple package options and the main IronPdf package selected for installation Figure 5: The NuGet Package Manager UI displaying IronPDF search results. The main IronPdf package (version 2023.6.10) is selected and ready to install, with 6.31M downloads shown.

  3. Install IronPDF: Once you see IronPDF in the search results, click on it. Make sure that the checkbox for your project in the right panel is checked and then click on Install.

Accept any prompts during installation.

You can also install using the Package Manager Console:

Install-Package IronPdf

For advanced installation options, including Docker setup and Azure deployment, see the IronPDF installation overview.

How Do I Build the User Interface?

Let's build the UI for our application. The MainPage.xaml file will have a button to open PDFs and labels to display the file name and content.

Open the MainPage.xaml file: This file contains the layout of the main page. You can find this file under the Pages folder in the Solution Explorer.

Define the Layout: We are going to use a <ScrollView> control which allows the user to scroll through the contents of the page when it cannot fit entirely on the screen. Inside the ScrollView, we will use a <StackLayout> for stacking our controls vertically. Inside the StackLayout, we have three <Frame> controls. Each Frame is used to hold a distinct section of our page, providing a neat and organized appearance.

Add Controls: The first Frame has a <VerticalStackLayout> which holds a Label and a Button. The Label displays the application name, and the Button allows the user to open a PDF file. The Clicked attribute is assigned the method OpenAndReadFile which will be defined later in the code-behind file.

<VerticalStackLayout
    Spacing="25"
    Padding="30,0"
    VerticalOptions="Center">
    <Label
        Text="IronPDF MAUI Application"
        SemanticProperties.HeadingLevel="Level1"
        SemanticProperties.Description="IronPDF MAUI Application"
        FontSize="30"
        HorizontalOptions="Center"
        FontAttributes="Bold"

    />
    <Button
        x:Name="openFileBtn"
        Text="Open PDF File"
        SemanticProperties.Hint="Open PDF File"
        Clicked="OpenAndReadFile"
        HorizontalOptions="Center" />
</VerticalStackLayout>
<VerticalStackLayout
    Spacing="25"
    Padding="30,0"
    VerticalOptions="Center">
    <Label
        Text="IronPDF MAUI Application"
        SemanticProperties.HeadingLevel="Level1"
        SemanticProperties.Description="IronPDF MAUI Application"
        FontSize="30"
        HorizontalOptions="Center"
        FontAttributes="Bold"

    />
    <Button
        x:Name="openFileBtn"
        Text="Open PDF File"
        SemanticProperties.Hint="Open PDF File"
        Clicked="OpenAndReadFile"
        HorizontalOptions="Center" />
</VerticalStackLayout>
XML

The second Frame uses <HorizontalStackLayout> with two Labels: one for static text and another named fileName for displaying the selected file.

<HorizontalStackLayout
    Spacing="25"
    Padding="30,0"
    VerticalOptions="Center">
    <Label
        Text="Selected File Name: "
        SemanticProperties.HeadingLevel="Level2"
        SemanticProperties.Description="Selected File Name"
        FontSize="18"
        HorizontalOptions="Center"
        FontAttributes="Bold"
    />
    <Label
        x:Name="fileName"
        Text=""
        SemanticProperties.HeadingLevel="Level3"
        SemanticProperties.Description="Selected File Name"
        FontSize="18"
        HorizontalOptions="Center" 
     />
</HorizontalStackLayout>
<HorizontalStackLayout
    Spacing="25"
    Padding="30,0"
    VerticalOptions="Center">
    <Label
        Text="Selected File Name: "
        SemanticProperties.HeadingLevel="Level2"
        SemanticProperties.Description="Selected File Name"
        FontSize="18"
        HorizontalOptions="Center"
        FontAttributes="Bold"
    />
    <Label
        x:Name="fileName"
        Text=""
        SemanticProperties.HeadingLevel="Level3"
        SemanticProperties.Description="Selected File Name"
        FontSize="18"
        HorizontalOptions="Center" 
     />
</HorizontalStackLayout>
XML

The third Frame contains a <VerticalStackLayout> with two Labels: one for "PDF Content" and another named content for displaying the PDF text.


<VerticalStackLayout>
    <Label
        Text="PDF Content"
        SemanticProperties.HeadingLevel="Level2"
        FontSize="25"
        FontAttributes="Bold"
        HorizontalOptions="Center" 
    />
    <Label
        x:Name="content"
        FontSize="18"
        HorizontalTextAlignment="Start"
    />
</VerticalStackLayout>

<VerticalStackLayout>
    <Label
        Text="PDF Content"
        SemanticProperties.HeadingLevel="Level2"
        FontSize="25"
        FontAttributes="Bold"
        HorizontalOptions="Center" 
    />
    <Label
        x:Name="content"
        FontSize="18"
        HorizontalTextAlignment="Start"
    />
</VerticalStackLayout>
XML

Your complete MainPage.xaml should look like this:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    xmlns="___PROTECTED_URL_46___"
    xmlns:x="___PROTECTED_URL_47___"
                x:Class="IronPDF_Read_and_View.MainPage">
    <ScrollView>
        <StackLayout>
            <Frame>
                <VerticalStackLayout
                    Spacing="25"
                    Padding="30,0"
                    VerticalOptions="Center">
                    <Label
                        Text="IronPDF MAUI Application"
                        SemanticProperties.HeadingLevel="Level1"
                        SemanticProperties.Description="IronPDF MAUI Application"
                        FontSize="30"
                        HorizontalOptions="Center"
                        FontAttributes="Bold"

                    />
                    <Button
                        x:Name="openFileBtn"
                        Text="Open PDF File"
                        SemanticProperties.Hint="Open PDF File"
                        Clicked="OpenAndReadFile"
                        HorizontalOptions="Center" />
                </VerticalStackLayout>
            </Frame>
            <Frame>
                <HorizontalStackLayout
                        Spacing="25"
                        Padding="30,0"
                        VerticalOptions="Center">
                    <Label
                            Text="Selected File Name: "
                            SemanticProperties.HeadingLevel="Level2"
                            SemanticProperties.Description="Selected File Name"
                            FontSize="18"
                            HorizontalOptions="Center"
                            FontAttributes="Bold"

                        />
                    <Label
                            x:Name="fileName"
                            Text=""
                            SemanticProperties.HeadingLevel="Level3"
                            SemanticProperties.Description="Selected File Name"
                            FontSize="18"
                            HorizontalOptions="Center" 
                        />
                </HorizontalStackLayout>
            </Frame>
            <Frame>
                <VerticalStackLayout>
                    <Label
                            Text="PDF Content"
                            SemanticProperties.HeadingLevel="Level2"
                            FontSize="25"
                        FontAttributes="Bold"
                            HorizontalOptions="Center" 
                        />
                    <Label
                        x:Name="content"
                        FontSize="18"
                        HorizontalTextAlignment="Start"
                        />
                </VerticalStackLayout>
            </Frame>
        </StackLayout>
    </ScrollView>
</ContentPage>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    xmlns="___PROTECTED_URL_46___"
    xmlns:x="___PROTECTED_URL_47___"
                x:Class="IronPDF_Read_and_View.MainPage">
    <ScrollView>
        <StackLayout>
            <Frame>
                <VerticalStackLayout
                    Spacing="25"
                    Padding="30,0"
                    VerticalOptions="Center">
                    <Label
                        Text="IronPDF MAUI Application"
                        SemanticProperties.HeadingLevel="Level1"
                        SemanticProperties.Description="IronPDF MAUI Application"
                        FontSize="30"
                        HorizontalOptions="Center"
                        FontAttributes="Bold"

                    />
                    <Button
                        x:Name="openFileBtn"
                        Text="Open PDF File"
                        SemanticProperties.Hint="Open PDF File"
                        Clicked="OpenAndReadFile"
                        HorizontalOptions="Center" />
                </VerticalStackLayout>
            </Frame>
            <Frame>
                <HorizontalStackLayout
                        Spacing="25"
                        Padding="30,0"
                        VerticalOptions="Center">
                    <Label
                            Text="Selected File Name: "
                            SemanticProperties.HeadingLevel="Level2"
                            SemanticProperties.Description="Selected File Name"
                            FontSize="18"
                            HorizontalOptions="Center"
                            FontAttributes="Bold"

                        />
                    <Label
                            x:Name="fileName"
                            Text=""
                            SemanticProperties.HeadingLevel="Level3"
                            SemanticProperties.Description="Selected File Name"
                            FontSize="18"
                            HorizontalOptions="Center" 
                        />
                </HorizontalStackLayout>
            </Frame>
            <Frame>
                <VerticalStackLayout>
                    <Label
                            Text="PDF Content"
                            SemanticProperties.HeadingLevel="Level2"
                            FontSize="25"
                        FontAttributes="Bold"
                            HorizontalOptions="Center" 
                        />
                    <Label
                        x:Name="content"
                        FontSize="18"
                        HorizontalTextAlignment="Start"
                        />
                </VerticalStackLayout>
            </Frame>
        </StackLayout>
    </ScrollView>
</ContentPage>
XML

When users click "Open PDF File", it triggers the OpenAndReadFile method. The fileName and content labels will display the selected file name and PDF content respectively.

For complex UI layouts, IronPDF supports converting XAML to PDF directly in MAUI applications.

What Goes in the Code Behind MainPage.xaml.cs?

Open MainPage.xaml.cs: Find this file in the Solution Explorer under the Pages folder. This is where we'll add our method.

Add the filePath field: At the top of the MainPage class, declare a string field named filePath. We will use this field to store the path of the selected file.

string filePath = string.Empty;
string filePath = string.Empty;
Dim filePath As String = String.Empty
$vbLabelText   $csharpLabel

Initialize Components: In the MainPage constructor, call the InitializeComponent method. This method is called automatically to initialize the page and its controls.

public MainPage()
{
    InitializeComponent();
}
public MainPage()
{
    InitializeComponent();
}
Public Sub New()
    InitializeComponent()
End Sub
$vbLabelText   $csharpLabel

Implement the OpenAndReadFile method: This method is marked as async because we're going to use the await keyword inside it. The FilePicker.PickAsync method is used to open the file picker. When the user selects a file, the file name is stored in the fileName label, and the file path in the filePath field. The IronPDF library is used to open the PDF document and extract all text from it. The extracted text is then assigned to the content label.

private async void OpenAndReadFile(object sender, EventArgs e)
{
    FileResult result = await FilePicker.PickAsync();
    fileName.Text = result.FileName;
    filePath = result.FullPath;

    IronPdf.License.LicenseKey = "Your-License-Key";

    // Read PDF File
    var document = PdfDocument.FromFile(filePath);
    var pdfContent = document.ExtractAllText();
    content.Text = pdfContent;
}
private async void OpenAndReadFile(object sender, EventArgs e)
{
    FileResult result = await FilePicker.PickAsync();
    fileName.Text = result.FileName;
    filePath = result.FullPath;

    IronPdf.License.LicenseKey = "Your-License-Key";

    // Read PDF File
    var document = PdfDocument.FromFile(filePath);
    var pdfContent = document.ExtractAllText();
    content.Text = pdfContent;
}
Private Async Sub OpenAndReadFile(ByVal sender As Object, ByVal e As EventArgs)
	Dim result As FileResult = Await FilePicker.PickAsync()
	fileName.Text = result.FileName
	filePath = result.FullPath

	IronPdf.License.LicenseKey = "Your-License-Key"

	' Read PDF File
	Dim document = PdfDocument.FromFile(filePath)
	Dim pdfContent = document.ExtractAllText()
	content.Text = pdfContent
End Sub
$vbLabelText   $csharpLabel

Replace "Your-License-Key" with your actual IronPDF license key. Learn about using license keys in IronPDF.

Here's the complete code:

using IronPdf;

public partial class MainPage : ContentPage
{
    string filePath = string.Empty;

    public MainPage()
    {
        InitializeComponent();
    }

    private async void OpenAndReadFile(object sender, EventArgs e)
    {
        FileResult result = await FilePicker.PickAsync();
        fileName.Text = result.FileName;
        filePath = result.FullPath;
        IronPdf.License.LicenseKey = "Your-License-Key";

        // Read PDF File
        var document = PdfDocument.FromFile(filePath);
        var pdfContent = document.ExtractAllText();
        content.Text = pdfContent;
    }
}
using IronPdf;

public partial class MainPage : ContentPage
{
    string filePath = string.Empty;

    public MainPage()
    {
        InitializeComponent();
    }

    private async void OpenAndReadFile(object sender, EventArgs e)
    {
        FileResult result = await FilePicker.PickAsync();
        fileName.Text = result.FileName;
        filePath = result.FullPath;
        IronPdf.License.LicenseKey = "Your-License-Key";

        // Read PDF File
        var document = PdfDocument.FromFile(filePath);
        var pdfContent = document.ExtractAllText();
        content.Text = pdfContent;
    }
}
Imports IronPdf

Partial Public Class MainPage
	Inherits ContentPage

	Private filePath As String = String.Empty

	Public Sub New()
		InitializeComponent()
	End Sub

	Private Async Sub OpenAndReadFile(ByVal sender As Object, ByVal e As EventArgs)
		Dim result As FileResult = Await FilePicker.PickAsync()
		fileName.Text = result.FileName
		filePath = result.FullPath
		IronPdf.License.LicenseKey = "Your-License-Key"

		' Read PDF File
		Dim document = PdfDocument.FromFile(filePath)
		Dim pdfContent = document.ExtractAllText()
		content.Text = pdfContent
	End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF offers additional features beyond text extraction. You can search and replace text, extract images, work with PDF forms, and add annotations programmatically.

How Do I Run the Application?

Start the Application: To run the application, you can either press F5 on your keyboard or click on the green 'Start Debugging' button in the toolbar at the top of Visual Studio. Ensure that the right target device or emulator is selected in the dropdown menu next to the 'Start Debugging' button.

Use the Application: Once the application launches, you will see a screen with the title "IronPDF MAUI Application" and a button labeled "Open PDF File".

Use the Application: You'll see a screen with "IronPDF MAUI Application" and an "Open PDF File" button.

Open a PDF File: Click on the "Open PDF File" button. This will open a file picker, allowing you to browse and select a PDF file from your device or emulator.

Open a PDF File: Click "Open PDF File" to open the file picker and select a PDF from your device.

View the Content: Upon selecting a PDF file, the file name will be displayed under "Selected File Name:", and the content of the selected PDF file will be displayed under "PDF Content".

View the Content: After selecting a PDF, the file name appears under "Selected File Name:" and the extracted text under "PDF Content".

IronPDF MAUI application window showing extracted text content from an invoice PDF file, displaying invoice details including items, prices, and payment information. The IronPDF MAUI application successfully extracts and displays text content from a selected invoice PDF file, demonstrating the library's text extraction capabilities in a .NET MAUI desktop application.

Note that large PDFs may take a few seconds to process. The extracted text format may not match the original PDF layout exactly, as the ExtractAllText method extracts embedded text content. For more control, use page-specific extraction methods or work with PDF DOM objects.

What Have We Learned?

This tutorial showed how to build a .NET MAUI application using IronPDF to extract and display PDF text content. This demonstrates the power and versatility of .NET MAUI and IronPDF for PDF processing.

Beyond text extraction, IronPDF supports interacting with PDF forms, splitting PDFs, rasterizing pages to images, authentication with HTML login forms, customizing headers and footers, and supporting CSS for pixel-perfect PDFs. You can explore PDF viewing in MAUI, work with UTF-8 and international languages, and generate PDF reports from data.

IronPDF is a commercial product offering a free trial to test its capabilities. If you find it beneficial for production use, licenses start from $799. Check out the comprehensive IronPDF features overview to learn more about this powerful PDF processing library.

Frequently Asked Questions

How can I display PDF embedded text in a .NET MAUI application?

To display PDF embedded text in a .NET MAUI application, you can use the IronPDF library. IronPDF allows you to extract text from PDF files and render it within your application. You'll need to set up a user interface in .NET MAUI to allow users to select and display PDF content.

Why is it important to embed fonts in a PDF document?

Embedding fonts in a PDF document is important because it ensures that the document's appearance remains consistent across different systems and PDF viewers, regardless of whether the fonts are installed on the user's device.

How do you install IronPDF in a .NET MAUI project?

To install IronPDF in a .NET MAUI project, use Visual Studio's NuGet Package Manager. Search for IronPDF and install it into your project. Alternatively, you can use the NuGet Package Manager Console with the command: Install-Package IronPdf.

What are the benefits of using IronPDF in .NET MAUI applications?

IronPDF provides several benefits for .NET MAUI applications, including the ability to extract and render PDF text, manage embedded fonts, and ensure high-quality PDF rendering across different platforms. It also offers a robust set of features for PDF manipulation and supports cross-platform development.

Can IronPDF extract text from any PDF file?

Yes, IronPDF can extract text from PDF files. However, the extracted text format may vary slightly from the original PDF layout, depending on how the PDF was created.

What steps are involved in setting up a .NET MAUI application to handle PDFs?

Setting up a .NET MAUI application to handle PDFs involves installing .NET MAUI and Visual Studio with necessary workloads, integrating the IronPDF library via NuGet, and developing a user interface to interact with PDF files. The process also includes writing C# code to extract and display PDF content.

Is there a free version of IronPDF available for development?

IronPDF offers a free trial version that allows developers to test its features. For production use, various licensing plans are available to suit different needs.

What types of PDF manipulation can be achieved with IronPDF?

With IronPDF, you can perform a variety of PDF manipulations, including text extraction, interacting with PDF forms, splitting PDFs, converting PDF pages to images, and customizing document headers and footers.

Does IronPDF support .NET 10, and can I use it with .NET 10 MAUI projects?

Yes — IronPDF is fully compatible with .NET 10. It supports .NET 10 MAUI projects, immediately taking advantage of .NET 10’s performance improvements and language features without requiring custom workarounds. IronPDF supports .NET 10 along with .NET 9, 8, 7, 6, 5, Core, Standard, and Framework. (ironpdf.com)

Are there any limitations or known issues when using IronPDF’s ExtractAllText with large PDFs in MAUI on devices with limited resources like iOS or Android?

While IronPDF’s ExtractAllText works well with standard PDFs, extracting embedded text from very large documents on mobile devices can be slower and memory-intensive. Developers should consider implementing pagination or chunked extraction for large files, and ensure sufficient device memory. Also, UI responsiveness may need background threading to avoid blocking the main thread in MAUI apps. (Based on general best practices for .NET MAUI and IronPDF’s handling of PDF extraction.)

Curtis Chau
Technical Writer

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.

...

Read More