GdPicture.NET.14.API
GdPicture14 Namespace / AnnotationManager Class / InitFromGdViewer Method
The GdViewer object that handles the source document. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
Example





In This Topic
InitFromGdViewer Method (AnnotationManager)
In This Topic
Initializes the current AnnotationManager object from a previously instantiated GdViewer object. The document previously handled by this AnnotationManager object will automatically close.

This method only initialises the AnnotationManager object, it means this AnnotationManager object will not be connected to the source GdViewer object. You need to use the GdViewer.GetAnnotationManager() method to have these objects linked for further usage, for example, when deleting annotations.

Be aware that the AnnotationManager object only handles GdPicture/XMP annotations available through the source GdViewer object.

Syntax
'Declaration
 
Public Function InitFromGdViewer( _
   ByVal Viewer As Object _
) As GdPictureStatus
public GdPictureStatus InitFromGdViewer( 
   object Viewer
)
public function InitFromGdViewer( 
    Viewer: TObject
): GdPictureStatus; 
public function InitFromGdViewer( 
   Viewer : Object
) : GdPictureStatus;
public: GdPictureStatus InitFromGdViewer( 
   Object* Viewer
) 
public:
GdPictureStatus InitFromGdViewer( 
   Object^ Viewer
) 

Parameters

Viewer
The GdViewer object that handles the source document. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.

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.
Example
How to initialize the AnnotationManager object from already initialized GdViewer object.
'We assume that the GdViewer1 control has been integrated into your application.
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK) AndAlso
   (GdViewer1.DisplayFromGdPicturePDF(gdpicturePDF) = GdPictureStatus.OK) Then
    Dim annotationManager As AnnotationManager = New AnnotationManager()
    If (annotationManager.InitFromGdViewer(GdViewer1) = 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
            annotationManager.SaveAnnotationsToPage()
            stamp.Dispose()
        Else
            MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdViewer")
        End If
    End If
    annotationManager.Close()
    GdViewer1.Redraw()
End If
//We assume that the GdViewer1 control has been integrated into your application.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK) &&
    (GdViewer1.DisplayFromGdPicturePDF(gdpicturePDF) == GdPictureStatus.OK))
{
    AnnotationManager annotationManager = new AnnotationManager();
    if ((annotationManager.InitFromGdViewer(GdViewer1) == 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;
            annotationManager.SaveAnnotationsToPage();
            stamp.Dispose();
        }
        else
            MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdViewer");
    }
    annotationManager.Close();
    GdViewer1.Redraw();
}
See Also