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 9, 2020, 8:15 PM EST
Hi All, when select the file it shows me in microsoft edge. How to fix it ?
Sibeesh VenuTOP 100Posted Mar 17, 2016, 7:17 AM EDT
Nice Share
Debasis SahaTOP 100Posted Mar 16, 2016, 9:49 AM EDT
Good One..
Raja TPosted Mar 15, 2016, 8:24 PM EDT
Nice,Thanks for sharing..
Kashif SohailPosted Mar 15, 2016, 1:15 PM EDT
Great
Debasis SahaTOP 100Posted Mar 15, 2016, 9:47 AM EDT
Good One..