Systems tried: Windows 7 64bit, 8GB RAM, Core i7 4700MQ
Hyper-V VM with Windows 2008R2 64bit, 8GB RAM, E5640 Xeon
.NET Version 4.5.2
Aspose.Pdf version 9.7
We are trying to consolidate all of our PDF processing into Aspose.Pdf. Converting PDF to images takes a lot of time. For the attached file PDFNet takes 2.3 seconds and Aspose.Pdf takes 17 seconds to convert the PDF to images while consuming 25% more CPU (over a longer period of time) and consuming 5 times the amount of memory.
Code sample is bellow. Over 99% of the below function was spent on the
bmpDevice.Process(_doc.Pages[pageNumber], stream); line
public Bitmap GetPageImage(int pageNumber)
{
Resolution resolution = new Resolution(95);
BmpDevice bmpDevice = new BmpDevice(resolution);<span style="color:blue;">using</span> (<span style="color:blue;">var</span> stream = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>()) { bmpDevice.Process(_doc.Pages[pageNumber], stream); <span style="color:blue;">var</span> imgBytes = stream.ToArray(); <span style="color:blue;">var</span> converter = <span style="color:blue;">new</span> <span style="color:#2b91af;">ImageConverter</span>(); <span style="color:#2b91af;">Bitmap</span> bitmap = (<span style="color:#2b91af;">Bitmap</span>)converter.ConvertFrom(imgBytes); <span style="color:blue;">return</span> bitmap; } } <span style="color:blue;">public</span> <span style="color:#2b91af;">List</span><<span style="color:#2b91af;">Bitmap</span>> GetPageImages() { <span style="color:#2b91af;">List</span><<span style="color:#2b91af;">Bitmap</span>> bitmaps = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span><<span style="color:#2b91af;">Bitmap</span>>(); <span style="color:blue;">for</span> (<span style="color:blue;">int</span> pageNum = 1; pageNum <= _doc.Pages.Count; pageNum++) { bitmaps.Add(GetPageImage(pageNum)); } <span style="color:blue;">return</span> bitmaps; }</pre>Thank you.<br>