Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
For p As Integer = 1 To annotationManager.PageCount
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For a As Integer = 0 To annotCount - 1
Dim value As Object = annotationManager.GetAnnotationPropertyValue(a, "Tag")
Dim tagValue As String = ""
If value IsNot Nothing Then
tagValue = CStr(value)
If tagValue.Equals("delete") Then
If annotationManager.DeleteAnnotation(a) <> GdPictureStatus.OK Then Exit For
Else
tagValue += " checked"
value = CObj(tagValue)
If annotationManager.SetAnnotationPropertyValue(a, "Tag", value) <> GdPictureStatus.OK Then Exit For
End If
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.SetAnnotationPropertyValue")
Else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
for (int p = 1; p <= annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int a = 0; a < annotCount; a++)
{
object value = annotationManager.GetAnnotationPropertyValue(a, "Tag");
string tagValue = "";
if (value != null)
{
tagValue = (string)value;
if (tagValue.Equals("delete"))
{
if (annotationManager.DeleteAnnotation(a) != GdPictureStatus.OK) break;
}
else
{
tagValue += " checked";
value = (object)tagValue;
if (annotationManager.SetAnnotationPropertyValue(a, "Tag", value) != GdPictureStatus.OK) break;
}
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
annotationManager.SaveAnnotationsToPage();
if (annotationManager.GetStat() != GdPictureStatus.OK) break;
}
else break;
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.SetAnnotationPropertyValue");
else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue");
}