How to measure textbox size, know when to split it?

Hi Mark,

You could set the TextBox to autofit its size based on its content and then call TextBox.Shape.FormatDrawing() to calculate that resizing.

In other words, something like this:

TextBox textBox = slide.Content.AddTextBox(...);
textBox.Format.AutoFit = TextAutoFit.ResizeShapeToFitText;

// Write some text...

textBox.Shape.FormatDrawing();
double height = textBox.Shape.Layout.Height;

Then based on that calculated height and the slide’s height (minus the top position of the textbox) you could detect if the text is too large.

Or you could perhaps create a TextBox with a size that fully occupies the slide and then use TextAutoFit.ShrinkTextOnOverflow. That way you won’t need to slit the text into multiple slides.

I hope this helps.

Regards,
Mario