Dim caption As String = "Example: RemoveAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString() + ": "
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
For annotID As Integer = annotCount - 1 To 0
status = gdpicturePDF.RemoveAnnotation(annotID)
If status <> GdPictureStatus.OK Then
message = message + "annotID: " + annotID.ToString() + " "
Exit For
End If
Next
message += status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("removed_annots.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString() + ": ";
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int annotID = annotCount - 1; annotID >= 0; annotID--)
{
status = gdpicturePDF.RemoveAnnotation(annotID);
if (status != GdPictureStatus.OK)
{
message = message + "annotID: " + annotID.ToString() + " ";
break;
}
}
message += status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("removed_annots.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();