How to get height of a block of text using graphics.DrawText

I would like to get the height of a block of text I added to a PDF using Graphics.DrawText with a value set for WrapWidth. When I use the Graphics.TextHeight function, it appears to return the height of the first line, not the height of the entire block.

There’s a second method that takes the wrap width that should give you the total height:

Graphics.TextHeight (value as String, wrapWidth as Double) As Double

Used to calculate the height of a line of text passed (given the wrap width passed) drawn with the current font.

But search the forum for a variety of discussions on this, including the API 1 version graphics.StringHeight()

Matthew’s solution threw an error when I added it to the PDF document graphics (not available in console apps. This is a web 2.0 app), but when I created a separate picture and wrote the text to it, I was able to get a height. Unfortunately, the height returned is about 80% of what it should be.

Hmmm… it is a listed method in the LR for PDFGraphics, but that redirects to Graphics, so not clear. LR also indicates “supported for all language types and targets” so maybe time for a Feedback case. They’ll probably need the examples.

There is an additional issue with Web apps: Fonts are seldom available on the server. As a result, using graphics to measure a block of text may work in debug on your machine, but it won’t work on the host.

With Xojo Cloud, it is possible to add fonts fairly easily. But with other Linux hosts, you may have to install the desktop software, and the fonts, yourself. That is the case for most VPS. I don’t know if Lifeboat supports that for Digital Ocean as well.

Not yet :frowning: It is on my to-do list, but nobody has emailed me with “oh gosh I need this now!” so I’ve been focusing on the requests that people have been sending. Happy to add it, it’s a great feature. If any Lifeboat users are reading this, send me an email to bump the priority!

I am not sure it is in high demand :slight_smile: