GdPicture.NET.14.API
GdPicture14 Namespace / AnnotationManager Class / AddLineAnnot Method
A color object that defines the required color of the newly added line annotation. It corresponds to the AnnotationLine.StrokeColor property.
The horizontal (X) coordinate of the starting point of the drawn line, in inches.
The vertical (Y) coordinate of the starting point of the drawn line, in inches.
The horizontal (X) coordinate of the ending point of the drawn line, in inches.
The vertical (Y) coordinate of the ending point of the drawn line, in inches.
Example





In This Topic
AddLineAnnot Method (AnnotationManager)
In This Topic
Adds a new GdPicture/XMP line annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified. A line annotation presents a single straight line drawn with the defined color, which uses the flat cap style on both its ending points.

The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeLine. You can change the annotation properties directly using the GdPicture14.Annotations.AnnotationLine class right after the successful creation of the annotation object.

Be aware that annotations are always treated relative to the currently selected page.

Adds a new GdPicture/XMP line annotation on the selected page of the document currently handled by this AnnotationManager object.
Syntax
'Declaration
 
Public Function AddLineAnnot( _
   ByVal BorderColor As GdPictureColor, _
   ByVal SrcLeft As Single, _
   ByVal SrcTop As Single, _
   ByVal DstLeft As Single, _
   ByVal DstTop As Single _
) As AnnotationLine
public AnnotationLine AddLineAnnot( 
   GdPictureColor BorderColor,
   float SrcLeft,
   float SrcTop,
   float DstLeft,
   float DstTop
)
public function AddLineAnnot( 
    BorderColor: GdPictureColor;
    SrcLeft: Single;
    SrcTop: Single;
    DstLeft: Single;
    DstTop: Single
): AnnotationLine; 
public function AddLineAnnot( 
   BorderColor : GdPictureColor,
   SrcLeft : float,
   SrcTop : float,
   DstLeft : float,
   DstTop : float
) : AnnotationLine;
public: AnnotationLine* AddLineAnnot( 
   GdPictureColor BorderColor,
   float SrcLeft,
   float SrcTop,
   float DstLeft,
   float DstTop
) 
public:
AnnotationLine^ AddLineAnnot( 
   GdPictureColor BorderColor,
   float SrcLeft,
   float SrcTop,
   float DstLeft,
   float DstTop
) 

Parameters

BorderColor
A color object that defines the required color of the newly added line annotation. It corresponds to the AnnotationLine.StrokeColor property.
SrcLeft
The horizontal (X) coordinate of the starting point of the drawn line, in inches.
SrcTop
The vertical (Y) coordinate of the starting point of the drawn line, in inches.
DstLeft
The horizontal (X) coordinate of the ending point of the drawn line, in inches.
DstTop
The vertical (Y) coordinate of the ending point of the drawn line, in inches.

Return Value

A GdPicture/XMP AnnotationLine object. The newly added GdPicture/XMP line annotation.
Remarks
Please ensure that you have selected the proper page before starting any annotation related action with the handled document. Annotations are always treated relative to the currently selected page.

You can regularly apply the AnnotationManager.GetStat method to determine if this method has been successful.

Example
How to use a line annotation to permanently underline found text.
'We assume that the GdViewer1 control has been integrated into your application.
If GdViewer1.DisplayFromFile("text_to_search.txt") = GdPictureStatus.OK Then
    Dim annotMgr As AnnotationManager = GdViewer1.GetAnnotationManager()
    If (annotMgr IsNot Nothing) AndAlso (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
        Dim text_to_find As String = "GdPicture"
        Dim occurrence As Integer = 1
        Dim left As Single = 0, top As Single = 0, width As Single = 0, height As Single = 0
        Dim text_found As Boolean = False
        GdViewer1.RemoveAllRegions()
        While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, left, top, width, height)
            text_found = True
            Dim annotLine As GdPicture14.Annotations.AnnotationLine = annotMgr.AddLineAnnot(Color.Blue, left, top + height, left + width, top + height)
            If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotLine IsNot Nothing) Then
                annotLine.Author = "GdPicture"
                annotLine.BorderWidth = 0.05F
                annotLine.Tag = "Line"
            End If
            annotLine.Dispose()
            occurrence = occurrence + 1
        End While
        If text_found Then
            If (annotMgr.SaveAnnotationsToPage() <> GdPictureStatus.OK) OrElse
               (annotMgr.BurnAnnotationsToPage(True) <> GdPictureStatus.OK) OrElse
               (annotMgr.SaveDocumentToJPEG("text_lines.jpg", 75) <> GdPictureStatus.OK) Then
                MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddLineAnnot")
            End If
            GdViewer1.Redraw()
        Else
            MessageBox.Show("The given text has not been found.", "AnnotationManager.AddLineAnnot")
        End If
    Else
        MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddLineAnnot")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddLineAnnot")
End If
//We assume that the GdViewer1 control has been integrated into your application.
if (GdViewer1.DisplayFromFile("text_to_search.txt") == GdPictureStatus.OK)
{
    AnnotationManager annotMgr = GdViewer1.GetAnnotationManager();
    if ((annotMgr != null) && (annotMgr.SelectPage(1) == GdPictureStatus.OK))
    {
        string text_to_find = "GdPicture";
        int occurrence = 1;
        float left = 0, top = 0, width = 0, height = 0;
        bool text_found = false;
        GdViewer1.RemoveAllRegions();
        while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, ref left, ref top, ref width, ref height))
        {
            text_found = true;
            GdPicture14.Annotations.AnnotationLine annotLine = annotMgr.AddLineAnnot(Color.Blue, left, top+height, left+width, top+height);
            if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotLine != null))
            {
                annotLine.Author = "GdPicture";
                annotLine.BorderWidth = 0.05f;
                annotLine.Tag = "Line";
            }
            annotLine.Dispose();
            occurrence = occurrence + 1;
        }
        if (text_found)
        {
            if ((annotMgr.SaveAnnotationsToPage() != GdPictureStatus.OK) ||
                (annotMgr.BurnAnnotationsToPage(true) != GdPictureStatus.OK) ||
                (annotMgr.SaveDocumentToJPEG("text_lines.jpg", 75) != GdPictureStatus.OK))
                MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddLineAnnot");
            GdViewer1.Redraw();
        }
        else
            MessageBox.Show("The given text has not been found.", "AnnotationManager.AddLineAnnot");
    }
    else
        MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddLineAnnot");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddLineAnnot");
See Also