An open API service indexing awesome lists of open source software.

https://github.com/welterdevelopment/pdfjs.winui

PDFjs wrapper for WinUI 3
https://github.com/welterdevelopment/pdfjs.winui

Last synced: 10 months ago
JSON representation

PDFjs wrapper for WinUI 3

Awesome Lists containing this project

README

          

# 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.:

``` csharp
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](https://user-images.githubusercontent.com/13318246/148249138-bf3800fe-cb4d-4437-92ec-1dcde2ef0a6f.png)

## 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