Skip to content

A implementation of pdfjs for android wrapped into a nuget so you can just install and use it. Have fun :). Based on https://github.com/jfversluis/MauiPdfJsViewerSample

License

Notifications You must be signed in to change notification settings

Jon2G/MauiPdfJSViewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MauiPdfJSViewer

NuGet version (PdfJSViewer-MAUI)

A implementation of pdfjs for android wrapped into a nuget so you can just install and use it. Have fun :).

Based on https://github.com/jfversluis/MauiPdfJsViewerSample

Be sure to meet pdf.js Apache license details in your app https://github.com/mozilla/pdf.js

Recording 2024-05-22 155352

Usage: XAML

        <pdfjs:PdfJsWebView x:Name="pdfJsViewer" />

C#

        private void Button_Clicked_FromAssets(object sender, EventArgs e)
        {
            pdfJsViewer.LoadPdfFromMauiAssets("sample.pdf");
        }

        private async void Button_Clicked_FromStream(object sender, EventArgs e)
        {
            using var stream = await FileSystem.OpenAppPackageFileAsync("sample.pdf");
            pdfJsViewer.LoadPdfFromSteam(stream);

        }

        private async void Button_Clicked_FromPath(object sender, EventArgs e)
        {
            string fileName = $"{Guid.NewGuid():N}.pdf";

            string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), fileName);

            using var pdfStream = await FileSystem.OpenAppPackageFileAsync("sample.pdf");
            using (FileStream file = new FileStream(filePath, FileMode.Create, FileAccess.Write))
                pdfStream.CopyTo(file);

            pdfJsViewer.LoadPdfFromPath(filePath);
        }

About

A implementation of pdfjs for android wrapped into a nuget so you can just install and use it. Have fun :). Based on https://github.com/jfversluis/MauiPdfJsViewerSample

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages