We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Image Rendering allocates lot of memory

i use the current Aspose PDF for NET release with a test license and this sample to render PDF
pages to PNG image files.
It works but pngDevice.Process allocates more and more memory for each page.

        For i = 1 To doc1.Pages.Count
            SourcePage = doc1.Pages(i)
            OutFile = "c:\temp\image" & i & ".png"

            Dim pngDevice As New PngDevice(resolution)
            pngDevice.RenderingOptions.UseNewImagingEngine = True
            pngDevice.Process(SourcePage, OutFile)
            pngDevice = Nothing


It seems that pngDevice.Process doesn’t free up all internal ressources after writing the image to disk.


Thanks for contacting support.

Please use following code snippet in order to convert PDF Pages into PNG images.

Dim pdfDocument As New Document(dataDir + "source.pdf")
For pageCount As Integer = 1 To pdfDocument.Pages.Count
	Dim tmpImgToInsert As String = pageCount + "_" + DateTime.Now.Ticks + ".png"
	Using imageStream As New FileStream(dataDir & tmpImgToInsert, FileMode.Create)
		' Create Resolution object
		Dim resolution As New Resolution(120)
		' Create PNG device with specified attributes
		Dim pngDevice As New PngDevice(resolution)
		pngDevice.RenderingOptions = New RenderingOptions() With { _
			Key .ScaleImagesToFitPageWidth = True _
		' Convert a particular page and save the image to stream
		pngDevice.Process(pdfDocument.Pages(pageCount), imageStream)
	End Using

In case if you still experience any issue, please share your sample PDF document with us, so that we can test the scenario in our environment and address it accordingly.