GdPicture.NET Reference Guide
TiffGetPageCount Method (GdPictureImaging)
Example 





GdPicture14 Namespace > GdPictureImaging Class : TiffGetPageCount Method
A unique image identifier of the GdPicture image 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 GdPicture image 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
Deleting pages of a multipage tiff document.
Deleting the last page of a multipage tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // LoadInMemory parameter is set to true in order to be able to update the input file.
    int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
    int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
    gdpictureImaging.TiffDeletePage(imageID, pageCount);
    gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removing the blank pages from a tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // LoadInMemory parameter is set to true in order to be able to update the input file.
    int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
    int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
    int pageNo = 1;
    while (pageNo <= pageCount)
    {
        gdpictureImaging.TiffSelectPage(imageID, pageNo);
        if (gdpictureImaging.IsBlank(imageID))
        {
            gdpictureImaging.TiffDeletePage(imageID, pageNo);
            pageCount--;
        }
        else
        {
            pageNo++;
        }
    }
    gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also

Reference

GdPictureImaging Class
GdPictureImaging Members
GetStat Method
TiffGetPageCount Method
TiffIsMultiPage Method
TiffIsEditableMultiPage Method