w:textboxTightWrap (Tight Wrap in Text Box)
Controls which lines of a paragraph are tightly wrapped to the text box boundary rather than using the full text box width.
Parent elements
Description
w:textboxTightWrap specifies how tightly a paragraph inside a text box wraps its content. It allows the text box to visually shrink its bounding box to the actual text extent for some or all lines, rather than occupying the full text box width.
It is defined in ECMA-376 Part 1 §17.3.1.37.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_TextboxTightWrap |
none, allLines, firstAndLastLine, firstLineOnly, lastLineOnly |
Specifies which lines are tightly wrapped. |
Values
| Value | Description |
|---|---|
none |
No tight wrapping; all lines use the full text box width (default). |
allLines |
All lines in the paragraph are tightly wrapped to the text extent. |
firstAndLastLine |
Only the first and last lines of the paragraph are tightly wrapped. |
firstLineOnly |
Only the first line is tightly wrapped. |
lastLineOnly |
Only the last line is tightly wrapped. |
Examples
<w:p>
<w:pPr>
<w:textboxTightWrap w:val="allLines"/>
</w:pPr>
<w:r><w:t>Tight-wrapped paragraph inside a text box.</w:t></w:r>
</w:p>
using DocumentFormat.OpenXml.Wordprocessing;
var para = new Paragraph(
new ParagraphProperties(
new TextBoxTightWrap { Val = TextBoxTightWrapValues.AllLines }
),
new Run(new Text("Tight-wrapped paragraph inside a text box."))
);
Notes
- This property is only meaningful for paragraphs inside a
w:txbxContent(text box) element. - It does not affect text wrapping of surrounding main-body content around the text box.