PDF to Image Conversion Performance

I am trying to convert a list of PDF documents referenced in a datagridview. When a user clicks on the row, I am converting the first page of that referenced PDF to a PNG device into a PictureBox as a preview. The user can then use a backwards and forwards button to skip between pages.


The VB code I am using is:

Public Property DocumentPDF() As Aspose.Pdf.Document
Get
Return pDocument
End Get
Set(ByVal value As Aspose.Pdf.Document)
pDocument = value
pPageNumber = 1

Call PDFDoc()
End Set
End Property

Private Sub PDFDoc()

Dim pageIndex As Integer = pPageNumber

Using memoryStream As New MemoryStream()

Dim resolution As New Resolution(72)
Dim pngDevice1 As New PngDevice(500, 700, resolution)

Try
pngDevice1.Process(pDocument.Pages(pageIndex), memoryStream)

docPagePictureBox.Width = 500 + 50 'SystemInformation.WorkingArea.Width - SystemInformation.VerticalScrollBarWidth)
docPagePictureBox.Height = 700 + 50
docPagePictureBox.Image = Image.FromStream(memoryStream)
Catch ex As Exception
MsgBox(ex.Message, vbOKOnly)
End Try

memoryStream.Dispose()
End Using

cursor.Current = cursor
End Sub


This unfortunately takes about 5-10 seconds to convert each selected PDF page to image.

Is there a way to improve the performance of this process?

Thanks
Paul

Hi Paul,


Thanks for using our products.

Can you please share the source PDF document so that we can test the scenario at our end. We are sorry for this inconvenience.

Please see example PDF attached.

Hi Paul,

Thank you for sharing the template file and sample code.

I tested your scenario with the latest version of Aspose.Pdf for .NET v6.9 and it took only 1.2 Sec to convert the first page of your shared file to memory stream. If you are using an older version then please download and try the latest version of Aspose.Pdf for .NET and let us know if it resolves the performance issue at your end. If you still face any issue, we will request you to create a sample application and share with us and also provide us the details regarding your system environment so we can test your issue accordingly.

Sorry for the inconvenience.

I have taken this document and scanned in 10 pages on a scanner, as users would usually.


Please could you check this? Is there an issue with the scanned PDF format?

Thanks
Paul

Hello Paul,


Thanks for sharing the resource file.

I have tested the scenario while converting the first page of PDF file and as per my observations, when tested with Aspose.Pdf for .NET 6.9.0, the process took around 24 seconds to convert the first page of PDF file to PNG image. For the sake of correction, I have logged this problem as PDFNEWNET-33676 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are really sorry for this inconvenience.

The issues you have found earlier (filed as PDFNET-33676) have been fixed in Aspose.PDF for .NET 25.11.