GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / AddRectangleHighlighterAnnot Method
A color object that defines the required background color (a color for highlighting) of the newly added rectangle highlighter annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Example





In This Topic
AddRectangleHighlighterAnnot Method (AnnotationManager)
In This Topic
Adds a new GdPicture/XMP rectangle highlighter annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified. This annotation highlights a defined rectangle area with the specified color.

The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeRectangleHighlighter. You can change the annotation properties directly using the GdPicture14.Annotations.AnnotationRectangleHighlighter 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 rectangle highlighter annotation on the selected page of the document currently handled by this AnnotationManager object.
Syntax
'Declaration
 
Public Function AddRectangleHighlighterAnnot( _
   ByVal BackColor As Color, _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Width As Single, _
   ByVal Height As Single _
) As AnnotationRectangleHighlighter
public AnnotationRectangleHighlighter AddRectangleHighlighterAnnot( 
   Color BackColor,
   float Left,
   float Top,
   float Width,
   float Height
)
public function AddRectangleHighlighterAnnot( 
    BackColor: Color;
    Left: Single;
    Top: Single;
    Width: Single;
    Height: Single
): AnnotationRectangleHighlighter; 
public function AddRectangleHighlighterAnnot( 
   BackColor : Color,
   Left : float,
   Top : float,
   Width : float,
   Height : float
) : AnnotationRectangleHighlighter;
public: AnnotationRectangleHighlighter* AddRectangleHighlighterAnnot( 
   Color BackColor,
   float Left,
   float Top,
   float Width,
   float Height
) 
public:
AnnotationRectangleHighlighter^ AddRectangleHighlighterAnnot( 
   Color BackColor,
   float Left,
   float Top,
   float Width,
   float Height
) 

Parameters

BackColor
A color object that defines the required background color (a color for highlighting) of the newly added rectangle highlighter annotation.
Left
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
Top
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
Width
The width of the annotation bounding box, in inches.
Height
The height of the annotation bounding box, in inches.

Return Value

A GdPicture/XMP AnnotationRectangleHighlighter object. The newly added GdPicture/XMP rectangle 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 use a rectangle highlighter to permanently highlight 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 annotRectH As GdPicture14.Annotations.AnnotationRectangleHighlighter = annotMgr.AddRectangleHighlighterAnnot(Color.Yellow, left, top, width, height)
            If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRectH IsNot Nothing) Then
                annotRectH.Author = "GdPicture"
                annotRectH.Tag = "Highligher"
            End If
            annotRectH.Dispose()
            GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow)
            occurrence = occurrence + 1
        End While
        If text_found Then
            If (annotMgr.SaveAnnotationsToPage() <> GdPictureStatus.OK) OrElse
               (annotMgr.BurnAnnotationsToPage(True) <> GdPictureStatus.OK) OrElse
               (annotMgr.SaveDocumentToJPEG("text_highlighted.jpg", 75) <> GdPictureStatus.OK) Then
                MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot")
            End If
            GdViewer1.Redraw()
        Else
            MessageBox.Show("The given text has not been found.", "AnnotationManager.AddRectangleHighlighterAnnot")
        End If
    Else
        MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddRectangleHighlighterAnnot")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot")
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.AnnotationRectangleHighlighter annotRectH = annotMgr.AddRectangleHighlighterAnnot(Color.Yellow, left, top, width, height);
            if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRectH != null))
            {
                annotRectH.Author = "GdPicture";
                annotRectH.Tag = "Highligher";
            }
            annotRectH.Dispose();
            GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow);
            occurrence = occurrence + 1;
        }
        if (text_found)
        {
            if ((annotMgr.SaveAnnotationsToPage() != GdPictureStatus.OK) ||
                (annotMgr.BurnAnnotationsToPage(true) != GdPictureStatus.OK) ||
                (annotMgr.SaveDocumentToJPEG("text_highlighted.jpg", 75) != GdPictureStatus.OK))
                MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot");
            GdViewer1.Redraw();
        }
        else
            MessageBox.Show("The given text has not been found.", "AnnotationManager.AddRectangleHighlighterAnnot");
    }
    else
        MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddRectangleHighlighterAnnot");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot");
See Also