GetAnnotationCount Method (AnnotationManager)
In This Topic
Returns the number of all GdPicture/XMP annotation objects contained within the selected page of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
Syntax
'Declaration
Public Function GetAnnotationCount() As Integer
public int GetAnnotationCount()
public function GetAnnotationCount(): Integer;
public function GetAnnotationCount() : int;
public: int GetAnnotationCount();
public:
int GetAnnotationCount();
Return Value
The number of all GdPicture/XMP annotation objects included within the selected page of the handled document.
Example
How to find out the number of GdPicture/XMP annotations within the 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.SelectPage")
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then MessageBox.Show(message, "AnnotationManager.SelectPage")
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
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.SelectPage");
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
break;
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, "AnnotationManager.SelectPage");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
}
Example
How to find out the number of GdPicture/XMP annotations within the 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.SelectPage")
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then MessageBox.Show(message, "AnnotationManager.SelectPage")
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
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.SelectPage");
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
break;
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, "AnnotationManager.SelectPage");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
}
See Also