Getting Started with the .NET MAUI PDF Viewer
This guide provides the information you need to start using the Telerik UI for .NET MAUI PDF Viewer by adding the control to your project.
At the end, you will be able to achieve the results from the first image on desktop platforms and the results from the second image on mobile platforms.
Prerequisites
Before adding the PDF Viewer, you need to:
Define the Control
1. When your .NET MAUI application is setup, you are ready to add a PDF Viewer control to your page.
<telerik:RadPdfViewer x:Name="pdfViewer" AutomationId="pdfViewer"/>
var pdfViewer = new RadPdfViewer();
2. Add the telerik
namespace:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
3. Visualize the PDF document by setting the Source
property of the control:
Func<CancellationToken, Task<Stream>> streamFunc = ct => Task.Run(() =>
{
Assembly assembly = typeof(GettingStartedXaml).Assembly;
string fileName = assembly.GetManifestResourceNames().FirstOrDefault(n => n.Contains("pdf-overview.pdf"));
Stream stream = assembly.GetManifestResourceStream(fileName);
return stream;
});
this.pdfViewer.Source = streamFunc;
4. Register the Telerik controls through the Telerik.Maui.Controls.Compatibility.UseTelerik
extension method called inside the CreateMauiApp
method of the MauiProgram.cs
file of your project:
using Telerik.Maui.Controls.Compatibility;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseTelerik()
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
return builder.Build();
}
}
The example above shows a PDF document visualized as an embedded resource. This is one of the options for loading a PDF with the RadPdfViewer
control.
For the runnable PDF Viewer Getting Started example, see the SDKBrowser Demo Application and go to PdfViewer > Getting Started.
Additional Resources
- .NET MAUI PDF Viewer Product Page
- .NET MAUI PDF Viewer Forum Page
- Telerik .NET MAUI Blogs
- Telerik .NET MAUI Roadmap