GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / AddRectangleAnnot Method
A color object that defines the required border color of the newly added rectangle annotation.
A color object that defines the required background color of the newly added rectangle 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
AddRectangleAnnot Method (AnnotationManager)
In This Topic
Adds a new GdPicture/XMP rectangle annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified. This annotation represents a filled and bordered rectangle drawn with the specified colors.

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

Parameters

BorderColor
A color object that defines the required border color of the newly added rectangle annotation.
BackColor
A color object that defines the required background color of the newly added rectangle 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 AnnotationRectangle object. The newly added GdPicture/XMP rectangle 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 rectangle 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 left As Single = 1, top As Single = 1, width As Single = 5, height As Single = 3, dist As Single = 0.2F
                Dim annotRect As GdPicture14.Annotations.AnnotationRectangle = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height)
                If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRect IsNot Nothing) Then
                    annotRect.Author = "GdPicture"
                    annotRect.BorderWidth = 0.05F
                    annotRect.Opacity = 0.85F
                End If
                annotRect.Dispose()
                If annotMgr.BurnAnnotationsToPage(True) = GdPictureStatus.OK Then
                    Dim annotRuler As GdPicture14.Annotations.AnnotationRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
                                                                                                       GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
            
                    If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
                        annotRuler.Author = "GdPicture"
                        annotRuler.BorderWidth = 0.02F
                        annotRuler.FontSize = 10
                        annotRuler.Opacity = 1
                    End If
                    annotRuler.Dispose()
                    annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
                                                        GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
                    If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
                        annotRuler.Author = "GdPicture"
                        annotRuler.BorderWidth = 0.02F
                        annotRuler.FontSize = 10
                        annotRuler.Opacity = 1
                    End If
                    annotRuler.Dispose()
                End If
                If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
                    annotMgr.SaveDocumentToJPEG("rectangle.jpeg", 75)
                End If
            End If
            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("rectangle.jpeg")
Else
    MessageBox.Show("Error!   Status: " + status.ToString(), "AnnotationManager.AddRectangleAnnot")
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 left = 1, top = 1,  width = 5, height = 3, dist = 0.2f;
                GdPicture14.Annotations.AnnotationRectangle annotRect = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height);
                if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRect != null))
                {
                    annotRect.Author = "GdPicture";
                    annotRect.BorderWidth = 0.05f;
                    annotRect.Opacity = 0.85f;
                }
                annotRect.Dispose();
                if (annotMgr.BurnAnnotationsToPage(true) == GdPictureStatus.OK)
                {
                    GdPicture14.Annotations.AnnotationRuler annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
                                                                                                GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
                    if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
                    {
                        annotRuler.Author = "GdPicture";
                        annotRuler.BorderWidth = 0.02f;
                        annotRuler.FontSize = 10;
                        annotRuler.Opacity = 1;
                    }
                    annotRuler.Dispose();
                    annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
                                                        GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
                    if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
                    {
                        annotRuler.Author = "GdPicture";
                        annotRuler.BorderWidth = 0.02f;
                        annotRuler.FontSize = 10;
                        annotRuler.Opacity = 1;
                    }
                    annotRuler.Dispose();
                }
                if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
                    annotMgr.SaveDocumentToJPEG("rectangle.jpeg", 75);
            }
            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("rectangle.jpeg");
else
    MessageBox.Show("Error!   Status: " + status.ToString(), "AnnotationManager.AddRectangleAnnot");
See Also