Dim caption As String = "Example: SetAnnotationName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = 0
Dim annotType As String = "", annotSubType As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) <> GdPictureStatus.OK Then Exit For
annotCount = gdpicturePDF.GetAnnotationCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If annotCount = 0 Then Continue For
For j As Integer = 0 To annotCount - 1
annotType = gdpicturePDF.GetAnnotationType(j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If annotType.Equals("Annot") AndAlso annotSubType.Equals("Text") Then
If gdpicturePDF.SetAnnotationName(j, "Text_p" + i.ToString() + "_idx" + j.ToString()) <> GdPictureStatus.OK Then Exit For
End If
Next
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_annotnames.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int annotCount = 0;
string annotType = "", annotSubType = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) != GdPictureStatus.OK) break;
annotCount = gdpicturePDF.GetAnnotationCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (annotCount == 0) continue;
for (int j = 0; j < annotCount; j++)
{
annotType = gdpicturePDF.GetAnnotationType(j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (annotType.Equals("Annot") && annotSubType.Equals("Text"))
{
if (gdpicturePDF.SetAnnotationName(j, "Text_p" + i.ToString() + "_idx" + j.ToString()) != GdPictureStatus.OK) break;
}
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_annotnames.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
gdpicturePDF.Dispose();