/Maui.PDFView

This repository contains a control for .NET MAUI and allows you to display PDF in View

Primary LanguageC#MIT LicenseMIT

Maui.PDFView

Library for display PDF files in .NET MAUI on Android and iOS (Windows alpha)

maui-pdfview-480.mp4

.NET 8.0 .NET MAUI

Platform Supported
Android
iOS
Windows alpha

Installation

Install-Package Vitvov.Maui.PDFView

Usage

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .UseMauiPdfView()   // <- Write this
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            });
        return builder.Build();
    }
}
<ContentPage
    x:Class="Example.Business.UI.Pages.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:pdf="clr-namespace:Maui.PDFView;assembly=Maui.PDFView">

    <!--
    IsHorizontal — Display PDF horizontally
    Uri — Path to the file on the device
    MaxZoom — Max zoom level
    -->
    <pdf:PdfView
        IsHorizontal="{Binding IsHorizontal}"
        Uri="{Binding PdfSource}"
        MaxZoom="4"/>

</ContentPage>
internal partial class MainPageViewModel : ObservableObject
{
    [ObservableProperty] private string _pdfSource;

    [RelayCommand] private void ChangeUri()
    {
        //  See the example project to understand how to work with paths.
        PdfSource = "/path/to/file.pdf";
    }
}