Free Support Forum - aspose.com

Getting an Out of Memory error when converting PDF to PNG

When we attempt to convert the attached PDF file into a PNG, the component is throwing an Out of Memory error.

Hi Geiger,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 10.5.0 in Visual Studio 2012 with .NET Framework 4.0, running over Windows 7 (x64) and I am unable to notice any issue. For your reference, I have also attached the resultant file generated over my end.

Can you please share some details regarding your working environment. We are sorry for this inconvenience.

[C#]

//open
document
<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/15+TTea+Food+for+Less+Coupon2out.pdf");

for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)

{

using (FileStream imageStream = new FileStream("c:/pdftest/15+TTea+Food+for+Less+Coupon2out_image" + pageCount + ".png", FileMode.Create))

{

//create Resolution object

Resolution resolution = new Resolution(300);

PngDevice pngDevice = new PngDevice(resolution);

//convert a particular page and save the image to stream

pngDevice.Process(pdfDocument.Pages[pageCount], imageStream);

//close stream

imageStream.Close();

}

}