Skip to content

WelterDevelopment/PDFjs.WinUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDFjs.WinUI

This is a WebView2-based wrapper of PDF.js for WinUI 3 / WinAppSDK. It is optimized to be used for PDF files generated by TeX. It uses the prebuilt version 2.12.313 from https://mozilla.github.io/pdf.js/getting_started/#download.

If you want to use your own version of PDF.js and just want to know how to get it to run within a WebView2 control, "SetVirtualHostNameToFolderMapping()" does the trick, e.g.:

private async void PDFjsViewerWebView_CoreWebView2Initialized(WebView2 sender, CoreWebView2InitializedEventArgs args)
{
	string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
	sender.CoreWebView2.SetVirtualHostNameToFolderMapping("pdfjs", path, CoreWebView2HostResourceAccessKind.DenyCors);
	PDFjsViewerWebView.Source = new("https://pdfjs/web/viewer.html");
}

Screenshot

Screenshot 2022-01-05 170246

Features

  • Open a PDF file (StorageFile)
  • Change the theme (Light/Dark)
  • viewer.css has been tweaked to show Win11-styled scrollbars (adapting to the theme)
  • viewer.html and viewer.js have been tweaked to automatically show the outline instead of thumbnails.
  • viewer.html and viewer.js have been tweaked to always use page-width, like Overleaf does. Zooming is disabled.
  • Page property is two-way bindable

ToDo

  • SyncTeX functionality (scroll to a specific position; listen to double-click events)
  • Implement more two-way bindable properties

About

PDFjs wrapper for WinUI 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published