Table of Contents

Text in text boxes and shapes

A text box, a callout or a shape with a label keeps its words in a text body: ordinary paragraphs, in the shape rather than in the page's flow. They are edited with the same calls as body paragraphs.

using DocWright.Dom;
using DocWright.Dom.Editing;

ShapeTextBody box = ((GeometryShape)shape.Root!).TextBody!;
var first = (Paragraph)box.Blocks[0];

document.InsertText(DocumentPosition.StartOf(first), "Updated: ");
document.FormatText(new DocumentSpan(DocumentPosition.StartOf(first), DocumentPosition.InParagraph(first, 8)), f => f.Bold = true);

What is saved

Word writes a text box's text twice: in the DrawingML shape and in a VML fallback for older readers, both identical. An edited text body is written into both, as Word writes it; the shape's size, outline and position are untouched. A shape whose text you did not change is written exactly as it was read (ShapeTextBody.IsEdited says which).

What a text box refuses

As in Word, a text box holds text: a table, a picture, a footnote and a page, column or section break are refused there (InvalidOperationException). A span cannot run from the body into a shape, or from one shape into another.