GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / AddRulerAnnot Method
A color object that defines the required color of the newly added ruler annotation. It is the color of the ruler's drawn line and it corresponds to the AnnotationRuler.StrokeColor property.
The horizontal (X) coordinate of the starting point, in inches, where the ruler's line starts.
The vertical (Y) coordinate of the starting point, in inches, where the ruler's line starts.
The horizontal (X) coordinate of the ending point, in inches, where the ruler's line ends.
The vertical (Y) coordinate of the ending point, in inches, where the ruler's line ends.
The measurement unit of the newly added ruler. The ruler presents its current length in the defined unit at the end of the drawn line.
Example





In This Topic
AddRulerAnnot Method (AnnotationManager)
In This Topic
Adds a new GdPicture/XMP ruler annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified. A ruler annotation depicts a single drawn line from the defined starting point to the defined ending point showing its length in the specified measurement unit.

The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeRuler. You can change the annotation properties directly using the GdPicture14.Annotations.AnnotationRuler 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 ruler annotation on the selected page of the document currently handled by this AnnotationManager object.
Syntax
'Declaration
 
Public Function AddRulerAnnot( _
   ByVal BorderColor As Color, _
   ByVal SrcLeft As Single, _
   ByVal SrcTop As Single, _
   ByVal DstLeft As Single, _
   ByVal DstTop As Single, _
   ByVal MeasurementUnit As Annotation.UnitMode _
) As AnnotationRuler
public AnnotationRuler AddRulerAnnot( 
   Color BorderColor,
   float SrcLeft,
   float SrcTop,
   float DstLeft,
   float DstTop,
   Annotation.UnitMode MeasurementUnit
)
public function AddRulerAnnot( 
    BorderColor: Color;
    SrcLeft: Single;
    SrcTop: Single;
    DstLeft: Single;
    DstTop: Single;
    MeasurementUnit: Annotation.UnitMode
): AnnotationRuler; 
public function AddRulerAnnot( 
   BorderColor : Color,
   SrcLeft : float,
   SrcTop : float,
   DstLeft : float,
   DstTop : float,
   MeasurementUnit : Annotation.UnitMode
) : AnnotationRuler;
public: AnnotationRuler* AddRulerAnnot( 
   Color BorderColor,
   float SrcLeft,
   float SrcTop,
   float DstLeft,
   float DstTop,
   Annotation.UnitMode MeasurementUnit
) 
public:
AnnotationRuler^ AddRulerAnnot( 
   Color BorderColor,
   float SrcLeft,
   float SrcTop,
   float DstLeft,
   float DstTop,
   Annotation.UnitMode MeasurementUnit
) 

Parameters

BorderColor
A color object that defines the required color of the newly added ruler annotation. It is the color of the ruler's drawn line and it corresponds to the AnnotationRuler.StrokeColor property.
SrcLeft
The horizontal (X) coordinate of the starting point, in inches, where the ruler's line starts.
SrcTop
The vertical (Y) coordinate of the starting point, in inches, where the ruler's line starts.
DstLeft
The horizontal (X) coordinate of the ending point, in inches, where the ruler's line ends.
DstTop
The vertical (Y) coordinate of the ending point, in inches, where the ruler's line ends.
MeasurementUnit
The measurement unit of the newly added ruler. The ruler presents its current length in the defined unit at the end of the drawn line.

Return Value

A GdPicture/XMP AnnotationRuler object. The newly added GdPicture/XMP ruler 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 ruler 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("rulerannot.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("rulerannot.jpeg")
Else
    MessageBox.Show("Error!   Status: " + status.ToString(), "AnnotationManager.AddRulerAnnot")
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("rulerannot.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("rulerannot.jpeg");
else
    MessageBox.Show("Error!   Status: " + status.ToString(), "AnnotationManager.AddRulerAnnot");
See Also