How to calculate canvas height with contents

I have a canvas with some text and pictures. I need to know the height of the canvas after the last drawn item either text or picture. Basically i need only the height of the canvas with contents and not the whole canvas. Is this possible. Thanks.

Pass all your drawing through a method which establishes the lowest point of what you draw.
Eg if it is a picture, you KNOW how big it is, and for text you KNOW where you started drawing it, so


if  pictop+picheight > lastbottom then
lastbottom = pictop+picheight 
end if

for text its a bit trickier, but if you are using DrawString (I assume), you need the same sort of code, but you’re looking for the text baseline plus the descenders, and maybe add a pixel or two for luck (:slight_smile: )

//drawing text at positions xpos, ypos

if  ypos + (textheight - textascent) > lastbottom then
lastbottom = ypos + (textheight - textascent) 
end if

thanks i will try the solution.