GdPicture.NET Reference Guide
TiffGetPageCount Method (GdPictureImaging)
Example 





GdPicture14 Namespace > GdPictureImaging Class : TiffGetPageCount Method
A unique image identifier of the GdPictureImage object representing the multipage TIFF image.
Returns the number of pages in the specified multipage TIFF image represented by its unique image identifier.

Please note that this method only handles multipage TIFF images, both editable or opened as read-only.

Syntax
'Declaration
 
Public Function TiffGetPageCount( _
   ByVal ImageID As Integer _
) As Integer
public int TiffGetPageCount( 
   int ImageID
)
public function TiffGetPageCount( 
    ImageID: Integer
): Integer; 
public function TiffGetPageCount( 
   ImageID : int
) : int;
public: int TiffGetPageCount( 
   int ImageID
) 
public:
int TiffGetPageCount( 
   int ImageID
) 

Parameters

ImageID
A unique image identifier of the GdPictureImage object representing the multipage TIFF image.

Return Value

The number of pages in the specified multipage TIFF image. Please always use the GetStat method to determine if this method has been successful.
Remarks
We strongly recommend using the GetStat method to identify the specific reason for the method's failure.

Be aware that this method only supports multipage TIFF images, both editable or opened as read-only. If the specified image is not a multipage image, this method will fail.

Example
How to find out the number of pages in your multipage TIFF image.
Dim caption As String = "Example: TiffGetPageCount"
Using oImage As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("multipage.tiff")
    If oImage.GetStat() = GdPictureStatus.OK Then
 
        Dim multipage As Boolean = oImage.TiffIsMultiPage(imageID)
        If oImage.GetStat() <> GdPictureStatus.OK Then GoTo Finished
 
        Dim editable As Boolean = oImage.TiffIsEditableMultiPage(imageID)
        If oImage.GetStat() <> GdPictureStatus.OK Then GoTo Finished
 
        Dim pageCount As Integer = oImage.TiffGetPageCount(imageID)
        If oImage.GetStat() <> GdPictureStatus.OK Then GoTo Finished
        
        MessageBox.Show("The image file: " + oImage.GetLastPath() + vbCrLf + "  multipage: " + multipage.ToString() + vbCrLf +
                        "  editable: " + editable.ToString() + vbCrLf + "  number of pages: " + pageCount, caption)
    Finished:
        If oImage.GetStat() <> GdPictureStatus.OK Then MessageBox.Show("Error!    status: " + oImage.GetStat().ToString(), caption)
 
        oImage.ReleaseGdPictureImage(imageID)
    Else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption)
    End If
End Using
string caption = "Example: TiffGetPageCount";
using (GdPictureImaging oImage = new GdPictureImaging())
{
    int imageID = oImage.CreateGdPictureImageFromFile("multipage.tiff");
    if (oImage.GetStat() == GdPictureStatus.OK)
    {
        bool multipage = oImage.TiffIsMultiPage(imageID);
        if (oImage.GetStat() != GdPictureStatus.OK) goto Finished;
        
        bool editable = oImage.TiffIsEditableMultiPage(imageID);
        if (oImage.GetStat() != GdPictureStatus.OK) goto Finished;
 
        int pageCount = oImage.TiffGetPageCount(imageID);
        if (oImage.GetStat() != GdPictureStatus.OK) goto Finished;
        
        MessageBox.Show("The image file: " + oImage.GetLastPath() + "\n  multipage: " + multipage.ToString() +
                        "\n  editable: " + editable.ToString() + "\n  number of pages: " + pageCount, caption);
 
    Finished:
        if (oImage.GetStat() != GdPictureStatus.OK)
            MessageBox.Show("Error!    status: " + oImage.GetStat().ToString(), caption);
 
        oImage.ReleaseGdPictureImage(imageID);
    }
    else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption);
}
See Also

Reference

GdPictureImaging Class
GdPictureImaging Members
CreateGdPictureImageFromFile(String) Method
TiffIsMultiPage Method
TiffIsEditableMultiPage Method
TiffSelectPage Method