I'm obviously doing something wrong here. The follow code has no issue getting an image from the GetPage() method but the ExportAsImage() method always throws a null exception:
public async Task ImportFileAsync(string path)
{
var file = await StorageFile.GetFileFromPathAsync(path);
if (file.FileType == ".pdf")
{
var stream = await file.OpenAsync(FileAccessMode.Read);
var fileStream = stream.AsStreamForRead();
var pdfViewer = new SfPdfViewerControl();
pdfViewer.LoadDocument(fileStream);
var image = pdfViewer.GetPage(0);
var imageStream = await pdfViewer.ExportAsImage(0) as MemoryStream;
}
}
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Syncfusion.SfPdfViewer.UWP
StackTrace:
at Syncfusion.Windows.PdfViewer.PdfDocumentView.<ExportAsImage>d__348.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Syncfusion.Windows.PdfViewer.SfPdfViewerControl.<ExportAsImage>d__604.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
What am I doing wrong?
Thanks