I need to process many PDFs and export it as an image, the first PDF works fine, however and other PDF I load and export, the image is always of the first one. I do not get any errors. This is the code I'm using:
SfPdfViewer pdfViewerControl = new SfPdfViewer();
Stream stream2 = pdfViewerControl.ExportAsImage(0,2.0f);
stream2.Position = 0;
byte[] imageAsBytes = Converters.ToByteArray(stream2);
PDFImage.Source = ImageSource.FromStream(() => new MemoryStream(imageAsBytes));
filePath = Path.Combine(localFolder, "test.png");
File.WriteAllBytes(filePath, imageAsBytes);
Again this works fine on the first PDF, but on any other PDF all I get is an image of the first PDF.
If I add this line:
pdfViewerControl.Unload();
I get this error:
"Object reference not set to an instance of an object."
I also tried, instead of creating the PDFViewer in code, creating it in XAML, the UnLoad works, however in this scenario, the image doesn't get exported, it just creates a 0 byte file.