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");
}
- 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
- SyncTeX functionality (scroll to a specific position; listen to double-click events)
- Implement more two-way bindable properties