Free Support Forum - aspose.com

"Cannot access closed stream" while Accessing GetNextImage Function

Hi,

I am using Aspose.Pdf.Kit for processing Pdf Documents in C# .Net Application.

I am Getting “Cannot access closed stream” Exception while processing GetNextImage function for retrieving image for a particular page.

I have used following code:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Image bitmap = null;

private PdfConverter _pdfDocument = new PdfConverter();

_pdfDocument.BindPdf(_fileName);

_pdfDocument.StartPage = index + 1;

_pdfDocument.EndPage = index + 1;

_pdfDocument.Resolution = 96;

_pdfDocument.DoConvert();

using (MemoryStream strem = new MemoryStream())

{

_pdfDocument.GetNextImage(strem, System.Drawing.Imaging.ImageFormat.Bmp);

bitmap = Image.FromStream(strem);

}

please let me know if anything wrong in my code and provide me the correct solution.

Thanks,

Sarath

Hi Sarath,

As I can see, your code looks good. Please make sure that you’re using the latest version at your end.
Moreover, if you could share the input PDF file with us as well, we’ll be able to investigate the issue over here and guide you accordingly.

We’re sorry for the inconvenience.
Regards,