DynaPDSMBS Text Box

I have a lump of text that I want to place into a PDF

I cannot find a way to work out how much space multiline text will occupy in that PDF.
It could be left or centre aligned, but the GetTextHeight methid doesnt mention a bounding width in the same way as Xojo’s graphics command does

Using WriteTextFT with a rectangle, close to the bottom of the page, causes unwanted new PDF pages if I get the size wrong, and right now, in testing, thats happening a lot.

It seems I have 3 possible solutions, but I can’t find a reliable way to implement any of them:

1/ obtain the bounding rectangle size that completely contains the text
2/ shrink the text to fit a rectangle of a size I specify
3/ truncate the text if it doesnt fit in a stated rectangle

Has anyone managed this?

You need to use:

GetTextHeightEx(Width as Double, Align as Integer, aText as string) as Double

There you can pass in width.

And please read this blog post: DynaPDF WriteFText last line handling


I found in the DynaPDF manual that the unwanted new page can be avoided by passing -1 as the height when using WriteText
So as long as I get the size pretty close, I’m there.