LEADTOOLS Annotations (Leadtools.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
AutoSize Method
See Also 
Leadtools.Annotations Namespace > AnnTextObject Class : AutoSize Method



The AutoSize Method is available in LEADTOOLS Document and Medical Imaging toolkits.

Adjusts this AnnTextObject object to where its bounds closely fit its contents.

Syntax

Visual Basic (Declaration) 
Public Overridable Sub AutoSize() 
Visual Basic (Usage)Copy Code
Dim instance As AnnTextObject
 
instance.AutoSize()
C# 
public virtual void AutoSize()
C++/CLI 
public:
virtual void AutoSize(); 

Example

Visual BasicCopy Code
Public Sub AnnTextObject_AutoSize(ByVal container As AnnContainer, ByVal viewer As RasterImageViewer)
   ' first add a new text object
   Dim text As New AnnTextObject()
   text.Pen = New AnnPen(Color.Red, New AnnLength(3))
   text.Text = "Hello World!"
   text.Brush = Nothing
   text.Font = New AnnFont("Arial", New AnnLength(10, AnnUnit.Point), FontStyle.Regular)
   text.EdgeMargin = AnnLength.Empty
   text.Alignment = StringAlignment.Center
   text.LineAlignment = StringAlignment.Center
   text.TextRotate = AnnTextRotate.Rotate0
   text.Bounds = New AnnRectangle(100, 100, 400, 600, AnnUnit.Pixel)
   container.Objects.Add(text)
   viewer.Invalidate()
   MessageBox.Show("A text object with the original bounding rectangle")

   ' now make the object firts the content (its text)
   text.AutoSize()
   viewer.Invalidate()

   MessageBox.Show("Same text object after AutoSize")
End Sub
C#Copy Code
public void AnnTextObject_AutoSize(AnnContainer container, RasterImageViewer viewer)
{
   // first add a new text object
   AnnTextObject text = new AnnTextObject();
   text.Pen = new AnnPen(Color.Red, new AnnLength(3));
   text.Text = "Hello World!";
   text.Brush = null;
   text.Font = new AnnFont("Arial", new AnnLength(10, AnnUnit.Point), FontStyle.Regular);
   text.EdgeMargin = AnnLength.Empty;
   text.Alignment = StringAlignment.Center;
   text.LineAlignment = StringAlignment.Center;
   text.TextRotate = AnnTextRotate.Rotate0;
   text.Bounds = new AnnRectangle(100, 100, 400, 600, AnnUnit.Pixel);
   container.Objects.Add(text);
   viewer.Invalidate();
   MessageBox.Show("A text object with the original bounding rectangle");

   // now make the object firts the content (its text)
   text.AutoSize();
   viewer.Invalidate();

   MessageBox.Show("Same text object after AutoSize");
}

Remarks

Call this method to change the bounds (AnnTextObject.Bounds) value to closely fit its contents. The control will automatically add the correct space around the text for the current font style and size leading and takes into consideration the border size.

When using automation, setting the value of the AnnTextEditDesigner.AutoSizeAfterEdit property to true will result in the toolkit calling the AnnTextObject.AutoSize to adjust the object.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Leadtools.Annotations requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features