Open a PDF from a URL in UWP

PSPDFKit for Windows supports a number of different ways of opening documents. This guide explains how to use Uris to display a document in your PdfView.

Note that UWP introduces very specific rules around file access permissions, and it’s worth reading about them here if you’re not familiar.

Microsoft also has several guide articles that cover topics such as working with file pickers, tracking recently used files, and much more.

URI Scheme

UWP uses specific Uri schemes, which can be used to access files from various locations, including the app’s package, its resources, and its local files. More information about the existing URI schemes and the types of files that can be accessed using those schemes can be found in UWP’s URI schemes documentation.

For example, if you want to access any documents included in your application’s assets, you should use the "ms-appx:///Assets/" scheme and path, like so:

var uri = new Uri("ms-appx:///Assets/pdfs/default.pdf");

Opening the Document

On PSPDFKit for Windows, you’re able to use these Uris to set the current open document of the PdfView through its PdfUriSource property.

This property can be accessed both through XAML and C#, and it automatically opens the Uri it’s set through whenever updated:

<ui:PdfView Name="PDFView" License="{StaticResource PSPDFKitLicense}"  PdfUriSource="ms-appx:///Assets/pdfs/example.pdf" />
PDFView.PdfUriSource = new Uri("ms-appx:///Assets/pdfs/default.pdf");