Introduction
Reading PDF files has involved third party libraries previously, but now in Windows 10, you can easily implement this using Launcher API.
Create a new Windows 10 universal app. For creating a new Windows 10 universal project, refer to the following:
Let’s see the steps
Now create one button to select the file. Go to the code behind and write the below code. Create an instance for a StorageFile class to store the file details.
StorageFile file = null;
Next, use FilePicker to select the file, here I have added filters to only view the PDF file,
- FileOpenPicker filePicker = new FileOpenPicker();
- filePicker.FileTypeFilter.Add(".pdf");
- filePicker.ViewMode = PickerViewMode.Thumbnail;
- filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
- filePicker.SettingsIdentifier = "picker1";
- filePicker.CommitButtonText = "Open Pdf File";
- file = await filePicker.PickSingleFileAsync();
After selecting the file, the properties of the selected file are assigned to the storage file instance. Now using launcher launch the selected file by using the following code,
- Windows.System.Launcher.LaunchFileAsync(file);
The full source code looks like the following.
- private async void selectFile_Click(object sender, RoutedEventArgs e)
- {
- StorageFile file = null;
- FileOpenPicker filePicker = newFileOpenPicker();
- filePicker.FileTypeFilter.Add(".pdf");
- filePicker.ViewMode = PickerViewMode.Thumbnail;
- filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
- filePicker.SettingsIdentifier = "picker1";
- filePicker.CommitButtonText = "Open Pdf File";
- file = await filePicker.PickSingleFileAsync();
- Windows.System.Launcher.LaunchFileAsync(file);
- }
- StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@ "Foldername\filename.pdf");
- Windows.System.Launcher.LaunchFileAsync(file);

Please share your comments on this article.
Read more articles on Windows 10
Summary
In this article, we learned about reading PDF Files In Windows 10 Universal App Using Default PDF Reader.

Mohit PandeyPosted Jan 10, 2020, 1:15 AM
Hi All, when select the file it shows me in microsoft edge. How to fix it ?
Sibeesh VenuPosted Mar 17, 2016, 11:17 AM
Nice Share
Debasis SahaPosted Mar 16, 2016, 1:49 PM
Good One..
Raja TPosted Mar 16, 2016, 12:24 AM
Nice,Thanks for sharing..
Kashif SohailPosted Mar 15, 2016, 5:15 PM
Great
Debasis SahaPosted Mar 15, 2016, 1:47 PM
Good One..