GetAnnotationTitle Method (GdPicturePDF)
In This Topic
Returns the title of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It is the text label that is displayed in the title bar of the annotation's pop-up window, mostly it represents the author of the annotation.
Syntax
'Declaration
Public Function GetAnnotationTitle( _
ByVal As Integer _
) As String
public string GetAnnotationTitle(
int
)
public function GetAnnotationTitle(
: Integer
): String;
public function GetAnnotationTitle(
: int
) : String;
public: string* GetAnnotationTitle(
int
)
public:
String^ GetAnnotationTitle(
int
)
Parameters
- AnnotationIdx
- The 0-based index of the required annotation within the current page. It must be a value from 0 to GdPicturePDF.GetAnnotationCount-1.
Return Value
The title of the specified annotation object. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Example
How to retrieve the title, the subject and the content of all text annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = "", title As String = "", subject As String = "", content As String = ""
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Text") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " title: "
title = gdpicturePDF.GetAnnotationTitle(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + title Else message = message + status.ToString()
message = message + " subject: "
subject = gdpicturePDF.GetAnnotationSubject(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + subject Else message = message + status.ToString()
message = message + " content: "
content = gdpicturePDF.GetAnnotationContents(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + content Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "", title = "", subject = "", content = "";
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Text"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n title: ";
title = gdpicturePDF.GetAnnotationTitle(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + title;
else message = message + status.ToString();
message = message + " subject: ";
subject = gdpicturePDF.GetAnnotationSubject(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + subject;
else message = message + status.ToString();
message = message + " content: ";
content = gdpicturePDF.GetAnnotationContents(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + content;
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Example
How to retrieve the title, the subject and the content of all text annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = "", title As String = "", subject As String = "", content As String = ""
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Text") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " title: "
title = gdpicturePDF.GetAnnotationTitle(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + title Else message = message + status.ToString()
message = message + " subject: "
subject = gdpicturePDF.GetAnnotationSubject(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + subject Else message = message + status.ToString()
message = message + " content: "
content = gdpicturePDF.GetAnnotationContents(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + content Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "", title = "", subject = "", content = "";
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Text"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n title: ";
title = gdpicturePDF.GetAnnotationTitle(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + title;
else message = message + status.ToString();
message = message + " subject: ";
subject = gdpicturePDF.GetAnnotationSubject(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + subject;
else message = message + status.ToString();
message = message + " content: ";
content = gdpicturePDF.GetAnnotationContents(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + content;
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also