I am writing an app for a client that allows users to browse a library of local PDFs, download new ones from a corporate server and read them, print them, etc and my client wants both a WPF and a UWP version. However I am seeing an issue in the WPF version where some PDFs are not loaded (PdfViewer_DocumentLoaded is never fired and nothing appears in the viewer control) but if I load this same PDF in the UWP version it loads with no issue. I don't get any exceptions in the WPF version - the document just doesn't load :-(
As you can imagine this is a huge issue as the users need to be able to load all PDFs on either platform so is this a bug in the WPF version or some sort of limitation?
Just FYI, in WPF I'm just loading it like so:
int totalPages= 0;
private void btnCF_OpenPDF_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".pdf"; // Default file extension
dlg.Filter = "PDF (.pdf)|*.pdf"; // Filter files by extension
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
pdfViewer.Load(dlg.FileName);
}
}
private void PdfViewer_DocumentLoaded(object sender, EventArgs args)
{
totalPages = pdfViewer.PageCount();
}
...and in UWP I do it via the StorageFile and Stream objects:
private async Task LoadPDF(StorageFile file)
{
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
Stream fileStream = stream.AsStreamForRead();
pdfViewer.LoadDocument(fileStream);
}
private void dfViewer_DocumentLoaded(object sender, Syncfusion.Windows.PdfViewer.DocumentLoadedEventArgs e)
{
totalPages = pdfViewer.PageCount;
}