Export PDF and Image at the same time

Hi,

I'm using PDFDocument to generate a PDF, it works as expected. But at the same time, I need to generate a png/image from the same PDF, so I'm trying to use PdfViewer to export as image but having issues with the pdfStream.

These are the steps I'm doing:

-------------

PdfDocument document = new PdfDocument();

...
create pdf contents
...

MemoryStream pdfStream = new MemoryStream();
document.Save(pdfStream);

SfPdfViewer pdfViewer = new SfPdfViewer();
pdfViewer.LoadDocument(pdfViewer);

var imageStream = pdfViewer.ExportAsImage(0); 

document.Close(true);

----------------

The issue is that the call to LoadDocument closes the pdfStream and makes the line: var imageStream = pdfViewer.ExportAsImage(0);  to fail with an error. 


Can you please help?

Many thanks!

3 Replies 1 reply marked as answer

AV Ashokkumar Viswanathan Syncfusion Team November 16, 2020 10:15 AM UTC

Hi Luis, 
 
Greetings from Syncfusion support, 
 
We were unable to reproduce the issue, “Application throws error while exporting PDF pages as image”, its working as expected. 
 
Please find the sample which we have used to reproduce the issue, 
 
Kindly share the following details to analyze more on this issue and assist you with the better solution   
  1. Simple sample/ Modify the above sample to reproduce the issue
  2. PDF document.
  3. Device specification.
  4. Xamarin Forms version
  5. SfPdfViewer version.
  6. Replication procedure to reproduce the issue
 
Regards, 
Ashok Kumar Viswanathan. 



LU luis November 18, 2020 07:38 PM UTC

Thanks for your support. Finally it was an error found at 18.3.0.35, I upgraded to latest version and it's working.


AV Ashokkumar Viswanathan Syncfusion Team November 19, 2020 06:07 AM UTC

Hi Luis, 
 
Thank you for your update. We hope the issue, “Application throws error while exporting PDF pages as image” is resolved in our latest version of SfPdfViewer control. 
 
Please let us know if you need any further assistance. 
 
Regards, 
Ashok Kumar Viswanathan. 


Marked as answer
Loader.
Up arrow icon