GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / Close() Method
Example





In This Topic
Close() Method
In This Topic
Closes the current AnnotationManager object by releasing the loaded document and all related annotations data. It is a good practice to call this method when you complete all the necessary annotation handling of the document.
Syntax
'Declaration
 
Public Function Close() As GdPictureStatus
public GdPictureStatus Close()
public function Close(): GdPictureStatus; 
public function Close() : GdPictureStatus;
public: GdPictureStatus Close(); 
public:
GdPictureStatus Close(); 

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Be aware that neither document nor annotations are associated with this AnnotationManager object after closing it anymore.
Example
How to close the current AnnotationManager after adding an anotation to a file.
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
   (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
    Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
    If stamp IsNot Nothing Then
        stamp.Rotation = 20
        If annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
            If annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) <> GdPictureStatus.OK Then
                MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close")
            End If
        Else
            MessageBox.Show("Annotations can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close")
        End If
        stamp.Dispose()
    Else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close")
    End If
    status = annotationManager.GetStat() 'Last known status before closing the annotation manager.
    annotationManager.Close()
Else
    status = annotationManager.GetStat()
    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + status.ToString(), "AnnotationManager.Close")
End If
If status = GdPictureStatus.OK Then
    'We assume that the GdViewer1 control has been integrated into your application.
    GdViewer1.DisplayFromFile("image_approved.jpg")
    annotationManager = GdViewer1.GetAnnotationManager()
End If
GdPictureStatus status = GdPictureStatus.OK;
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
    (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
    GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
    if (stamp != null)
    {
        stamp.Rotation = 20;
        if (annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK)
        {
            if (annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) != GdPictureStatus.OK)
                MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close");
        }
        else
            MessageBox.Show("Annotations can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close");
        stamp.Dispose();
    }
    else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close");
    status = annotationManager.GetStat(); //Last known status before closing the annotation manager.
    annotationManager.Close();
}
else
{
    status = annotationManager.GetStat();
    MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + status.ToString(), "AnnotationManager.Close");
}
if (status == GdPictureStatus.OK)
{
    //We assume that the GdViewer1 control has been integrated into your application.
    GdViewer1.DisplayFromFile("image_approved.jpg");
    annotationManager = GdViewer1.GetAnnotationManager();
}
See Also