Prod.: Engine, ver.: 6, ID: 60000485, HowTo : How to get the vdtext's height and width before adding it to the document

HowTo : How to get the vdtext's height and width before adding it to the document

Article60000485
TypeHowTo
ProductEngine
Version6
Date Added4/23/2008
Submitted bySheena Konikkara
Keywords

Subject

How to get the vdtext's height and width before adding it to the document

Summary

How to get the vdtext's height and width before adding it to the document like the version's 5 GetTextSize Function.

Solution

Try a code like:

Private Function GetTextSize(ByVal TextString As String, ByVal tstyle As VectorDraw.Professional.vdPrimaries.vdTextstyle, ByVal Height As Double, ByRef duHeight As Double, ByRef duWidth As Double) As Boolean

duWidth = 0 : duHeight = 0

'Add a check like : If tstyle is nothing/null or textstring is empty exit sub

If tstyle Is Nothing Then Return False

If TextString Is Nothing Or TextString = "" Then Return False

Dim text As VectorDraw.Professional.vdFigures.vdText = New VectorDraw.Professional.vdFigures.vdText()

text.SetUnRegisterDocument(VectorDrawBaseControl1.ActiveDocument)

text.setDocumentDefaults()

text.Style = tstyle

text.TextString = TextString

text.Height = Height

text.Update()

duWidth = text.BoundingBox.Width

duHeight = text.BoundingBox.Height

Return True

End Function