Thumbnail browser of a multipage PDF file in vb.net

Example requests & Code samples for GdPicture Toolkits.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5597
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Thumbnail browser of a multipage PDF file in vb.net

Post by Loïc » Fri Mar 28, 2008 1:36 pm

A sample to create a thumbnail browser of a multipage PDF file using GdPicture Pro & vb.net


- Start a new project.
- Add an AxImaging object to your form (AxImaging1)
- Add an AxGdViewer object to your form (AxGdViewer1)
- Add a Button object (Button1)
- Add a ListView object (ListView1)
- Add an OpenFileDialog object (OpenFileDialog1)
- Add an ImageList object (ImageList1)



And copy this code into Form1:

Code: Select all

Public Class Form1

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        For i As Integer = 0 To ListView1.Items.Count - 1
            If ListView1.Items.Item(i).Selected = True Then
                AxGdViewer1.DisplayFrame(i + 1)
                Return
            End If
        Next
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim nThumbnailID As Long
        Dim nCpt As Integer

        OpenFileDialog1.Filter = "PDF Files|*.pdf"

        OpenFileDialog1.ShowDialog()
        AxGdViewer1.ZoomMode = GdPicturePro5.ViewerZoomMode.ZoomFitToControl
        AxGdViewer1.LockControl = True
        AxGdViewer1.PdfDpiRendering = 50
        AxGdViewer1.DisplayFromPdfFile(OpenFileDialog1.FileName)

        ImageList1.ImageSize = New Size(100, 100)
        ImageList1.Images.Clear()
        ListView1.Items.Clear()

        If AxGdViewer1.GetNativeImage <> 0 Then
            For nCpt = 1 To AxGdViewer1.PageCount
                AxGdViewer1.DisplayFrame(nCpt)
                nThumbnailID = AxImaging1.CreateThumbnailHQ(AxGdViewer1.GetNativeImage, 100, 100)
                AxImaging1.SetNativeImage(nThumbnailID)
                Call ImageList1.Images.Add("", Bitmap.FromHbitmap(AxImaging1.GetHBitmap))
                Call ListView1.Items.Add("", nCpt - 1)
                AxImaging1.CloseImage(nThumbnailID)
            Next nCpt
            AxGdViewer1.PdfDpiRendering = 120
            AxGdViewer1.LockControl = False
            AxGdViewer1.DisplayFrame(1)
        End If

        ListView1.LargeImageList = ImageList1
    End Sub

End Class
Attachments
screenshot.JPG
screenshot

NWM
Posts: 11
Joined: Wed Oct 17, 2007 8:09 pm

Re: Thumbnail browser of a multipage PDF file in vb.net

Post by NWM » Fri Mar 28, 2008 11:47 pm

Thank you so much for your help!!!

You always deliver excellent support.

Thanks Again!

Neil
NWM

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 4 guests