Example





In This Topic

PageCount Property (AnnotationManager)

In This Topic
Gets the total number of pages in the document currently handled by this AnnotationManager object.
Syntax
'Declaration
 
Public ReadOnly Property PageCount As Integer
public int PageCount {get;}
public read-only property PageCount: Integer; 
public function get PageCount : int
public: __property int get_PageCount();
public:
property int PageCount {
   int get();
}
Remarks
Be aware that you have to select the required page before starting any page related action with the handled document.
Example
How to find out the number of pages in the currently handled document.
Using annotationManager As AnnotationManager = New AnnotationManager()
    If annotationManager.InitFromFile("test.pdf") = GdPictureStatus.OK Then
        Dim message As String = "The number of pages: " + annotationManager.PageCount
        For p As Integer = 1 To annotationManager.PageCount - 1
            If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
                Dim annotCount As Integer = annotationManager.GetAnnotationCount()
                If annotationManager.GetStat() = GdPictureStatus.OK Then
                    message = message + vbCrLf + "The page nr." + p + " contains " + annotCount.ToString() + " annotations."
                Else
                    MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount")
                    Exit For
                End If
            Else
                MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount")
                Exit For
            End If
        Next
        If annotationManager.GetStat() = GdPictureStatus.OK Then MessageBox.Show(message, "AnnotationManager.PageCount")
        annotationManager.Close()
    Else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount")
    End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
    if (annotationManager.InitFromFile("test.pdf") == GdPictureStatus.OK)
    {
        string message = "The number of pages: " + annotationManager.PageCount;
        for (int p = 1; p < annotationManager.PageCount; p++)
        {
            if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
            {
                int annotCount = annotationManager.GetAnnotationCount();
                if (annotationManager.GetStat() == GdPictureStatus.OK)
                {
                    message = message + "\nThe page nr." + p + " contains " + annotCount.ToString() + " annotations.";
                }
                else
                {
                    MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount");
                    break;
                }
            }
            else
            {
                MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount");
                break;
            }
        }
        if (annotationManager.GetStat() == GdPictureStatus.OK)
            MessageBox.Show(message, "AnnotationManager.PageCount");
        annotationManager.Close();
    }
    else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount");
}
See Also