You are here: GdPicture.NET > Documentation > Classes > GdPictureImaging Class > GdPictureImaging Methods > PDF Reader > PdfReaderGetImageCount Method
logo.gif
ContentsIndexHome
PreviousUpNext
GdPictureImaging.PdfReaderGetImageCount Method

Returns the number of bitmap available on the selected page of a PDF.

C#
public int PdfReaderGetImageCount(
    int hPdf
);
Visual Basic
Public Function PdfReaderGetImageCount(
    ByVal hPdf As Integer
) As Integer
Parameters
Parameters 
Description 
hPdf 
A PDF handle returned by the PdfReaderLoadFromFile or the PdfReaderLoadFromStream function. 
Returns

The number of available bitmap.

You can use the GetStat() function to determine if this function failed.

Extracting all bitmap of a PDF to a multipage TIFF 

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   Dim oGdPictureImaging As New GdPictureImaging
   oGdPictureImaging.SetLicenseNumber("XXX") 'Replace XXX by a valid demo or commercial KEY

   Dim ImageNo As Integer = 0 'Number of extracted bitmaps
   Dim TiffID As Integer = 0 'the multipage TIFF document ID
   Dim hPDF As Integer = oGdPictureImaging.PdfReaderLoadFromFile("c:input.pdf")
   Dim Status As GdPictureStatus = oGdPictureImaging.GetStat

   If oGdPictureImaging.GetStat = GdPictureStatus.OK Then
       For i As Integer = 1 To oGdPictureImaging.PdfReaderGetPageCount(hPDF)
           If Status = GdPictureStatus.OK Then
               If oGdPictureImaging.PdfReaderSelectPage(hPDF, i) Then
                   For j As Integer = 1 To oGdPictureImaging.PdfReaderGetImageCount(hPDF)
                       If Status = GdPictureStatus.OK Then
                           Dim ImageID As Integer = oGdPictureImaging.PdfReaderExtractImage(hPDF, j)
                           Status = oGdPictureImaging.GetStat
                           If Status = GdPictureStatus.OK Then
                               ImageNo += 1
                               If ImageNo = 1 Then
                                   'Start the Multipage tiff document
                                   TiffID = ImageID
                                   Status = oGdPictureImaging.TiffSaveAsMultiPageFile(TiffID, "c:output.tif", TiffCompression.TiffCompressionAUTO)
                               Else
                                   'Add image to multipage tiff document
                                   Status = oGdPictureImaging.TiffAddToMultiPageFile(TiffID, ImageID)
                                   oGdPictureImaging.ReleaseGdPictureImage(ImageID)
                               End If
                           End If
                       End If
                   Next
               Else
                   MsgBox("Error selecting page: " + Str(i))
                   Status = oGdPictureImaging.GetStat
               End If
           End If
       Next
       oGdPictureImaging.PdfReaderCloseDocument(hPDF)
   Else
       MsgBox("Can't open PDF")
   End If

   If TiffID <> 0 Then oGdPictureImaging.TiffCloseMultiPageFile(TiffID)

   If Status = GdPictureStatus.OK Then
       MsgBox("operation done with success !")
   Else
       MsgBox("an error occurred")
   End If
End Sub
What do you think about this topic? Send feedback!
Copyright (c) 2009-2011 www.gdpicture.com. All rights reserved.