Frequently Asked Question:
Clip text to a rectangle
Is there anyway to clip text to a rectangle when using DrawText or similar? In other words, the text I want to draw may be too long for the available space, and I'd like to simply clip it so that it doesn't run into the next column of text. I don't want to wrap or resize the text, simply truncate it to the available space.
There isn't currently a function that would let you directly clip text to a rectangle.
However, with a little bit of work you could programmatically truncate your text strings so that they did not exceed a predefined width. This could be done by taking the predefined width and comparing it to the width of your text string (returned by the GetTextWidth function) and then chopping the required amount off of the text string so that it matched the required width.
Then you could add the truncated text string to the PDF using the DrawText function.