GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / AddFreeHandHighlighterAnnot Method
A color object that defines the required color of the newly added freehand annotation. It corresponds to the AnnotationFreeHandHighlighter.StrokeColor property.
An array of points, in inches, which determines the line segments to be connected.
Example





In This Topic
AddFreeHandHighlighterAnnot Method (AnnotationManager)
In This Topic
Adds a new GdPicture/XMP freehand highlighter annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified. A freehand highlighter annotation is a drawn line consisting of several connected line segments, which highlights the covered area.

The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeFreeHandHighlighter. You can change the annotation properties directly using the GdPicture14.Annotations.AnnotationFreeHandHighlighter 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 freehand highlighter annotation on the selected page of the document currently handled by this AnnotationManager object.
Syntax
'Declaration
 
Public Function AddFreeHandHighlighterAnnot( _
   ByVal BorderColor As Color, _
   ByVal Points() As PointF _
) As AnnotationFreeHandHighlighter
public AnnotationFreeHandHighlighter AddFreeHandHighlighterAnnot( 
   Color BorderColor,
   PointF[] Points
)
public function AddFreeHandHighlighterAnnot( 
    BorderColor: Color;
    Points: PointFarray of
): AnnotationFreeHandHighlighter; 
public function AddFreeHandHighlighterAnnot( 
   BorderColor : Color,
   Points : PointF[]
) : AnnotationFreeHandHighlighter;
public: AnnotationFreeHandHighlighter* AddFreeHandHighlighterAnnot( 
   Color BorderColor,
   PointF[]* Points
) 
public:
AnnotationFreeHandHighlighter^ AddFreeHandHighlighterAnnot( 
   Color BorderColor,
   array<PointF>^ Points
) 

Parameters

BorderColor
A color object that defines the required color of the newly added freehand annotation. It corresponds to the AnnotationFreeHandHighlighter.StrokeColor property.
Points
An array of points, in inches, which determines the line segments to be connected.

Return Value

A GdPicture/XMP AnnotationFreeHandHighlighter object. The newly added GdPicture/XMP freehand highlighter 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 GetStat method to determine if this method has been successful.

Example
How to add a freehand highlighter annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
    status = image.GetStat()
    If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
        Using annotMgr As AnnotationManager = New AnnotationManager()
            If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
               (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
                Dim px As Single = 2, py As Single = 1, dx As Single = 0.25F, dy As Single = 0.25F
                Dim annotText As GdPicture14.Annotations.AnnotationText = annotMgr.AddTextAnnot(px, py, 2, 2, "GdPicture")
                If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotText IsNot Nothing) Then
                    annotText.FontSize = 20
                End If
                annotText.Dispose()
                If (annotMgr.SaveAnnotationsToPage() <> GdPictureStatus.OK) OrElse
                   (annotMgr.BurnAnnotationsToPage(True) <> GdPictureStatus.OK) Then
                    GoTo with_error
                End If
                Dim points As PointF() = New PointF(6) {New PointF(px, py), New PointF(px + dx, py + dy), New PointF(px + 2 * dx, py),
                                                        New PointF(px + 3 * dx, py + dy), New PointF(px + 4 * dx, py),
                                                        New PointF(px + 5 * dx, py + dy), New PointF(px + 6 * dx, py)}
                Dim annot As GdPicture14.Annotations.AnnotationFreeHandHighlighter = annotMgr.AddFreeHandHighlighterAnnot(Color.GreenYellow, points)
                If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
                    annot.Author = "GdPicture"
                    annot.BorderWidth = 0.1F
                End If
                annot.Dispose()
                If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
                    annotMgr.SaveDocumentToJPEG("freehandhighlighter.jpeg", 75)
                End If
            End If
with_error:
            status = annotMgr.GetStat()
            annotMgr.Close()
        End Using
        image.ReleaseGdPictureImage(imageID)
    End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
    GdViewer1.DisplayFromFile("freehandhighlighter.jpeg")
Else
    MessageBox.Show("Error!   Status: " + status.ToString(), "AnnotationManager.AddFreeHandHighlighterAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
    int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
    status = image.GetStat();
    if ((status == GdPictureStatus.OK) && (imageID != 0))
    {
        using (AnnotationManager annotMgr = new AnnotationManager())
        {
            if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
                (annotMgr.SelectPage(1) == GdPictureStatus.OK))
            {
                float px = 2, py = 1, dx = 0.25f, dy = 0.25f;
                GdPicture14.Annotations.AnnotationText annotText = annotMgr.AddTextAnnot(px, py, 2, 2, "GdPicture");
                if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotText != null))
                {
                    annotText.FontSize = 20;
                }
                annotText.Dispose();
                if ((annotMgr.SaveAnnotationsToPage() != GdPictureStatus.OK) ||
                    (annotMgr.BurnAnnotationsToPage(true) != GdPictureStatus.OK))
                {
                    goto with_error;
                }
                PointF[] points = new PointF[7] { new PointF(px, py), new PointF(px+dx, py+dy), new PointF(px+2*dx, py),
                                                  new PointF(px+3*dx, py+dy), new PointF(px+4*dx, py),
                                                  new PointF(px+5*dx, py+dy), new PointF(px+6*dx, py)};
                GdPicture14.Annotations.AnnotationFreeHandHighlighter annot = annotMgr.AddFreeHandHighlighterAnnot(Color.GreenYellow, points);
                if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
                {
                    annot.Author = "GdPicture";
                    annot.BorderWidth = 0.1f;
                }
                annot.Dispose();
                if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
                    annotMgr.SaveDocumentToJPEG("freehandhighlighter.jpeg", 75);
            }
            with_error:
            status = annotMgr.GetStat();
            annotMgr.Close();
        }
        image.ReleaseGdPictureImage(imageID);
    }
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
    GdViewer1.DisplayFromFile("freehandhighlighter.jpeg");
else
    MessageBox.Show("Error!   Status: " + status.ToString(), "AnnotationManager.AddFreeHandHighlighterAnnot");
See Also