How to read the pdf files in windows 8 app .In my windows 8 application how to open the pdf files .
In manifest file i wrote the below code.
<Extensions>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="pdf">
<SupportedFileTypes>
<FileType>.pdf</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
</Extensions>
and code behind.
string imageFile = @"Images\DX730_EN.pdf";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
i could not able to open the pdf file.please tell me where is error?
you can use the LaunchFileAsync method of the Windows.System.Launcher class.
Take a look at this: http://msdn.microsoft.com/en-us/library/windows/apps/hh701465.aspx
Windows 8 comes with windows Reader to read pdf files .
This link might help you
http://www.howto-connect.com/how-to-view-pdf-file-in-windows-8-what-is-windows-reader/
If that doesn't help, this might
The solution is, you can open pdf files on Windows.ApplicationModel.Package.Current.InstalledLocation...
So, put the pdf on local folder and open from it.
StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile file= await localFolder.GetFileAsync("myFile.pdf");
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
}
来源:https://stackoverflow.com/questions/13118338/how-to-open-pdf-files-in-windows-8-application-using-c