Skip to content

Repository files navigation

12/02/2026 - Work in progress ...

We were unable to get CollectionView to scroll horizontally properly, so we had to revert to a ScrollView. If anyone knows how to implement horizontal scrolling on CollectionView, we would appreciate your assistance. 😉

PDFViewer

A simple Maui PDF viewer based on the nativ PDF libraries ...
based on ideas and code of vitalii-vov ( https://github.com/vitalii-vov/Maui.PDFView )

“Powered by native PDF engines. Wrapped in simplicity.”


.NET MAUI.NET 10
PlatformAndroidiOSMacWindows
Supported (goal)
Progress90 %90 %90 %90 %

MacCatalyst is not tested yet!

NuGet DownloadsNuGet DownloadsGitHub Licenselast commitAsk DeepWiki

iOSAndroidWinUI

Download

https://www.nuget.org/packages/ZPF.PDFViewer.Maui

Installation

Install-Package ZPF.PDFViewer.Maui

or

dotnet add package ZPF.PDFViewer.Maui 

Installation

Install-Package ZPF.PDFViewer.Maui

Usage

Nothing to add to MauiProgram.

Simply add PdfViewer to XAML

<ContentPagex: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:ZPF.PDFViewer.Maui;assembly=PDFViewer.Maui">
<pdf:PDFViewerIsToolbarVisible="True"BackgroundColor="AntiqueWhite"ToolbarColor="LightGray"ClickOnPage="pdfViewer_ClickOnPage"DoubleClickOnPage="pdfViewer_DoubleClickOnPage" />
</ContentPage>

Set PDF source in code-behind

Load PDF from file path

awaitpdfViewer.LoadPDF(fullPath);

Load PDF with password

awaitpdfViewer.LoadPDF(fullPath,password);

For Android, Passwords are only supported on: 'android' 35.0 and later.

Error handling

if(!awaitpdfViewer.LoadPDF(fullPath,password)){awaitDisplayAlertAsync("Oups ...",pdfViewer.LastMessage,"ok");}

Helper classes implementing IPdfSource

The PDFViewer component works only with file paths. This is because the native platform components primarily operate with file paths, and handling different PDF data sources directly inside the component would significantly complicate the code.

Therefore, you must always provide a file path regardless of the form your PDF data takes—whether it’s a file, an asset, or a URL.

To simplify working with these data sources, the component includes helper classes that implement the IPdfSource interface:

  • AssetPdfSource
  • FilePdfSource
  • HttpPdfSource

Load PDF from file path

awaitpdfViewer.LoadPDF(newFilePdfSource(),FullPath);

Load PDF from URL

awaitpdfViewer.LoadPDF(newHttpPdfSource(),"https://www.learningcontainer.com/wp-content/uploads/2019/09/sample-pdf-download-10-mb.pdf");

Load PDF from resource asset

awaitpdfViewer.LoadPDF(newAssetPdfSource(),"Example.Resources.PDF.pdf2.pdf");

See the example project to see the different sources in action.

You can also create your own implementation of the IPdfSource interface to address your specific needs.

Helper classe PDFToImageHelper

Methods to save PDF pages as images:

  • SaveFirstPageAsImageAsync(string pdfPath, string outputImagePath)
  • SavePageAsImageAsync(string pdfPath, string outputImagePath, uint pageNumber = 0)

Example of using PDFToImageHelper

{stringtnFileName=System.IO.Path.GetTempFileName();awaitPDFToImageHelper.SaveFirstPageAsImageAsync(pdfFilepath,tnFileName);returntnFileName;}

Experimental doc...

About

PDFViewer - A simple Maui PDF viewer based on the nativ PDF libraries ...

Topics

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages