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 As Color, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As Annotation.UnitMode _
) As AnnotationRuler
public AnnotationRuler AddRulerAnnot(
Color ,
float ,
float ,
float ,
float ,
Annotation.UnitMode
)
public function AddRulerAnnot(
: Color;
: Single;
: Single;
: Single;
: Single;
: Annotation.UnitMode
): AnnotationRuler;
public function AddRulerAnnot(
: Color,
: float,
: float,
: float,
: float,
: Annotation.UnitMode
) : AnnotationRuler;
public: AnnotationRuler* AddRulerAnnot(
Color ,
float ,
float ,
float ,
float ,
Annotation.UnitMode
)
public:
AnnotationRuler^ AddRulerAnnot(
Color ,
float ,
float ,
float ,
float ,
Annotation.UnitMode
)
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.
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");
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