PDFReader - creating thumbnails performance problems

Discussions about PDF management.
Post Reply
ebbiTeam
Posts: 20
Joined: Fri May 13, 2011 3:49 pm

PDFReader - creating thumbnails performance problems

Post by ebbiTeam » Fri Jun 10, 2011 10:18 am

Hello,

I have my own implementation of a pdf-thumbnailview using a .net listview and your pdfreader component.
Thumbnails are created with the following function:

Code: Select all

m_gdPicture.PdfReaderGetPageThumbnail(m_fileID, 256, 256, Color.White)
This takes a little moment for the conversion and e.g. creating thumbnails for 10 pdf-pages will need some seconds. Is there any chance to improve the time for the conversion? Perhaps there's another function to fasten it up? (maybe v8 is faster regarding this issue?)
If you wonder why I'm not using your thumbnailEx component: It has not all features available I do need (e.g. multiselect without checkboxes, drag&drop, full handling with the items/thumbs...) . That's a great pity cause it's loading and showing the thumbs very fast.

Help will be much appreciated.

Best regards
Tobias Herold

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PDFReader - creating thumbnails performance problems

Post by Loïc » Fri Jun 10, 2011 10:34 am

Hi Tobias,

We consider the PdfReaderGetPageThumbnail very fast. Almost all the time it is most faster that Adobe Acrobat API...

When you tell "for 10 pdf-pages will need some seconds. ", I am not agree. For 10 pdf-pages it takes less than 1 sec with me. So I suspect you have a perf issue with your thumbnail control or something else.

BTW, the rasterization have been improved in V8, but in your case I don't think this will considerably reduce your loading time since I suspect your problem to be away..

Kind regards,

Loïc

ebbiTeam
Posts: 20
Joined: Fri May 13, 2011 3:49 pm

Re: PDFReader - creating thumbnails performance problems

Post by ebbiTeam » Fri Jun 10, 2011 11:27 am

Okay, I'm glad to hear that. :)

Could you please have a look to the relevant parts of my implementation and give me the difference to your fast solution?

Code: Select all



Private m_gdPicture As New GdPicture.GdPictureImaging
Private m_page As New PDFSplitterDocumentPage 'Representing a PDF page
Private m_fileID As Integer

 Public Sub FileOpen(ByVal sender As Object, ByVal e As EventArgs)
        Dim filePaths As String() = Nothing
        Dim fileNames As String() = Nothing

        If MyBase.WorkItem.Status = WorkItemStatus.Active Then
            If m_view.OpenDocumentDialog.ShowDialog = DialogResult.OK Then
                m_page = New PDFSplitterDocumentPage 
                filePaths = m_view.OpenDocumentDialog.FileNames
                fileNames = m_view.OpenDocumentDialog.SafeFileNames

                For fileIndex As Integer = 0 To fileNames.Length - 1
                    m_openFilename = fileNames(fileIndex)
                    m_openFilepath = filePaths(fileIndex)

                    m_fileID = m_gdPicture.PdfReaderLoadFromFile(m_openFilepath) 

                    FillThumbnailLists() 'Adds thumbnails to the ListView&Imagelist
                Next
            End If
        End If
End Sub


'Adds created thumbnail-bitmaps to the imagelist which is connected to the listview
Public Sub AddToThumbnailImageList(ByVal documentPage As PDFSplitterDocumentPage)
        m_view.ThumbnailImageList.Images.Add(documentPage.ThumbnailKeyword, documentPage.ThumbnailPicture)
End Sub

'Adds thumbnail entries to the listview
Public Sub AddToThumbnailListView(ByVal documentPage As PDFSplitterDocumentPage)
        m_view.ThumbnailListView.Items.Add(documentPage.ThumbnailKeyword, documentPage.ThumbnailKeyword, documentPage.ThumbnailKeyword)
        m_view.ThumbnailListView.Items(documentPage.ThumbnailKeyword).Tag = documentPage
 End Sub

'Creates a PDF page and the associated thumbnail
Public Function CreateDocumentPage(ByVal pageID As Integer, ByVal pageNumber As Integer) As PDFSplitterDocumentPage
        m_gdPicture.PdfReaderSelectPage(pageID, pageNumber) 
        Dim thumbId As Integer = m_gdPicture.PdfReaderGetPageThumbnail(m_fileID, 256, 256, Color.White) 
        Dim documentPage As PDFSplitterDocumentPage = New PDFSplitterDocumentPage()
        Dim thumbPic As Bitmap = Bitmap.FromHbitmap(m_gdPicture.GetHBitmapFromGdPictureImage(thumbId)) 'convert to bitmap for listview handling
        documentPage.ThumbnailPicture = thumbPic
        documentPage.PageNumber = pageNumber
        documentPage.PageID = pageID
        documentPage.ThumbnailKeyword = "Page " & pageNumber 
         Return documentPage
End Function

Public Sub FillThumbnailLists()
        m_documentID += 1
        If m_view.ThumbnailListView.Items.Count > -1 Then
            For item As Integer = 1 To m_gdPicture.PdfReaderGetPageCount(m_fileID)
                m_page = CreateDocumentPage(m_, item)
                AddToThumbnailImageList(m_page)
                AddToThumbnailListView(m_page)
            Next
        Else
        End If
End Sub

Thank you very much
Tobias Herold

ebbiTeam
Posts: 20
Joined: Fri May 13, 2011 3:49 pm

Re: PDFReader - creating thumbnails performance problems

Post by ebbiTeam » Wed Jun 15, 2011 11:28 am

Do you have any idea how to improve the performance for my case?

Thank you very much.

ebbiTeam
Posts: 20
Joined: Fri May 13, 2011 3:49 pm

Re: PDFReader - creating thumbnails performance problems

Post by ebbiTeam » Fri Jun 24, 2011 3:01 pm

Please have a look at my implementation.
I'm sure you can find the problem very fast.

Thanks and best regards,

Tobias Herold

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PDFReader - creating thumbnails performance problems

Post by Loïc » Sat Jun 25, 2011 12:39 pm

Hi,

There is no problem in your code. Also, I can't fully investigate how to optimize your own application for you.
Maybe you should try to use a tool such as ANTS Performance Profiler http://www.red-gate.com/products/dotnet ... -profiler/ to identify the critical parts of your code.

Also keep in mind that Building ThumbnailEx control required more than 2 month of developments to obtain an earlier Alpha version. We use multi-threading approach + an internal kind of garbage collector to fast allocate/de-allocate thumbnails in memory + low-level api to render each item of the list.

Kind regards,

Loïc




-

ebbiTeam
Posts: 20
Joined: Fri May 13, 2011 3:49 pm

Re: PDFReader - creating thumbnails performance problems

Post by ebbiTeam » Wed Jun 29, 2011 12:12 pm

Hello,

thanks for looking at my code.

I have tested the code again (now it's adapted to v 8) and the critical time consuming part is clearly the method for converting to
thumbnail:

Code: Select all

Dim thumbId As Integer = pdfManaging.GetPageThumbnail(32, 32, color.White )
I have shared the workflow into 3 parts to find out what's slowing down.

1.) Loading the pdf document
2.) Creating the thumbnails of all pages and add them to a collection
3.) Go over this collection and fill my thumbnailview(= ListView in Thumbnailmode&ImageList)

The attached sample document results in the following times for these steps:
Step 1: < 100 ms
Step 2: ~15 sec
Step 3: ~ 1,5 sec.

Is this value in Step 2 the best I could expect for this sample document or do you see any optimization potencial?

What I will do for better performance is the implementation of multithreading, so the creation of thumbnails will be spread over multiple cores.

Of course I would rather use your very fast thumbnailEx-control instead of implementating a similar one by myself but the drag&drop and multipage functionallity isn't sufficient for our needs - unfortunately.

Kind regards
Tobias Herold
Attachments
tx_ocx_programmers_guide.zip
Sample pdf document for performance test
(933.37 KiB) Downloaded 299 times

ebbiTeam
Posts: 20
Joined: Fri May 13, 2011 3:49 pm

Re: PDFReader - creating thumbnails performance problems

Post by ebbiTeam » Tue Jul 05, 2011 11:10 am

Nothing to say about this issue?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests