My application requires me to add text in the following way (pseudo code):
Function AddText()
//Obj is just an arbitrary reference to an object used to store various values
Dim CurrentX = Obj.X * 72
Dim CurerntY = Obj.Y * 72
Dim pageWidth = Page.PageInfo.Width - LeftMargin - RightMargin
Dim Fragment = New TextFragment(Text)
Fragment.isInline = true
Page.Paragraphs.Add(Fragment)
//Storing the Fragment X and Y positions in object properties
Obj.X = (Fragment.Rectangle.Width Mod PageWidth) / 72 //conversion to inches
Obj.Y = (Fragment.Rectangle.Height + NumberofLines) / 72 //assume number of lines is already calculated
EndFunction
Then repeat the process with new Text
The problem is when adding a new TextFragment and then the line is greater than the page width and begins wrapping the Mod calculation doesn’t work because the word wrapping generates empty space depending on the location of the wrap. Is it possible to somehow obtain this measurement?