Rendering a PDF Page

Although the PDF support lacks power, its simplicity is hard to beat. Imagine that you have a simple Page with an Image named image on it. The following update to the original ShowUserSelectedFile method from the beginning of this chapter enables the Image to render the first page of a PDF file chosen by the user:

async Task ShowUserSelectedFile() {   // Get a PDF file from the user   FileOpenPicker picker = new FileOpenPicker();   picker.FileTypeFilter.Add(".pdf" ); #if WINDOWS_PHONE_APP   // See Chapter 19   ... #else   StorageFile file = await picker.PickSingleFileAsync();   if (file != null)   {     // Throws an exception if the document is password-protected:     PdfDocument document = ...

Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.